Verzeichnisstruktur phpBB-3.3.15
- Veröffentlicht
- 28.08.2024
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
ServerRequestInterface.php
001 <?php
002
003 declare(strict_types=1);
004
005 namespace Psr\Http\Message;
006
007 /**
008 * Representation of an incoming, server-side HTTP request.
009 *
010 * Per the HTTP specification, this interface includes properties for
011 * each of the following:
012 *
013 * - Protocol version
014 * - HTTP method
015 * - URI
016 * - Headers
017 * - Message body
018 *
019 * Additionally, it encapsulates all data as it has arrived to the
020 * application from the CGI and/or PHP environment, including:
021 *
022 * - The values represented in $_SERVER.
023 * - Any cookies provided (generally via $_COOKIE)
024 * - Query string arguments (generally via $_GET, or as parsed via parse_str())
025 * - Upload files, if any (as represented by $_FILES)
026 * - Deserialized body parameters (generally from $_POST)
027 *
028 * $_SERVER values MUST be treated as immutable, as they represent application
029 * state at the time of request; as such, no methods are provided to allow
030 * modification of those values. The other values provide such methods, as they
031 * can be restored from $_SERVER or the request body, and may need treatment
032 * during the application (e.g., body parameters may be deserialized based on
033 * content type).
034 *
035 * Additionally, this interface recognizes the utility of introspecting a
036 * request to derive and match additional parameters (e.g., via URI path
037 * matching, decrypting cookie values, deserializing non-form-encoded body
038 * content, matching authorization headers to users, etc). These parameters
039 * are stored in an "attributes" property.
040 *
041 * Requests are considered immutable; all methods that might change state MUST
042 * be implemented such that they retain the internal state of the current
043 * message and return an instance that contains the changed state.
044 */
045 interface ServerRequestInterface extends RequestInterface
046 {
047 /**
048 * Retrieve server parameters.
049 *
050 * Retrieves data related to the incoming request environment,
051 * typically derived from PHP's $_SERVER superglobal. The data IS NOT
052 * REQUIRED to originate from $_SERVER.
053 *
054 * @return array
055 */
056 public function getServerParams();
057
058 /**
059 * Retrieve cookies.
060 *
061 * Retrieves cookies sent by the client to the server.
062 *
063 * The data MUST be compatible with the structure of the $_COOKIE
064 * superglobal.
065 *
066 * @return array
067 */
068 public function getCookieParams();
069
070 /**
071 * Return an instance with the specified cookies.
072 *
073 * The data IS NOT REQUIRED to come from the $_COOKIE superglobal, but MUST
074 * be compatible with the structure of $_COOKIE. Typically, this data will
075 * be injected at instantiation.
076 *
077 * This method MUST NOT update the related Cookie header of the request
078 * instance, nor related values in the server params.
079 *
080 * This method MUST be implemented in such a way as to retain the
081 * immutability of the message, and MUST return an instance that has the
082 * updated cookie values.
083 *
084 * @param array $cookies Array of key/value pairs representing cookies.
085 * @return static
086 */
087 public function withCookieParams(array $cookies);
088
089 /**
090 * Retrieve query string arguments.
091 *
092 * Retrieves the deserialized query string arguments, if any.
093 *
094 * Note: the query params might not be in sync with the URI or server
095 * params. If you need to ensure you are only getting the original
096 * values, you may need to parse the query string from `getUri()->getQuery()`
097 * or from the `QUERY_STRING` server param.
098 *
099 * @return array
100 */
101 public function getQueryParams();
102
103 /**
104 * Return an instance with the specified query string arguments.
105 *
106 * These values SHOULD remain immutable over the course of the incoming
107 * request. They MAY be injected during instantiation, such as from PHP's
108 * $_GET superglobal, or MAY be derived from some other value such as the
109 * URI. In cases where the arguments are parsed from the URI, the data
110 * MUST be compatible with what PHP's parse_str() would return for
111 * purposes of how duplicate query parameters are handled, and how nested
112 * sets are handled.
113 *
114 * Setting query string arguments MUST NOT change the URI stored by the
115 * request, nor the values in the server params.
116 *
117 * This method MUST be implemented in such a way as to retain the
118 * immutability of the message, and MUST return an instance that has the
119 * updated query string arguments.
120 *
121 * @param array $query Array of query string arguments, typically from
122 * $_GET.
123 * @return static
124 */
125 public function withQueryParams(array $query);
126
127 /**
128 * Retrieve normalized file upload data.
129 *
130 * This method returns upload metadata in a normalized tree, with each leaf
131 * an instance of Psr\Http\Message\UploadedFileInterface.
132 *
133 * These values MAY be prepared from $_FILES or the message body during
134 * instantiation, or MAY be injected via withUploadedFiles().
135 *
136 * @return array An array tree of UploadedFileInterface instances; an empty
137 * array MUST be returned if no data is present.
138 */
139 public function getUploadedFiles();
140
141 /**
142 * Create a new instance with the specified uploaded files.
143 *
144 * This method MUST be implemented in such a way as to retain the
145 * immutability of the message, and MUST return an instance that has the
146 * updated body parameters.
147 *
148 * @param array $uploadedFiles An array tree of UploadedFileInterface instances.
149 * @return static
150 * @throws \InvalidArgumentException if an invalid structure is provided.
151 */
152 public function withUploadedFiles(array $uploadedFiles);
153
154 /**
155 * Retrieve any parameters provided in the request body.
156 *
157 * If the request Content-Type is either application/x-www-form-urlencoded
158 * or multipart/form-data, and the request method is POST, this method MUST
159 * return the contents of $_POST.
160 *
161 * Otherwise, this method may return any results of deserializing
162 * the request body content; as parsing returns structured content, the
163 * potential types MUST be arrays or objects only. A null value indicates
164 * the absence of body content.
165 *
166 * @return null|array|object The deserialized body parameters, if any.
167 * These will typically be an array or object.
168 */
169 public function getParsedBody();
170
171 /**
172 * Return an instance with the specified body parameters.
173 *
174 * These MAY be injected during instantiation.
175 *
176 * If the request Content-Type is either application/x-www-form-urlencoded
177 * or multipart/form-data, and the request method is POST, use this method
178 * ONLY to inject the contents of $_POST.
179 *
180 * The data IS NOT REQUIRED to come from $_POST, but MUST be the results of
181 * deserializing the request body content. Deserialization/parsing returns
182 * structured data, and, as such, this method ONLY accepts arrays or objects,
183 * or a null value if nothing was available to parse.
184 *
185 * As an example, if content negotiation determines that the request data
186 * is a JSON payload, this method could be used to create a request
187 * instance with the deserialized parameters.
188 *
189 * This method MUST be implemented in such a way as to retain the
190 * immutability of the message, and MUST return an instance that has the
191 * updated body parameters.
192 *
193 * @param null|array|object $data The deserialized body data. This will
194 * typically be in an array or object.
195 * @return static
196 * @throws \InvalidArgumentException if an unsupported argument type is
197 * provided.
198 */
199 public function withParsedBody($data);
200
201 /**
202 * Retrieve attributes derived from the request.
203 *
204 * The request "attributes" may be used to allow injection of any
205 * parameters derived from the request: e.g., the results of path
206 * match operations; the results of decrypting cookies; the results of
207 * deserializing non-form-encoded message bodies; etc. Attributes
208 * will be application and request specific, and CAN be mutable.
209 *
210 * @return array Attributes derived from the request.
211 */
212 public function getAttributes();
213
214 /**
215 * Retrieve a single derived request attribute.
216 *
217 * Retrieves a single derived request attribute as described in
218 * getAttributes(). If the attribute has not been previously set, returns
219 * the default value as provided.
220 *
221 * This method obviates the need for a hasAttribute() method, as it allows
222 * specifying a default value to return if the attribute is not found.
223 *
224 * @see getAttributes()
225 * @param string $name The attribute name.
226 * @param mixed $default Default value to return if the attribute does not exist.
227 * @return mixed
228 */
229 public function getAttribute(string $name, $default = null);
230
231 /**
232 * Return an instance with the specified derived request attribute.
233 *
234 * This method allows setting a single derived request attribute as
235 * described in getAttributes().
236 *
237 * This method MUST be implemented in such a way as to retain the
238 * immutability of the message, and MUST return an instance that has the
239 * updated attribute.
240 *
241 * @see getAttributes()
242 * @param string $name The attribute name.
243 * @param mixed $value The value of the attribute.
244 * @return static
245 */
246 public function withAttribute(string $name, $value);
247
248 /**
249 * Return an instance that removes the specified derived request attribute.
250 *
251 * This method allows removing a single derived request attribute as
252 * described in getAttributes().
253 *
254 * This method MUST be implemented in such a way as to retain the
255 * immutability of the message, and MUST return an instance that removes
256 * the attribute.
257 *
258 * @see getAttributes()
259 * @param string $name The attribute name.
260 * @return static
261 */
262 public function withoutAttribute(string $name);
263 }
264