6
6
* An incoming (server-side) HTTP request.
7
7
*
8
8
* 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
10
10
* string arguments, body parameters, upload file metadata, cookies, and
11
- * matched routing parameters .
11
+ * arbitrary attributes derived from the request by the application .
12
12
*/
13
13
interface IncomingRequestInterface extends RequestInterface
14
14
{
@@ -18,13 +18,10 @@ interface IncomingRequestInterface extends RequestInterface
18
18
* Retrieves cookies sent by the client to the server.
19
19
*
20
20
* 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 .
23
23
*
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
28
25
*/
29
26
public function getCookieParams ();
30
27
@@ -35,28 +32,28 @@ public function getCookieParams();
35
32
* libraries that implement additional security practices, such as
36
33
* encrypting or hashing cookie values; in such cases, they will read
37
34
* 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.
42
36
*
43
- * @param array|\ArrayAccess $cookies Cookie values/structs
37
+ * The value provided MUST be compatible with the structure of $_COOKIE.
44
38
*
39
+ * @param array $cookies Cookie values
45
40
* @return void
41
+ * @throws \InvalidArgumentException For invalid cookie parameters.
46
42
*/
47
- public function setCookieParams ($ cookies );
43
+ public function setCookieParams (array $ cookies );
48
44
49
45
/**
50
46
* Retrieve query string arguments.
51
47
*
52
48
* Retrieves the deserialized query string arguments, if any.
53
49
*
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.
60
57
*
61
58
* @return array
62
59
*/
@@ -65,15 +62,12 @@ public function getQueryParams();
65
62
/**
66
63
* Retrieve the upload file metadata.
67
64
*
68
- * This method should return file upload metadata in the same structure
65
+ * This method MUST return file upload metadata in the same structure
69
66
* as PHP's $_FILES superglobal.
70
67
*
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.
77
71
*
78
72
* @return array Upload file(s) metadata, if any.
79
73
*/
@@ -82,56 +76,51 @@ public function getFileParams();
82
76
/**
83
77
* Retrieve any parameters provided in the request body.
84
78
*
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.
88
83
*
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.
91
86
*
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.
95
88
*/
96
89
public function getBodyParams ();
97
90
98
91
/**
99
92
* Set the request body parameters.
100
93
*
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.
109
97
*
98
+ * @param array $values The deserialized body parameters, if any.
110
99
* @return void
100
+ * @throws \InvalidArgumentException For $values that cannot be accepted.
111
101
*/
112
- public function setBodyParams ($ values );
102
+ public function setBodyParams (array $ values );
113
103
114
104
/**
115
- * Retrieve parameters matched during routing .
105
+ * Retrieve attributes derived from the request .
116
106
*
117
107
* 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.
120
110
*
121
- * @return array|\ArrayAccess Path parameters matched by routing
111
+ * @return array Attributes derived from the request.
122
112
*/
123
- public function getPathParams ();
113
+ public function getAttributes ();
124
114
125
115
/**
126
- * Set parameters discovered by matching that path
116
+ * Set attributes derived from the request
127
117
*
128
118
* 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.
133
121
*
122
+ * @param array $attributes Attributes derived from the request.
134
123
* @return void
135
124
*/
136
- public function setPathParams (array $ values );
125
+ public function setAttributes (array $ attributes );
137
126
}
0 commit comments