Joomla CMS  4.2.2
Documentation des API du CMS Joomla en version 4.2.2
Référence de l'espace de nommage Laminas\Diactoros

Espaces de nommage

 Exception
 
 Request
 
 Response
 

Structures de données

class  AbstractSerializer
 
class  CallbackStream
 
class  ConfigProvider
 
class  HeaderSecurity
 
class  Module
 
class  PhpInputStream
 
class  RelativeStream
 
class  Request
 
class  RequestFactory
 
class  Response
 
class  ResponseFactory
 
class  ServerRequest
 
class  ServerRequestFactory
 
class  Stream
 
class  StreamFactory
 
class  UploadedFile
 
class  UploadedFileFactory
 
class  Uri
 
class  UriFactory
 

Fonctions

 createUploadedFile (array $spec)
 
 marshalHeadersFromSapi (array $server)
 
 marshalMethodFromSapi (array $server)
 
 marshalProtocolVersionFromSapi (array $server)
 
 marshalUriFromSapi (array $server, array $headers)
 
 normalizeServer (array $server, callable $apacheRequestHeaderCallback=null)
 
 normalizeUploadedFiles (array $files)
 
 parseCookieHeader ($cookieHeader)
 
 getProtocolVersion ()
 
 withProtocolVersion ($version)
 
 getHeaders ()
 
 hasHeader ($header)
 
 getHeader ($header)
 
 getHeaderLine ($name)
 
 withHeader ($header, $value)
 
 withAddedHeader ($header, $value)
 
 withoutHeader ($header)
 
 getBody ()
 
 withBody (StreamInterface $body)
 
 getStream ($stream, string $modeIfNotInstance)
 
 setHeaders (array $originalHeaders)
 
 validateProtocolVersion ($version)
 
 filterHeaderValue ($values)
 
 assertHeader ($name)
 
 initialize ( $uri=null, string $method=null, $body='php://memory', array $headers=[])
 
 createUri ($uri)
 
 getRequestTarget ()
 
 withRequestTarget ($requestTarget)
 
 getMethod ()
 
 withMethod ($method)
 
 getUri ()
 
 withUri (UriInterface $uri, $preserveHost=false)
 
 setMethod ($method)
 
 getHostFromUri ()
 

Variables

trait MessageTrait
 
 $headerNames = []
 
 $protocol = '1.1'
 
 $stream
 
trait RequestTrait
 
 $method = 'GET'
 
 $requestTarget
 
 $uri
 

Documentation des fonctions

◆ assertHeader()

Laminas\Diactoros\assertHeader (   $name)
private

Ensure header name and values are valid.

Paramètres
string$name
Exceptions
Exception

Références $name, et HeaderSecurity\assertValidName().

Référencé par Laminas\Diactoros\setHeaders(), Laminas\Diactoros\withAddedHeader(), et Laminas\Diactoros\withHeader().

◆ createUploadedFile()

Laminas\Diactoros\createUploadedFile ( array  $spec)

Create an uploaded file instance from an array of values.

Paramètres
array$specA single $_FILES entry.
Exceptions
Exception

Références null.

Référencé par Laminas\Diactoros\normalizeUploadedFiles().

◆ createUri()

Laminas\Diactoros\createUri (   $uri)
private

Create and return a URI instance.

If $uri is a already a UriInterface instance, returns it.

If $uri is a string, passes it to the Uri constructor to return an instance.

If $uri is null, creates and returns an emptyUri` instance.

Otherwise, it raises an exception.

Paramètres
null | string | UriInterface$uri
Exceptions
Exception

Références Laminas\Diactoros\$uri, et null.

Référencé par Router\build(), et Laminas\Diactoros\initialize().

◆ filterHeaderValue()

Laminas\Diactoros\filterHeaderValue (   $values)
private
Paramètres
mixed$values
Renvoie
string[]

Références $value, et HeaderSecurity\assertValid().

Référencé par Laminas\Diactoros\setHeaders(), Laminas\Diactoros\withAddedHeader(), et Laminas\Diactoros\withHeader().

◆ getBody()

Laminas\Diactoros\getBody ( )

Gets the body of the message.

Renvoie
StreamInterface Returns the body as a stream.

Références Laminas\Diactoros\$stream.

Référencé par Cache\onAfterRespond(), et CMSApplication\toString().

◆ getHeader()

Laminas\Diactoros\getHeader (   $header)

Retrieves a message header value by the given case-insensitive name.

This method returns an array of all the header values of the given case-insensitive header name.

If the header does not appear in the message, this method MUST return an empty array.

Paramètres
string$headerCase-insensitive header field name.
Renvoie
string[] An array of string values as provided for the given header. If the header does not appear in the message, this method MUST return an empty array.

Références $header, et Laminas\Diactoros\hasHeader().

Référencé par Laminas\Diactoros\getHeaderLine().

◆ getHeaderLine()

Laminas\Diactoros\getHeaderLine (   $name)

Retrieves a comma-separated string of the values for a single header.

This method returns all of the header values of the given case-insensitive header name as a string concatenated together using a comma.

NOTE: Not all header values may be appropriately represented using comma concatenation. For such headers, use getHeader() instead and supply your own delimiter when concatenating.

If the header does not appear in the message, this method MUST return an empty string.

Paramètres
string$nameCase-insensitive header field name.
Renvoie
string A string of values as provided for the given header concatenated together using a comma. If the header does not appear in the message, this method MUST return an empty string.

Références $name, $value, et Laminas\Diactoros\getHeader().

◆ getHeaders()

Laminas\Diactoros\getHeaders ( )

Retrieves all message headers.

The keys represent the header name as it will be sent over the wire, and each value is an array of strings associated with the header.

// Represent the headers as a string
foreach ($message->getHeaders() as $name => $values) {
    echo $name . ": " . implode(", ", $values);
}

// Emit headers iteratively:
foreach ($message->getHeaders() as $name => $values) {
    foreach ($values as $value) {
        header(sprintf('%s: %s', $name, $value), false);
    }
}
Renvoie
array Returns an associative array of the message's headers. Each key MUST be a header name, and each value MUST be an array of strings.

◆ getHostFromUri()

Laminas\Diactoros\getHostFromUri ( )
private

Retrieve the host from the URI instance

Référencé par Request\getHeader(), Request\getHeaders(), et Laminas\Diactoros\initialize().

◆ getMethod()

Laminas\Diactoros\getMethod ( )

Retrieves the HTTP method of the request.

Renvoie
string Returns the request method.

Références Laminas\Diactoros\$method.

◆ getProtocolVersion()

Laminas\Diactoros\getProtocolVersion ( )

Retrieves the HTTP protocol version as a string.

The string MUST contain only the HTTP version number (e.g., "1.1", "1.0").

Renvoie
string HTTP protocol version.

Références Laminas\Diactoros\$protocol.

◆ getRequestTarget()

Laminas\Diactoros\getRequestTarget ( )

Retrieves the message's request target.

Retrieves the message's request-target either as it will appear (for clients), as it appeared at request (for servers), or as it was specified for the instance (see withRequestTarget()).

In most cases, this will be the origin-form of the composed URI, unless a value was provided to the concrete implementation (see withRequestTarget() below).

If no URI is available, and no request-target has been specifically provided, this method MUST return the string "/".

Références Laminas\Diactoros\$requestTarget, $target, et null.

◆ getStream()

Laminas\Diactoros\getStream (   $stream,
string  $modeIfNotInstance 
)
private

◆ getUri()

Laminas\Diactoros\getUri ( )

Retrieves the URI instance.

This method MUST return a UriInterface instance.

UriInterface Returns a UriInterface instance representing the URI of the request, if any.

Références Laminas\Diactoros\$uri.

◆ hasHeader()

Laminas\Diactoros\hasHeader (   $header)

Checks if a header exists by the given case-insensitive name.

Paramètres
string$headerCase-insensitive header name.
Renvoie
bool Returns true if any header names match the given header name using a case-insensitive string comparison. Returns false if no matching header name is found in the message.

Références $header.

Référencé par Laminas\Diactoros\getHeader(), Laminas\Diactoros\initialize(), AbstractWebApplication\respond(), Laminas\Diactoros\withAddedHeader(), Laminas\Diactoros\withoutHeader(), et Laminas\Diactoros\withUri().

◆ initialize()

Laminas\Diactoros\initialize (   $uri = null,
string  $method = null,
  $body = 'php://memory',
array  $headers = [] 
)
private

Initialize request state.

Used by constructors.

Paramètres
null | string | UriInterface$uriURI for the request, if any.
null | string$methodHTTP method for the request, if any.
string | resource | StreamInterface$bodyMessage body, if any.
array$headersHeaders for the message, if any.
Exceptions
Exception

Références Laminas\Diactoros\$method, Laminas\Diactoros\$uri, Laminas\Diactoros\createUri(), Laminas\Diactoros\getHostFromUri(), Laminas\Diactoros\getStream(), Laminas\Diactoros\hasHeader(), null, Laminas\Diactoros\setHeaders(), et Laminas\Diactoros\setMethod().

Référencé par Request\__construct(), Encrypt\__construct(), ServerRequest\__construct(), Engine\__construct(), PHP32\initialize(), PHP64\initialize(), et Inline\parse().

◆ marshalHeadersFromSapi()

Laminas\Diactoros\marshalHeadersFromSapi ( array  $server)
Paramètres
array$serverValues obtained from the SAPI (generally $_SERVER).
Renvoie
array Header/value pairs

Références $key, $name, et $value.

Référencé par ServerRequestFactory\fromGlobals().

◆ marshalMethodFromSapi()

Laminas\Diactoros\marshalMethodFromSapi ( array  $server)

Retrieve the request method from the SAPI parameters.

Référencé par ServerRequestFactory\fromGlobals().

◆ marshalProtocolVersionFromSapi()

Laminas\Diactoros\marshalProtocolVersionFromSapi ( array  $server)

Return HTTP protocol version (X.Y) as discovered within a $_SERVER array.

Exceptions
Exception

Références UnrecognizedProtocolVersionException\forVersion().

Référencé par ServerRequestFactory\fromGlobals().

◆ marshalUriFromSapi()

Laminas\Diactoros\marshalUriFromSapi ( array  $server,
array  $headers 
)

Marshal a Uri instance based on the values presnt in the $_SERVER array and headers.

Paramètres
array$serverSAPI parameters
array$headersHTTP request headers

Retrieve a header value from an array of headers using a case-insensitive lookup.

Paramètres
array$headersKey/value header pairs
mixed$defaultDefault value to return if header not found
Renvoie
mixed

Marshal the host and port from HTTP headers and/or the PHP environment.

Renvoie
array Array of two items, host and port, in that order (can be passed to a list() operation).
Paramètres
string | array$host
Renvoie
array Array of two items, host and port, in that order (can be passed to a list() operation).
array Array of two items, host and port, in that order (can be passed to a list() operation).

Detect the path for the request

Looks at a variety of criteria in order to attempt to autodetect the base request path, including:

  • IIS7 UrlRewrite environment
  • REQUEST_URI
  • ORIG_PATH_INFO

From Laminas class

Références $default, $header, $name, $path, $query, Laminas\Diactoros\$uri, $value, elseif, et null.

Référencé par ServerRequestFactory\fromGlobals().

◆ normalizeServer()

Laminas\Diactoros\normalizeServer ( array  $server,
callable  $apacheRequestHeaderCallback = null 
)

Marshal the $_SERVER array

Pre-processes and returns the $_SERVER superglobal. In particularly, it attempts to detect the Authorization header, which is often not aggregated correctly under various SAPI/httpd combinations.

Paramètres
null | callable$apacheRequestHeaderCallbackCallback that can be used to retrieve Apache request headers. This defaults to apache_request_headers under the Apache mod_php.
Renvoie
array Either $server verbatim, or with an added HTTP_AUTHORIZATION header.

Références null.

Référencé par ServerRequestFactory\fromGlobals().

◆ normalizeUploadedFiles()

Laminas\Diactoros\normalizeUploadedFiles ( array  $files)

Normalize uploaded files

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

Renvoie
UploadedFileInterface[]
Exceptions
Exception

Traverse a nested tree of uploaded file specifications.

Paramètres
string[]|array[]$tmpNameTree
int[]|array[]$sizeTree
int[]|array[]$errorTree
string[]|array[]|null$nameTree
string[]|array[]|null$typeTree
Renvoie
UploadedFile[]|array[]

Normalize an array of file specifications.

Loops through all nested files (as determined by receiving an array to the tmp_name key of a $_FILES specification) and returns a normalized array of UploadedFile instances.

This function normalizes a $_FILES array representing a nested set of uploaded files as produced by the php-fpm SAPI, CGI SAPI, or mod_php SAPI.

Paramètres
array$files
Renvoie
UploadedFile[]

Références $key, $value, Laminas\Diactoros\createUploadedFile(), et null.

Référencé par ServerRequestFactory\fromGlobals().

◆ parseCookieHeader()

Laminas\Diactoros\parseCookieHeader (   $cookieHeader)

Parse a cookie header according to RFC 6265.

PHP will replace special characters in cookie names, which results in other cookies not being available due to overwriting. Thus, the server request should take the cookies from the request header instead.

Paramètres
string$cookieHeaderA string cookie header value.
Renvoie
array key/value cookie pairs.

Référencé par ServerRequestFactory\fromGlobals().

◆ setHeaders()

Laminas\Diactoros\setHeaders ( array  $originalHeaders)
private

Filter a set of headers to ensure they are in the correct internal format.

Used by message constructors to allow setting all initial headers at once.

Paramètres
array$originalHeadersHeaders to filter.

Références $header, Laminas\Diactoros\$headerNames, $value, Laminas\Diactoros\assertHeader(), et Laminas\Diactoros\filterHeaderValue().

Référencé par Response\__construct(), Laminas\Diactoros\initialize(), et SerializerErrorRenderer\render().

◆ setMethod()

Laminas\Diactoros\setMethod (   $method)
private

Set and validate the HTTP method

Paramètres
string$method
Exceptions
Exception

Références Laminas\Diactoros\$method, et method.

Référencé par Laminas\Diactoros\initialize().

◆ validateProtocolVersion()

Laminas\Diactoros\validateProtocolVersion (   $version)
private

Validate the HTTP protocol version

Paramètres
string$version
Exceptions
Exception

Références $version.

Référencé par Laminas\Diactoros\withProtocolVersion().

◆ withAddedHeader()

Laminas\Diactoros\withAddedHeader (   $header,
  $value 
)

Return an instance with the specified header appended with the given value.

Existing values for the specified header will be maintained. The new value(s) will be appended to the existing list. If the header did not exist previously, it will be added.

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 new header and/or value.

Paramètres
string$headerCase-insensitive header field name to add.
string|string[]$value Header value(s).
Renvoie
static
Exceptions
Exception

Références $header, $this, $value, Laminas\Diactoros\assertHeader(), Laminas\Diactoros\filterHeaderValue(), Laminas\Diactoros\hasHeader(), et Laminas\Diactoros\withHeader().

◆ withBody()

Laminas\Diactoros\withBody ( StreamInterface  $body)

Return an instance with the specified message body.

The body MUST be a StreamInterface object.

This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return a new instance that has the new body stream.

Paramètres
StreamInterface$bodyBody.
Renvoie
static
Exceptions
Exception

Références $this.

Référencé par AbstractWebApplication\appendBody(), AbstractWebApplication\prependBody(), et AbstractWebApplication\setBody().

◆ withHeader()

Laminas\Diactoros\withHeader (   $header,
  $value 
)

Return an instance with the provided header, replacing any existing values of any headers with the same case-insensitive name.

While header names are case-insensitive, the casing of the header will be preserved by this function, and returned from getHeaders().

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 new and/or updated header and value.

Paramètres
string$headerCase-insensitive header field name.
string|string[]$value Header value(s).
Renvoie
static
Exceptions
Exception

Références $header, $this, $value, Laminas\Diactoros\assertHeader(), et Laminas\Diactoros\filterHeaderValue().

Référencé par Laminas\Diactoros\withAddedHeader().

◆ withMethod()

Laminas\Diactoros\withMethod (   $method)

Return an instance with the provided HTTP method.

While HTTP method names are typically all uppercase characters, HTTP method names are case-sensitive and thus implementations SHOULD NOT modify the given string.

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 changed request method.

Paramètres
string$methodCase-insensitive method.
Exceptions
Exception

Références Laminas\Diactoros\$method, et $this.

◆ withoutHeader()

Laminas\Diactoros\withoutHeader (   $header)

Return an instance without the specified header.

Header resolution MUST be done without case-sensitivity.

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 named header.

Paramètres
string$headerCase-insensitive header field name to remove.
Renvoie
static

Références $header, $this, et Laminas\Diactoros\hasHeader().

◆ withProtocolVersion()

Laminas\Diactoros\withProtocolVersion (   $version)

Return an instance with the specified HTTP protocol version.

The version string MUST contain only the HTTP version number (e.g., "1.1", "1.0").

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 new protocol version.

Paramètres
string$versionHTTP protocol version
Renvoie
static

Références $this, $version, et Laminas\Diactoros\validateProtocolVersion().

◆ withRequestTarget()

Laminas\Diactoros\withRequestTarget (   $requestTarget)

Create a new instance with a specific request-target.

If the request needs a non-origin-form request-target — e.g., for specifying an absolute-form, authority-form, or asterisk-form — this method may be used to create an instance with the specified request-target, verbatim.

This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return a new instance that has the changed request target.

(for the various request-target forms allowed in request messages) string $requestTarget Exception if the request target is invalid.

Références Laminas\Diactoros\$requestTarget, et $this.

◆ withUri()

Laminas\Diactoros\withUri ( UriInterface  $uri,
  $preserveHost = false 
)

Returns an instance with the provided URI.

This method will update the Host header of the returned request by default if the URI contains a host component. If the URI does not contain a host component, any pre-existing Host header will be carried over to the returned request.

You can opt-in to preserving the original state of the Host header by setting $preserveHost to true. When $preserveHost is set to true, the returned request will not update the Host header of the returned message – even if the message contains no Host header. This means that a call to ‘getHeader('Host’)on the original request MUST equal the return value of a call togetHeader('Host')` on the returned request.

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 new UriInterface instance.

UriInterface $uri New request URI to use. bool $preserveHost Preserve the original state of the Host header.

Références $header, $this, Laminas\Diactoros\$uri, et Laminas\Diactoros\hasHeader().

Documentation des variables

◆ $headerNames

$headerNames = []
protected

Référencé par Laminas\Diactoros\setHeaders().

◆ $method

◆ $protocol

◆ $requestTarget

◆ $stream

◆ $uri

◆ MessageTrait

trait MessageTrait
Valeur initiale :
{
protected $headers = []

Trait implementing the various methods defined in MessageInterface.

Voir également
https://github.com/php-fig/http-message/tree/master/src/MessageInterface.php

◆ RequestTrait

trait RequestTrait
Valeur initiale :

Trait with common request behaviors.

Server and client-side requests differ slightly in how the Host header is handled; on client-side, it should be calculated on-the-fly from the composed URI (if present), while on server-side, it will be calculated from the environment. As such, this trait exists to provide the common code between both client-side and server-side requests, and each can then use the headers functionality required by their implementations.