package and depencies
This commit is contained in:
@@ -28,8 +28,11 @@ class StreamedResponse extends Response
|
||||
{
|
||||
protected $callback;
|
||||
protected $streamed;
|
||||
private $headersSent;
|
||||
private bool $headersSent;
|
||||
|
||||
/**
|
||||
* @param int $status The HTTP status code (200 "OK" by default)
|
||||
*/
|
||||
public function __construct(callable $callback = null, int $status = 200, array $headers = [])
|
||||
{
|
||||
parent::__construct(null, $status, $headers);
|
||||
@@ -41,28 +44,12 @@ class StreamedResponse extends Response
|
||||
$this->headersSent = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory method for chainability.
|
||||
*
|
||||
* @param callable|null $callback A valid PHP callback or null to set it later
|
||||
*
|
||||
* @return static
|
||||
*
|
||||
* @deprecated since Symfony 5.1, use __construct() instead.
|
||||
*/
|
||||
public static function create($callback = null, int $status = 200, array $headers = [])
|
||||
{
|
||||
trigger_deprecation('symfony/http-foundation', '5.1', 'The "%s()" method is deprecated, use "new %s()" instead.', __METHOD__, static::class);
|
||||
|
||||
return new static($callback, $status, $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the PHP callback associated with this Response.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCallback(callable $callback)
|
||||
public function setCallback(callable $callback): static
|
||||
{
|
||||
$this->callback = $callback;
|
||||
|
||||
@@ -70,13 +57,11 @@ class StreamedResponse extends Response
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* This method only sends the headers once.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function sendHeaders()
|
||||
public function sendHeaders(): static
|
||||
{
|
||||
if ($this->headersSent) {
|
||||
return $this;
|
||||
@@ -88,13 +73,11 @@ class StreamedResponse extends Response
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* This method only sends the content once.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function sendContent()
|
||||
public function sendContent(): static
|
||||
{
|
||||
if ($this->streamed) {
|
||||
return $this;
|
||||
@@ -112,13 +95,11 @@ class StreamedResponse extends Response
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* @return $this
|
||||
*
|
||||
* @throws \LogicException when the content is not null
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setContent(?string $content)
|
||||
public function setContent(?string $content): static
|
||||
{
|
||||
if (null !== $content) {
|
||||
throw new \LogicException('The content cannot be set on a StreamedResponse instance.');
|
||||
@@ -129,10 +110,7 @@ class StreamedResponse extends Response
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getContent()
|
||||
public function getContent(): string|false
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user