fix:更新已知bug,优化代码

This commit is contained in:
Ying
2022-11-28 19:11:12 +08:00
parent f6aee95cfc
commit 9445b206a2
1378 changed files with 53759 additions and 20789 deletions

View File

@@ -28,7 +28,7 @@ class StreamedResponse extends Response
{
protected $callback;
protected $streamed;
private $headersSent;
private bool $headersSent;
public function __construct(callable $callback = null, int $status = 200, array $headers = [])
{
@@ -41,28 +41,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;
@@ -76,7 +60,7 @@ class StreamedResponse extends Response
*
* @return $this
*/
public function sendHeaders()
public function sendHeaders(): static
{
if ($this->headersSent) {
return $this;
@@ -94,7 +78,7 @@ class StreamedResponse extends Response
*
* @return $this
*/
public function sendContent()
public function sendContent(): static
{
if ($this->streamed) {
return $this;
@@ -118,7 +102,7 @@ class StreamedResponse extends Response
*
* @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.');
@@ -132,7 +116,7 @@ class StreamedResponse extends Response
/**
* {@inheritdoc}
*/
public function getContent()
public function getContent(): string|false
{
return false;
}