Skip to content

Psr7RequestTrait

Reading and stripping of intrinsic PSR-7 request data, used by WebRequest.

The three protected helpers work purely against a ServerRequestInterface: one looks a single name up across parsed body, query, cookies, headers and uploaded files; one returns everything, or just one of the named sources (parameters, cookies, files, headers, attributes); and one returns a request clone with a name removed from whichever source holds it, or null when no source did.

They see only what arrived with the request. Runtime parameters set through WebRequest::setParameter(), the strict-validation whitelist and PSR-7 attributes are WebRequest’s own concern and are applied around these helpers, not inside them.

trait Psr7RequestTrait

SourceRequest/Psr7RequestTrait.php
MethodDescription
getRequestParam(ServerRequestInterface $request, string $name, mixed $default = null): mixedHelper used by WebRequest for reading intrinsic HTTP request data.
[`getRequestParams(ServerRequestInterface $request, ?string $source = null): array<intstring, mixed>`](#getrequestparams)
withoutParameter(ServerRequestInterface $request, string $name, ?string $source = null): ?ServerRequestInterface

protected function getRequestParam(ServerRequestInterface $request, string $name, mixed $default = null): mixed

Helper used by WebRequest for reading intrinsic HTTP request data.

ParameterTypeDescription
$requestServerRequestInterface
$namestring
$defaultmixed

Returns mixed

protected function getRequestParams(ServerRequestInterface $request, ?string $source = null): array<int|string, mixed>

ParameterTypeDescription
$requestServerRequestInterface
$source?``string

Returns array``<``int``|``string``, ``mixed``>

protected function withoutParameter(ServerRequestInterface $request, string $name, ?string $source = null): ?ServerRequestInterface

ParameterTypeDescription
$requestServerRequestInterface
$namestring
$source?``string

Returns ?ServerRequestInterface