66 * An incoming (server-side) HTTP request.
77 *
88 * This interface further describes a server-side request and provides
9- * accessors and mutators around common request data, such as query
9+ * accessors and mutators around common request data, including query
1010 * string arguments, body parameters, upload file metadata, cookies, and
11- * matched routing parameters .
11+ * arbitrary attributes derived from the request by the application .
1212 */
1313interface IncomingRequestInterface extends RequestInterface
1414{
@@ -18,13 +18,10 @@ interface IncomingRequestInterface extends RequestInterface
1818 * Retrieves cookies sent by the client to the server.
1919 *
2020 * The assumption is these are injected during instantiation, typically
21- * from PHP's $_COOKIE superglobal, and should remain immutable over the
22- * course of the incoming request .
21+ * from PHP's $_COOKIE superglobal. The data IS NOT REQUIRED to come from
22+ * $_COOKIE, but MUST be compatible with the structure of $_COOKIE .
2323 *
24- * The return value can be either an array or an object that acts like
25- * an array (e.g., implements ArrayAccess, or an ArrayObject).
26- *
27- * @return array|\ArrayAccess
24+ * @return array
2825 */
2926 public function getCookieParams ();
3027
@@ -35,28 +32,28 @@ public function getCookieParams();
3532 * libraries that implement additional security practices, such as
3633 * encrypting or hashing cookie values; in such cases, they will read
3734 * the original value, filter them, and re-inject into the incoming
38- * request..
39- *
40- * The value provided should be an array or array-like object
41- * (e.g., implements ArrayAccess, or an ArrayObject).
35+ * request.
4236 *
43- * @param array|\ArrayAccess $cookies Cookie values/structs
37+ * The value provided MUST be compatible with the structure of $_COOKIE.
4438 *
39+ * @param array $cookies Cookie values
4540 * @return void
41+ * @throws \InvalidArgumentException For invalid cookie parameters.
4642 */
47- public function setCookieParams ($ cookies );
43+ public function setCookieParams (array $ cookies );
4844
4945 /**
5046 * Retrieve query string arguments.
5147 *
5248 * Retrieves the deserialized query string arguments, if any.
5349 *
54- * The assumption is these are injected during instantiation, typically
55- * from PHP's $_GET superglobal, and should remain immutable over the
56- * course of the incoming request.
57- *
58- * The return value can be either an array or an object that acts like
59- * an array (e.g., implements ArrayAccess, or an ArrayObject).
50+ * These values SHOULD remain immutable over the course of the incoming
51+ * request. They MAY be injected during instantiation, such as from PHP's
52+ * $_GET superglobal, or MAY be derived from some other value such as the
53+ * URI. In cases where the arguments are parsed from the URI, the data
54+ * MUST be compatible with what PHP's `parse_str()` would return for
55+ * purposes of how duplicate query parameters are handled, and how nested
56+ * sets are handled.
6057 *
6158 * @return array
6259 */
@@ -65,15 +62,12 @@ public function getQueryParams();
6562 /**
6663 * Retrieve the upload file metadata.
6764 *
68- * This method should return file upload metadata in the same structure
65+ * This method MUST return file upload metadata in the same structure
6966 * as PHP's $_FILES superglobal.
7067 *
71- * The assumption is these are injected during instantiation, typically
72- * from PHP's $_FILES superglobal, and should remain immutable over the
73- * course of the incoming request.
74- *
75- * The return value can be either an array or an object that acts like
76- * an array (e.g., implements ArrayAccess, or an ArrayObject).
68+ * These values SHOULD remain immutable over the course of the incoming
69+ * request. They MAY be injected during instantiation, such as from PHP's
70+ * $_FILES superglobal, or MAY be derived from other sources.
7771 *
7872 * @return array Upload file(s) metadata, if any.
7973 */
@@ -82,56 +76,51 @@ public function getFileParams();
8276 /**
8377 * Retrieve any parameters provided in the request body.
8478 *
85- * If the request body can be deserialized, and if the deserialized values
86- * can be represented as an array or object, this method can be used to
87- * retrieve them.
79+ * If the request body can be deserialized to an array, this method MAY be
80+ * used to retrieve them. These MAY be injected during instantiation from
81+ * PHP's $_POST superglobal. The data IS NOT REQUIRED to come from $_POST,
82+ * but MUST be an array.
8883 *
89- * In other cases, the parent getBody() method should be used to retrieve
90- * the body content.
84+ * In cases where the request content cannot be coerced to an array, the
85+ * parent getBody() method should be used to retrieve the body content.
9186 *
92- * @return array|object The deserialized body parameters, if any. These may
93- * be either an array or an object, though an array or
94- * array-like object is recommended.
87+ * @return array The deserialized body parameters, if any.
9588 */
9689 public function getBodyParams ();
9790
9891 /**
9992 * Set the request body parameters.
10093 *
101- * If the body content can be deserialized, the values obtained may then
102- * be injected into the response using this method. This method will
103- * typically be invoked by a factory marshaling request parameters.
104- *
105- * @param array|object $values The deserialized body parameters, if any.
106- * These may be either an array or an object,
107- * though an array or array-like object is
108- * recommended.
94+ * If the body content can be deserialized to an array, the values obtained
95+ * MAY then be injected into the response using this method. This method
96+ * will typically be invoked by a factory marshaling request parameters.
10997 *
98+ * @param array $values The deserialized body parameters, if any.
11099 * @return void
100+ * @throws \InvalidArgumentException For $values that cannot be accepted.
111101 */
112- public function setBodyParams ($ values );
102+ public function setBodyParams (array $ values );
113103
114104 /**
115- * Retrieve parameters matched during routing .
105+ * Retrieve attributes derived from the request .
116106 *
117107 * If a router or similar is used to match against the path and/or request,
118- * this method can be used to retrieve the results, so long as those
119- * results can be represented as an array or array-like object .
108+ * this method MAY be used to retrieve the results, so long as those
109+ * results can be represented as an array.
120110 *
121- * @return array|\ArrayAccess Path parameters matched by routing
111+ * @return array Attributes derived from the request.
122112 */
123- public function getPathParams ();
113+ public function getAttributes ();
124114
125115 /**
126- * Set parameters discovered by matching that path
116+ * Set attributes derived from the request
127117 *
128118 * If a router or similar is used to match against the path and/or request,
129- * this method can be used to inject the request with the results, so long
130- * as those results can be represented as an array or array-like object.
131- *
132- * @param array|\ArrayAccess $values Path parameters matched by routing
119+ * this method MAY be used to inject the request with the results, so long
120+ * as those results can be represented as an array.
133121 *
122+ * @param array $attributes Attributes derived from the request.
134123 * @return void
135124 */
136- public function setPathParams (array $ values );
125+ public function setAttributes (array $ attributes );
137126}
0 commit comments