ServerRequestFactory implements ServerRequestFactoryInterface

Class ServerRequestFactory to create ServerRequest objects

Highly inspired by https://github.com/phly/http/

Internal

Note that this is not public API yet.

Table of Contents

Interfaces

ServerRequestFactoryInterface

Methods

createServerRequest()  : ServerRequestInterface
Create a new server request.
fromGlobals()  : ServerRequest
Create a request from the original superglobal variables.
createUploadedFile()  : UploadedFileInterface[]|UploadedFileInterface|null
Create and return an UploadedFile instance from a $_FILES specification.
normalizeUploadedFiles()  : array
Normalize uploaded files
prepareHeaders()  : array
Fetch headers from $_SERVER variables which are only the ones starting with HTTP_* and CONTENT_*

Methods

createServerRequest()

Create a new server request.

public createServerRequest(string $method, UriInterface|string $uri[, array $serverParams = [] ]) : ServerRequestInterface

Note that server-params are taken precisely as given - no parsing/processing of the given values is performed, and, in particular, no attempt is made to determine the HTTP method or URI, which must be provided explicitly.

Parameters
$method : string

The HTTP method associated with the request.

$uri : UriInterface|string

The URI associated with the request.

$serverParams : array = []

Array of SAPI parameters with which to seed the generated request instance.

Return values
ServerRequestInterface

fromGlobals()

Create a request from the original superglobal variables.

public static fromGlobals() : ServerRequest
Internal

Note that this is not public API yet.

Tags
throws
InvalidArgumentException

when invalid file values given

Return values
ServerRequest

createUploadedFile()

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

protected static createUploadedFile(array $value) : UploadedFileInterface[]|UploadedFileInterface|null

If the specification represents an array of values, this method will recursively resolve uploaded files.

Parameters
$value : array

$_FILES structure

Return values
UploadedFileInterface[]|UploadedFileInterface|null

normalizeUploadedFiles()

Normalize uploaded files

protected static normalizeUploadedFiles(array $files) : array

Transforms each value into an UploadedFileInterface instance, and ensures that nested arrays are normalized.

Parameters
$files : array
Tags
throws
InvalidArgumentException

for unrecognized values

Return values
array

prepareHeaders()

Fetch headers from $_SERVER variables which are only the ones starting with HTTP_* and CONTENT_*

protected static prepareHeaders(array $server) : array
Parameters
$server : array
Return values
array
On this page

Search results