Zend\Diactoros\ServerRequest::__construct PHP Méthode

__construct() public méthode

public __construct ( array $serverParams = [], array $uploadedFiles = [], null | string | Psr\Http\Message\UriInterface $uri = null, null | string $method = null, string | resource | Psr\Http\Message\StreamInterface $body = 'php://input', array $headers = [], array $cookies = [], array $queryParams = [], null | array | object $parsedBody = null, string $protocol = '1.1' )
$serverParams array Server parameters, typically from $_SERVER
$uploadedFiles array Upload file information, a tree of UploadedFiles
$uri null | string | Psr\Http\Message\UriInterface URI for the request, if any.
$method null | string HTTP method for the request, if any.
$body string | resource | Psr\Http\Message\StreamInterface Message body, if any.
$headers array Headers for the message, if any.
$cookies array Cookies for the message, if any.
$queryParams array Query params for the message, if any.
$parsedBody null | array | object The deserialized body parameters, if any.
$protocol string HTTP protocol version.
    public function __construct(array $serverParams = [], array $uploadedFiles = [], $uri = null, $method = null, $body = 'php://input', array $headers = [], array $cookies = [], array $queryParams = [], $parsedBody = null, $protocol = '1.1')
    {
        $this->validateUploadedFiles($uploadedFiles);
        if ($body === 'php://input') {
            $body = new PhpInputStream();
        }
        $this->initialize($uri, $method, $body, $headers);
        $this->serverParams = $serverParams;
        $this->uploadedFiles = $uploadedFiles;
        $this->cookieParams = $cookies;
        $this->queryParams = $queryParams;
        $this->parsedBody = $parsedBody;
        $this->protocol = $protocol;
    }

Usage Example

Exemple #1
0
 /**
  * @param CookieJar $jar
  * @param array     $serverParams
  * @param array     $uploadedFiles
  * @param null      $uri
  * @param null      $method
  * @param string    $body
  * @param array     $headers
  */
 public function __construct(CookieJar $jar = null, array $serverParams = [], array $uploadedFiles = [], $uri = null, $method = null, $body = 'php://input', array $headers = [])
 {
     parent::__construct($serverParams, $uploadedFiles, $uri, $method, $body, $headers);
     $this->cookieJar = $jar ?: new CookieJar();
 }