Symfony\Component\HttpFoundation\Response::__construct PHP Method

__construct() public method

Constructor.
public __construct ( mixed $content = '', integer $status = 200, array $headers = [] )
$content mixed The response content, see setContent()
$status integer The response status code
$headers array An array of response headers
    public function __construct($content = '', $status = 200, $headers = array())
    {
        $this->headers = new ResponseHeaderBag($headers);
        $this->setContent($content);
        $this->setStatusCode($status);
        $this->setProtocolVersion('1.0');

        // Deprecations
        $class = get_class($this);
        if ($this instanceof \PHPUnit_Framework_MockObject_MockObject || $this instanceof \Prophecy\Doubler\DoubleInterface) {
            $class = get_parent_class($class);
        }
        if (isset(self::$deprecationsTriggered[$class])) {
            return;
        }

        self::$deprecationsTriggered[$class] = true;
        foreach (self::$deprecatedMethods as $method) {
            $r = new \ReflectionMethod($class, $method);
            if (__CLASS__ !== $r->getDeclaringClass()->getName()) {
                @trigger_error(sprintf('Extending %s::%s() in %s is deprecated since version 3.2 and won\'t be supported anymore in 4.0 as it will be final.', __CLASS__, $method, $class), E_USER_DEPRECATED);
            }
        }
    }

Usage Example

 /**
  * Constructor.
  *
  * @param mixed   $data    The response data
  * @param int     $status  The response status code
  * @param array   $headers An array of response headers
  */
 public function __construct(array $responses = array(), $status = 200, $headers = array())
 {
     parent::__construct('', $status, $headers);
     foreach ($responses as $response) {
         $this->addResponse($response);
     }
 }
All Usage Examples Of Symfony\Component\HttpFoundation\Response::__construct