ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
GuzzleHttp\Psr7\ServerRequest Class Reference

Server-side HTTP request. More...

+ Inheritance diagram for GuzzleHttp\Psr7\ServerRequest:
+ Collaboration diagram for GuzzleHttp\Psr7\ServerRequest:

Public Member Functions

 __construct ( $method, $uri, array $headers=[], $body=null, $version='1.1', array $serverParams=[])
 
 getServerParams ()
 {Retrieve server parameters.Retrieves data related to the incoming request environment, typically derived from PHP's $_SERVER superglobal. The data IS NOT REQUIRED to originate from $_SERVER.
Returns
array
} More...
 
 getUploadedFiles ()
 {Retrieve normalized file upload data.This method returns upload metadata in a normalized tree, with each leaf an instance of Psr\Http\Message\UploadedFileInterface.These values MAY be prepared from $_FILES or the message body during instantiation, or MAY be injected via withUploadedFiles().
Returns
array An array tree of UploadedFileInterface instances; an empty array MUST be returned if no data is present.
} More...
 
 withUploadedFiles (array $uploadedFiles)
 {Create a new instance with the specified uploaded files.This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that has the updated body parameters.
Parameters
array$uploadedFilesAn array tree of UploadedFileInterface instances.
Returns
static
Exceptions

InvalidArgumentException if an invalid structure is provided.} More...

 
 getCookieParams ()
 {Retrieve cookies.Retrieves cookies sent by the client to the server.The data MUST be compatible with the structure of the $_COOKIE superglobal.
Returns
array
} More...
 
 withCookieParams (array $cookies)
 {Return an instance with the specified cookies.The data IS NOT REQUIRED to come from the $_COOKIE superglobal, but MUST be compatible with the structure of $_COOKIE. Typically, this data will be injected at instantiation.This method MUST NOT update the related Cookie header of the request instance, nor related values in the server params.This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that has the updated cookie values.
Parameters
array$cookiesArray of key/value pairs representing cookies.
Returns
static
} More...
 
 getQueryParams ()
 {Retrieve query string arguments.Retrieves the deserialized query string arguments, if any.Note: the query params might not be in sync with the URI or server params. If you need to ensure you are only getting the original values, you may need to parse the query string from getUri()->getQuery() or from the QUERY_STRING server param.
Returns
array
} More...
 
 withQueryParams (array $query)
 {Return an instance with the specified query string arguments.These values SHOULD remain immutable over the course of the incoming request. They MAY be injected during instantiation, such as from PHP's $_GET superglobal, or MAY be derived from some other value such as the URI. In cases where the arguments are parsed from the URI, the data MUST be compatible with what PHP's parse_str() would return for purposes of how duplicate query parameters are handled, and how nested sets are handled.Setting query string arguments MUST NOT change the URI stored by the request, nor the values in the server params.This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that has the updated query string arguments.
Parameters
array$queryArray of query string arguments, typically from $_GET.
Returns
static
} More...
 
 getParsedBody ()
 {Retrieve any parameters provided in the request body.If the request Content-Type is either application/x-www-form-urlencoded or multipart/form-data, and the request method is POST, this method MUST return the contents of $_POST.Otherwise, this method may return any results of deserializing the request body content; as parsing returns structured content, the potential types MUST be arrays or objects only. A null value indicates the absence of body content.
Returns
null|array|object The deserialized body parameters, if any. These will typically be an array or object.
} More...
 
 withParsedBody ($data)
 {Return an instance with the specified body parameters.These MAY be injected during instantiation.If the request Content-Type is either application/x-www-form-urlencoded or multipart/form-data, and the request method is POST, use this method ONLY to inject the contents of $_POST.The data IS NOT REQUIRED to come from $_POST, but MUST be the results of deserializing the request body content. Deserialization/parsing returns structured data, and, as such, this method ONLY accepts arrays or objects, or a null value if nothing was available to parse.As an example, if content negotiation determines that the request data is a JSON payload, this method could be used to create a request instance with the deserialized parameters.This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that has the updated body parameters.
Parameters
null | array | object$dataThe deserialized body data. This will typically be in an array or object.
Returns
static
Exceptions

InvalidArgumentException if an unsupported argument type is provided.} More...

 
 getAttributes ()
 {Retrieve attributes derived from the request.The request "attributes" may be used to allow injection of any parameters derived from the request: e.g., the results of path match operations; the results of decrypting cookies; the results of deserializing non-form-encoded message bodies; etc. Attributes will be application and request specific, and CAN be mutable.
Returns
array Attributes derived from the request.
} More...
 
 getAttribute ($attribute, $default=null)
 {Retrieve a single derived request attribute.Retrieves a single derived request attribute as described in getAttributes(). If the attribute has not been previously set, returns the default value as provided.This method obviates the need for a hasAttribute() method, as it allows specifying a default value to return if the attribute is not found.
See also
getAttributes()
Parameters
string$nameThe attribute name.
mixed$defaultDefault value to return if the attribute does not exist.
Returns
mixed
} More...
 
 withAttribute ($attribute, $value)
 {Return an instance with the specified derived request attribute.This method allows setting a single derived request attribute as described in getAttributes().This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that has the updated attribute.
See also
getAttributes()
Parameters
string$nameThe attribute name.
mixed$valueThe value of the attribute.
Returns
static
} More...
 
 withoutAttribute ($attribute)
 {Return an instance that removes the specified derived request attribute.This method allows removing a single derived request attribute as described in getAttributes().This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that removes the attribute.
See also
getAttributes()
Parameters
string$nameThe attribute name.
Returns
static
} More...
 
- Public Member Functions inherited from GuzzleHttp\Psr7\Request
 __construct ( $method, $uri, array $headers=[], $body=null, $version='1.1')
 
 getRequestTarget ()
 Retrieves the message's request target. More...
 
 withRequestTarget ($requestTarget)
 Return an instance with the specific request-target. More...
 
 getMethod ()
 Retrieves the HTTP method of the request. More...
 
 withMethod ($method)
 Return an instance with the provided HTTP method. More...
 
 getUri ()
 Retrieves the URI instance. More...
 
 withUri (UriInterface $uri, $preserveHost=false)
 Returns an instance with the provided URI. More...
 
 getRequestTarget ()
 Retrieves the message's request target. More...
 
 withRequestTarget ($requestTarget)
 Return an instance with the specific request-target. More...
 
 getMethod ()
 Retrieves the HTTP method of the request. More...
 
 withMethod ($method)
 Return an instance with the provided HTTP method. More...
 
 getUri ()
 Retrieves the URI instance. More...
 
 withUri (UriInterface $uri, $preserveHost=false)
 Returns an instance with the provided URI. More...
 
- Public Member Functions inherited from Psr\Http\Message\MessageInterface
 getProtocolVersion ()
 Retrieves the HTTP protocol version as a string. More...
 
 withProtocolVersion ($version)
 Return an instance with the specified HTTP protocol version. More...
 
 getHeaders ()
 Retrieves all message header values. More...
 
 hasHeader ($name)
 Checks if a header exists by the given case-insensitive name. More...
 
 getHeader ($name)
 Retrieves a message header value by the given case-insensitive name. More...
 
 getHeaderLine ($name)
 Retrieves a comma-separated string of the values for a single header. More...
 
 withHeader ($name, $value)
 Return an instance with the provided value replacing the specified header. More...
 
 withAddedHeader ($name, $value)
 Return an instance with the specified header appended with the given value. More...
 
 withoutHeader ($name)
 Return an instance without the specified header. More...
 
 getBody ()
 Gets the body of the message. More...
 
 withBody (StreamInterface $body)
 Return an instance with the specified message body. More...
 
 getServerParams ()
 Retrieve server parameters. More...
 
 getCookieParams ()
 Retrieve cookies. More...
 
 withCookieParams (array $cookies)
 Return an instance with the specified cookies. More...
 
 getQueryParams ()
 Retrieve query string arguments. More...
 
 withQueryParams (array $query)
 Return an instance with the specified query string arguments. More...
 
 getUploadedFiles ()
 Retrieve normalized file upload data. More...
 
 withUploadedFiles (array $uploadedFiles)
 Create a new instance with the specified uploaded files. More...
 
 getParsedBody ()
 Retrieve any parameters provided in the request body. More...
 
 withParsedBody ($data)
 Return an instance with the specified body parameters. More...
 
 getAttributes ()
 Retrieve attributes derived from the request. More...
 
 getAttribute ($name, $default=null)
 Retrieve a single derived request attribute. More...
 
 withAttribute ($name, $value)
 Return an instance with the specified derived request attribute. More...
 
 withoutAttribute ($name)
 Return an instance that removes the specified derived request attribute. More...
 

Static Public Member Functions

static normalizeFiles (array $files)
 Return an UploadedFile instance array. More...
 
static fromGlobals ()
 Return a ServerRequest populated with superglobals: $_GET $_POST $_COOKIE $_FILES $_SERVER. More...
 
static getUriFromGlobals ()
 Get a Uri populated with values from $_SERVER. More...
 

Static Private Member Functions

static createUploadedFileFromSpec (array $value)
 Create and return an UploadedFile instance from a $_FILES specification. More...
 
static normalizeNestedFileSpec (array $files=[])
 Normalize an array of file specifications. More...
 

Private Attributes

 $attributes = []
 
 $cookieParams = []
 
 $parsedBody
 
 $queryParams = []
 
 $serverParams
 
 $uploadedFiles = []
 

Detailed Description

Server-side HTTP request.

Extends the Request definition to add methods for accessing incoming data, specifically server parameters, cookies, matched path parameters, query string arguments, body parameters, and upload file information.

"Attributes" are discovered via decomposing the request (and usually specifically the URI path), and typically will be injected by the application.

Requests are considered immutable; all methods that might change state are implemented such that they retain the internal state of the current message and return a new instance that contains the changed state.

Definition at line 25 of file ServerRequest.php.

Constructor & Destructor Documentation

◆ __construct()

GuzzleHttp\Psr7\ServerRequest::__construct (   $method,
  $uri,
array  $headers = [],
  $body = null,
  $version = '1.1',
array  $serverParams = [] 
)
Parameters
string$methodHTTP method
string | UriInterface$uriURI
array$headersRequest headers
string | null | resource | StreamInterface$bodyRequest body
string$versionProtocol version
array$serverParamsTypically the $_SERVER superglobal

Definition at line 65 of file ServerRequest.php.

72 {
73 $this->serverParams = $serverParams;
74
75 parent::__construct($method, $uri, $headers, $body, $version);
76 }

References GuzzleHttp\Psr7\Request\$method, GuzzleHttp\Psr7\ServerRequest\$serverParams, GuzzleHttp\Psr7\Request\$uri, and $version.

Member Function Documentation

◆ createUploadedFileFromSpec()

static GuzzleHttp\Psr7\ServerRequest::createUploadedFileFromSpec ( array  $value)
staticprivate

Create and return an UploadedFile instance from a $_FILES specification.

If the specification represents an array of values, this method will delegate to normalizeNestedFileSpec() and return that return value.

Parameters
array$value$_FILES struct
Returns
array|UploadedFileInterface

Definition at line 114 of file ServerRequest.php.

115 {
116 if (is_array($value['tmp_name'])) {
117 return self::normalizeNestedFileSpec($value);
118 }
119
120 return new UploadedFile(
121 $value['tmp_name'],
122 (int) $value['size'],
123 (int) $value['error'],
124 $value['name'],
125 $value['type']
126 );
127 }
static normalizeNestedFileSpec(array $files=[])
Normalize an array of file specifications.

References GuzzleHttp\Psr7\ServerRequest\normalizeNestedFileSpec().

Referenced by GuzzleHttp\Psr7\ServerRequest\normalizeFiles(), and GuzzleHttp\Psr7\ServerRequest\normalizeNestedFileSpec().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fromGlobals()

static GuzzleHttp\Psr7\ServerRequest::fromGlobals ( )
static

Return a ServerRequest populated with superglobals: $_GET $_POST $_COOKIE $_FILES $_SERVER.

Returns
ServerRequestInterface

Definition at line 166 of file ServerRequest.php.

167 {
168 $method = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : 'GET';
169 $headers = function_exists('getallheaders') ? getallheaders() : [];
171 $body = new LazyOpenStream('php://input', 'r+');
172 $protocol = isset($_SERVER['SERVER_PROTOCOL']) ? str_replace('HTTP/', '', $_SERVER['SERVER_PROTOCOL']) : '1.1';
173
174 $serverRequest = new ServerRequest($method, $uri, $headers, $body, $protocol, $_SERVER);
175
176 return $serverRequest
177 ->withCookieParams($_COOKIE)
178 ->withQueryParams($_GET)
179 ->withParsedBody($_POST)
180 ->withUploadedFiles(self::normalizeFiles($_FILES));
181 }
$_COOKIE['client_id']
Definition: server.php:9
$_GET["client_id"]
$_POST["username"]
static getUriFromGlobals()
Get a Uri populated with values from $_SERVER.
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']

References $_COOKIE, $_GET, $_POST, $_SERVER, GuzzleHttp\Psr7\Request\$method, GuzzleHttp\Psr7\$protocol, GuzzleHttp\Psr7\Request\$uri, and GuzzleHttp\Psr7\ServerRequest\getUriFromGlobals().

Referenced by ILIAS\HTTP\Request\RequestFactoryImpl\create().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAttribute()

GuzzleHttp\Psr7\ServerRequest::getAttribute (   $attribute,
  $default = null 
)

{Retrieve a single derived request attribute.Retrieves a single derived request attribute as described in getAttributes(). If the attribute has not been previously set, returns the default value as provided.This method obviates the need for a hasAttribute() method, as it allows specifying a default value to return if the attribute is not found.

See also
getAttributes()
Parameters
string$nameThe attribute name.
mixed$defaultDefault value to return if the attribute does not exist.
Returns
mixed
}

Implements Psr\Http\Message\ServerRequestInterface.

Definition at line 324 of file ServerRequest.php.

325 {
326 if (false === array_key_exists($attribute, $this->attributes)) {
327 return $default;
328 }
329
330 return $this->attributes[$attribute];
331 }

◆ getAttributes()

GuzzleHttp\Psr7\ServerRequest::getAttributes ( )

{Retrieve attributes derived from the request.The request "attributes" may be used to allow injection of any parameters derived from the request: e.g., the results of path match operations; the results of decrypting cookies; the results of deserializing non-form-encoded message bodies; etc. Attributes will be application and request specific, and CAN be mutable.

Returns
array Attributes derived from the request.
}

Implements Psr\Http\Message\ServerRequestInterface.

Definition at line 316 of file ServerRequest.php.

References GuzzleHttp\Psr7\ServerRequest\$attributes.

◆ getCookieParams()

GuzzleHttp\Psr7\ServerRequest::getCookieParams ( )

{Retrieve cookies.Retrieves cookies sent by the client to the server.The data MUST be compatible with the structure of the $_COOKIE superglobal.

Returns
array
}

Implements Psr\Http\Message\ServerRequestInterface.

Definition at line 259 of file ServerRequest.php.

References GuzzleHttp\Psr7\ServerRequest\$cookieParams.

◆ getParsedBody()

GuzzleHttp\Psr7\ServerRequest::getParsedBody ( )

{Retrieve any parameters provided in the request body.If the request Content-Type is either application/x-www-form-urlencoded or multipart/form-data, and the request method is POST, this method MUST return the contents of $_POST.Otherwise, this method may return any results of deserializing the request body content; as parsing returns structured content, the potential types MUST be arrays or objects only. A null value indicates the absence of body content.

Returns
null|array|object The deserialized body parameters, if any. These will typically be an array or object.
}

Implements Psr\Http\Message\ServerRequestInterface.

Definition at line 297 of file ServerRequest.php.

References GuzzleHttp\Psr7\ServerRequest\$parsedBody.

◆ getQueryParams()

GuzzleHttp\Psr7\ServerRequest::getQueryParams ( )

{Retrieve query string arguments.Retrieves the deserialized query string arguments, if any.Note: the query params might not be in sync with the URI or server params. If you need to ensure you are only getting the original values, you may need to parse the query string from getUri()->getQuery() or from the QUERY_STRING server param.

Returns
array
}

Implements Psr\Http\Message\ServerRequestInterface.

Definition at line 278 of file ServerRequest.php.

References GuzzleHttp\Psr7\ServerRequest\$queryParams.

◆ getServerParams()

GuzzleHttp\Psr7\ServerRequest::getServerParams ( )

{Retrieve server parameters.Retrieves data related to the incoming request environment, typically derived from PHP's $_SERVER superglobal. The data IS NOT REQUIRED to originate from $_SERVER.

Returns
array
}

Implements Psr\Http\Message\ServerRequestInterface.

Definition at line 232 of file ServerRequest.php.

233 {
234 return $this->serverParams;
235 }

References GuzzleHttp\Psr7\ServerRequest\$serverParams.

◆ getUploadedFiles()

GuzzleHttp\Psr7\ServerRequest::getUploadedFiles ( )

{Retrieve normalized file upload data.This method returns upload metadata in a normalized tree, with each leaf an instance of Psr\Http\Message\UploadedFileInterface.These values MAY be prepared from $_FILES or the message body during instantiation, or MAY be injected via withUploadedFiles().

Returns
array An array tree of UploadedFileInterface instances; an empty array MUST be returned if no data is present.
}

Implements Psr\Http\Message\ServerRequestInterface.

Definition at line 240 of file ServerRequest.php.

References GuzzleHttp\Psr7\ServerRequest\$uploadedFiles.

◆ getUriFromGlobals()

static GuzzleHttp\Psr7\ServerRequest::getUriFromGlobals ( )
static

Get a Uri populated with values from $_SERVER.

Returns
UriInterface

Definition at line 188 of file ServerRequest.php.

188 {
189 $uri = new Uri('');
190
191 $uri = $uri->withScheme(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' ? 'https' : 'http');
192
193 $hasPort = false;
194 if (isset($_SERVER['HTTP_HOST'])) {
195 $hostHeaderParts = explode(':', $_SERVER['HTTP_HOST']);
196 $uri = $uri->withHost($hostHeaderParts[0]);
197 if (isset($hostHeaderParts[1])) {
198 $hasPort = true;
199 $uri = $uri->withPort($hostHeaderParts[1]);
200 }
201 } elseif (isset($_SERVER['SERVER_NAME'])) {
202 $uri = $uri->withHost($_SERVER['SERVER_NAME']);
203 } elseif (isset($_SERVER['SERVER_ADDR'])) {
204 $uri = $uri->withHost($_SERVER['SERVER_ADDR']);
205 }
206
207 if (!$hasPort && isset($_SERVER['SERVER_PORT'])) {
208 $uri = $uri->withPort($_SERVER['SERVER_PORT']);
209 }
210
211 $hasQuery = false;
212 if (isset($_SERVER['REQUEST_URI'])) {
213 $requestUriParts = explode('?', $_SERVER['REQUEST_URI']);
214 $uri = $uri->withPath($requestUriParts[0]);
215 if (isset($requestUriParts[1])) {
216 $hasQuery = true;
217 $uri = $uri->withQuery($requestUriParts[1]);
218 }
219 }
220
221 if (!$hasQuery && isset($_SERVER['QUERY_STRING'])) {
222 $uri = $uri->withQuery($_SERVER['QUERY_STRING']);
223 }
224
225 return $uri;
226 }

References $_SERVER, and GuzzleHttp\Psr7\Request\$uri.

Referenced by GuzzleHttp\Psr7\ServerRequest\fromGlobals().

+ Here is the caller graph for this function:

◆ normalizeFiles()

static GuzzleHttp\Psr7\ServerRequest::normalizeFiles ( array  $files)
static

Return an UploadedFile instance array.

Parameters
array$filesA array which respect $_FILES structure
Exceptions
InvalidArgumentExceptionfor unrecognized values
Returns
array

Definition at line 85 of file ServerRequest.php.

86 {
87 $normalized = [];
88
89 foreach ($files as $key => $value) {
90 if ($value instanceof UploadedFileInterface) {
91 $normalized[$key] = $value;
92 } elseif (is_array($value) && isset($value['tmp_name'])) {
93 $normalized[$key] = self::createUploadedFileFromSpec($value);
94 } elseif (is_array($value)) {
95 $normalized[$key] = self::normalizeFiles($value);
96 continue;
97 } else {
98 throw new InvalidArgumentException('Invalid value in files specification');
99 }
100 }
101
102 return $normalized;
103 }
$files
Definition: add-vimline.php:18
static normalizeFiles(array $files)
Return an UploadedFile instance array.
static createUploadedFileFromSpec(array $value)
Create and return an UploadedFile instance from a $_FILES specification.
$key
Definition: croninfo.php:18

References $files, $key, GuzzleHttp\Psr7\ServerRequest\createUploadedFileFromSpec(), and GuzzleHttp\Psr7\ServerRequest\normalizeFiles().

Referenced by GuzzleHttp\Psr7\ServerRequest\normalizeFiles().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ normalizeNestedFileSpec()

static GuzzleHttp\Psr7\ServerRequest::normalizeNestedFileSpec ( array  $files = [])
staticprivate

Normalize an array of file specifications.

Loops through all nested files and returns a normalized array of UploadedFileInterface instances.

Parameters
array$files
Returns
UploadedFileInterface[]

Definition at line 138 of file ServerRequest.php.

139 {
140 $normalizedFiles = [];
141
142 foreach (array_keys($files['tmp_name']) as $key) {
143 $spec = [
144 'tmp_name' => $files['tmp_name'][$key],
145 'size' => $files['size'][$key],
146 'error' => $files['error'][$key],
147 'name' => $files['name'][$key],
148 'type' => $files['type'][$key],
149 ];
150 $normalizedFiles[$key] = self::createUploadedFileFromSpec($spec);
151 }
152
153 return $normalizedFiles;
154 }

References $files, $key, and GuzzleHttp\Psr7\ServerRequest\createUploadedFileFromSpec().

Referenced by GuzzleHttp\Psr7\ServerRequest\createUploadedFileFromSpec().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ withAttribute()

GuzzleHttp\Psr7\ServerRequest::withAttribute (   $attribute,
  $value 
)

{Return an instance with the specified derived request attribute.This method allows setting a single derived request attribute as described in getAttributes().This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that has the updated attribute.

See also
getAttributes()
Parameters
string$nameThe attribute name.
mixed$valueThe value of the attribute.
Returns
static
}

Implements Psr\Http\Message\ServerRequestInterface.

Definition at line 336 of file ServerRequest.php.

337 {
338 $new = clone $this;
339 $new->attributes[$attribute] = $value;
340
341 return $new;
342 }

References $new.

◆ withCookieParams()

GuzzleHttp\Psr7\ServerRequest::withCookieParams ( array  $cookies)

{Return an instance with the specified cookies.The data IS NOT REQUIRED to come from the $_COOKIE superglobal, but MUST be compatible with the structure of $_COOKIE. Typically, this data will be injected at instantiation.This method MUST NOT update the related Cookie header of the request instance, nor related values in the server params.This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that has the updated cookie values.

Parameters
array$cookiesArray of key/value pairs representing cookies.
Returns
static
}

Implements Psr\Http\Message\ServerRequestInterface.

Definition at line 267 of file ServerRequest.php.

268 {
269 $new = clone $this;
270 $new->cookieParams = $cookies;
271
272 return $new;
273 }

References $new.

◆ withoutAttribute()

GuzzleHttp\Psr7\ServerRequest::withoutAttribute (   $attribute)

{Return an instance that removes the specified derived request attribute.This method allows removing a single derived request attribute as described in getAttributes().This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that removes the attribute.

See also
getAttributes()
Parameters
string$nameThe attribute name.
Returns
static
}

Implements Psr\Http\Message\ServerRequestInterface.

Definition at line 347 of file ServerRequest.php.

348 {
349 if (false === array_key_exists($attribute, $this->attributes)) {
350 return $this;
351 }
352
353 $new = clone $this;
354 unset($new->attributes[$attribute]);
355
356 return $new;
357 }

References $new.

◆ withParsedBody()

GuzzleHttp\Psr7\ServerRequest::withParsedBody (   $data)

{Return an instance with the specified body parameters.These MAY be injected during instantiation.If the request Content-Type is either application/x-www-form-urlencoded or multipart/form-data, and the request method is POST, use this method ONLY to inject the contents of $_POST.The data IS NOT REQUIRED to come from $_POST, but MUST be the results of deserializing the request body content. Deserialization/parsing returns structured data, and, as such, this method ONLY accepts arrays or objects, or a null value if nothing was available to parse.As an example, if content negotiation determines that the request data is a JSON payload, this method could be used to create a request instance with the deserialized parameters.This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that has the updated body parameters.

Parameters
null | array | object$dataThe deserialized body data. This will typically be in an array or object.
Returns
static
Exceptions

InvalidArgumentException if an unsupported argument type is provided.}

Implements Psr\Http\Message\ServerRequestInterface.

Definition at line 305 of file ServerRequest.php.

306 {
307 $new = clone $this;
308 $new->parsedBody = $data;
309
310 return $new;
311 }

References $data, and $new.

◆ withQueryParams()

GuzzleHttp\Psr7\ServerRequest::withQueryParams ( array  $query)

{Return an instance with the specified query string arguments.These values SHOULD remain immutable over the course of the incoming request. They MAY be injected during instantiation, such as from PHP's $_GET superglobal, or MAY be derived from some other value such as the URI. In cases where the arguments are parsed from the URI, the data MUST be compatible with what PHP's parse_str() would return for purposes of how duplicate query parameters are handled, and how nested sets are handled.Setting query string arguments MUST NOT change the URI stored by the request, nor the values in the server params.This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that has the updated query string arguments.

Parameters
array$queryArray of query string arguments, typically from $_GET.
Returns
static
}

Implements Psr\Http\Message\ServerRequestInterface.

Definition at line 286 of file ServerRequest.php.

287 {
288 $new = clone $this;
289 $new->queryParams = $query;
290
291 return $new;
292 }
$query

References $new, and $query.

◆ withUploadedFiles()

GuzzleHttp\Psr7\ServerRequest::withUploadedFiles ( array  $uploadedFiles)

{Create a new instance with the specified uploaded files.This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that has the updated body parameters.

Parameters
array$uploadedFilesAn array tree of UploadedFileInterface instances.
Returns
static
Exceptions

InvalidArgumentException if an invalid structure is provided.}

Implements Psr\Http\Message\ServerRequestInterface.

Definition at line 248 of file ServerRequest.php.

249 {
250 $new = clone $this;
251 $new->uploadedFiles = $uploadedFiles;
252
253 return $new;
254 }

References $new, and GuzzleHttp\Psr7\ServerRequest\$uploadedFiles.

Field Documentation

◆ $attributes

GuzzleHttp\Psr7\ServerRequest::$attributes = []
private

Definition at line 30 of file ServerRequest.php.

Referenced by GuzzleHttp\Psr7\ServerRequest\getAttributes().

◆ $cookieParams

GuzzleHttp\Psr7\ServerRequest::$cookieParams = []
private

Definition at line 35 of file ServerRequest.php.

Referenced by GuzzleHttp\Psr7\ServerRequest\getCookieParams().

◆ $parsedBody

GuzzleHttp\Psr7\ServerRequest::$parsedBody
private

Definition at line 40 of file ServerRequest.php.

Referenced by GuzzleHttp\Psr7\ServerRequest\getParsedBody().

◆ $queryParams

GuzzleHttp\Psr7\ServerRequest::$queryParams = []
private

Definition at line 45 of file ServerRequest.php.

Referenced by GuzzleHttp\Psr7\ServerRequest\getQueryParams().

◆ $serverParams

GuzzleHttp\Psr7\ServerRequest::$serverParams
private

◆ $uploadedFiles

GuzzleHttp\Psr7\ServerRequest::$uploadedFiles = []
private

The documentation for this class was generated from the following file: