You are here

public function Response::__construct in Zircon Profile 8

Same name in this branch
  1. 8 vendor/symfony/http-foundation/Response.php \Symfony\Component\HttpFoundation\Response::__construct()
  2. 8 vendor/symfony/browser-kit/Response.php \Symfony\Component\BrowserKit\Response::__construct()
  3. 8 vendor/zendframework/zend-diactoros/src/Response.php \Zend\Diactoros\Response::__construct()
  4. 8 vendor/guzzlehttp/psr7/src/Response.php \GuzzleHttp\Psr7\Response::__construct()
  5. 8 vendor/jcalderonzumba/gastonjs/src/NetworkTraffic/Response.php \Zumba\GastonJS\NetworkTraffic\Response::__construct()
  6. 8 vendor/symfony/psr-http-message-bridge/Tests/Fixtures/Response.php \Symfony\Bridge\PsrHttpMessage\Tests\Fixtures\Response::__construct()
Same name and namespace in other branches
  1. 8.0 vendor/zendframework/zend-diactoros/src/Response.php \Zend\Diactoros\Response::__construct()

Parameters

string|resource|StreamInterface $stream Stream identifier and/or actual stream resource:

int $status Status code for the response, if any.:

array $headers Headers for the response, if any.:

Throws

InvalidArgumentException on any invalid element.

4 calls to Response::__construct()
EmptyResponse::__construct in vendor/zendframework/zend-diactoros/src/Response/EmptyResponse.php
Create an empty response with the given status code.
HtmlResponse::__construct in vendor/zendframework/zend-diactoros/src/Response/HtmlResponse.php
Create an HTML response.
JsonResponse::__construct in vendor/zendframework/zend-diactoros/src/Response/JsonResponse.php
Create a JSON response with the given data.
RedirectResponse::__construct in vendor/zendframework/zend-diactoros/src/Response/RedirectResponse.php
Create a redirect response.
4 methods override Response::__construct()
EmptyResponse::__construct in vendor/zendframework/zend-diactoros/src/Response/EmptyResponse.php
Create an empty response with the given status code.
HtmlResponse::__construct in vendor/zendframework/zend-diactoros/src/Response/HtmlResponse.php
Create an HTML response.
JsonResponse::__construct in vendor/zendframework/zend-diactoros/src/Response/JsonResponse.php
Create a JSON response with the given data.
RedirectResponse::__construct in vendor/zendframework/zend-diactoros/src/Response/RedirectResponse.php
Create a redirect response.

File

vendor/zendframework/zend-diactoros/src/Response.php, line 113

Class

Response
HTTP response encapsulation.

Namespace

Zend\Diactoros

Code

public function __construct($body = 'php://memory', $status = 200, array $headers = []) {
  if (!is_string($body) && !is_resource($body) && !$body instanceof StreamInterface) {
    throw new InvalidArgumentException('Stream must be a string stream resource identifier, ' . 'an actual stream resource, ' . 'or a Psr\\Http\\Message\\StreamInterface implementation');
  }
  if (null !== $status) {
    $this
      ->validateStatus($status);
  }
  $this->stream = $body instanceof StreamInterface ? $body : new Stream($body, 'wb+');
  $this->statusCode = $status ? (int) $status : 200;
  list($this->headerNames, $headers) = $this
    ->filterHeaders($headers);
  $this
    ->assertHeaders($headers);
  $this->headers = $headers;
}