|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Psr\Http\Message; |
| 4 | + |
| 5 | +/** |
| 6 | + * An incoming (server-side) HTTP request. |
| 7 | + * |
| 8 | + * This interface further describes a server-side request and provides |
| 9 | + * accessors and mutators around common request data, such as query |
| 10 | + * string arguments, body parameters, upload file metadata, cookies, and |
| 11 | + * matched routing parameters. |
| 12 | + */ |
| 13 | +interface IncomingRequestInterface extends RequestInterface |
| 14 | +{ |
| 15 | + /** |
| 16 | + * Retrieve cookies. |
| 17 | + * |
| 18 | + * Retrieves cookies sent by the client to the server. |
| 19 | + * |
| 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. |
| 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 |
| 28 | + */ |
| 29 | + public function getCookieParams(); |
| 30 | + |
| 31 | + /** |
| 32 | + * Set cookie parameters. |
| 33 | + * |
| 34 | + * Allows a library to set the cookie parameters. Use cases include |
| 35 | + * libraries that implement additional security practices, such as |
| 36 | + * encrypting or hashing cookie values; in such cases, they will read |
| 37 | + * 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). |
| 42 | + * |
| 43 | + * @param array|\ArrayAccess $cookies Cookie values/structs |
| 44 | + * |
| 45 | + * @return void |
| 46 | + */ |
| 47 | + public function setCookieParams($cookies); |
| 48 | + |
| 49 | + /** |
| 50 | + * Retrieve query string arguments. |
| 51 | + * |
| 52 | + * Retrieves the deserialized query string arguments, if any. |
| 53 | + * |
| 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). |
| 60 | + * |
| 61 | + * @return array |
| 62 | + */ |
| 63 | + public function getQueryParams(); |
| 64 | + |
| 65 | + /** |
| 66 | + * Retrieve the upload file metadata. |
| 67 | + * |
| 68 | + * This method should return file upload metadata in the same structure |
| 69 | + * as PHP's $_FILES superglobal. |
| 70 | + * |
| 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). |
| 77 | + * |
| 78 | + * @return array Upload file(s) metadata, if any. |
| 79 | + */ |
| 80 | + public function getFileParams(); |
| 81 | + |
| 82 | + /** |
| 83 | + * Retrieve any parameters provided in the request body. |
| 84 | + * |
| 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. |
| 88 | + * |
| 89 | + * In other cases, the parent getBody() method should be used to retrieve |
| 90 | + * the body content. |
| 91 | + * |
| 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. |
| 95 | + */ |
| 96 | + public function getBodyParams(); |
| 97 | + |
| 98 | + /** |
| 99 | + * Set the request body parameters. |
| 100 | + * |
| 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. |
| 109 | + * |
| 110 | + * @return void |
| 111 | + */ |
| 112 | + public function setBodyParams($values); |
| 113 | + |
| 114 | + /** |
| 115 | + * Retrieve parameters matched during routing. |
| 116 | + * |
| 117 | + * 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. |
| 120 | + * |
| 121 | + * @return array|\ArrayAccess Path parameters matched by routing |
| 122 | + */ |
| 123 | + public function getPathParams(); |
| 124 | + |
| 125 | + /** |
| 126 | + * Set parameters discovered by matching that path |
| 127 | + * |
| 128 | + * 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 |
| 133 | + * |
| 134 | + * @return void |
| 135 | + */ |
| 136 | + public function setPathParams(array $values); |
| 137 | +} |
0 commit comments