mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-05 19:42:38 +02:00
Update composer
This commit is contained in:
parent
330cdbe615
commit
0c83c9a678
442 changed files with 9523 additions and 10793 deletions
|
@ -38,14 +38,14 @@ class BinaryFileResponse extends Response
|
|||
|
||||
/**
|
||||
* @param \SplFileInfo|string $file The file to stream
|
||||
* @param int $status The response status code (200 "OK" by default)
|
||||
* @param int $status The response status code
|
||||
* @param array $headers An array of response headers
|
||||
* @param bool $public Files are public by default
|
||||
* @param string|null $contentDisposition The type of Content-Disposition to set automatically with the filename
|
||||
* @param bool $autoEtag Whether the ETag header should be automatically set
|
||||
* @param bool $autoLastModified Whether the Last-Modified header should be automatically set
|
||||
*/
|
||||
public function __construct(\SplFileInfo|string $file, int $status = 200, array $headers = [], bool $public = true, ?string $contentDisposition = null, bool $autoEtag = false, bool $autoLastModified = true)
|
||||
public function __construct($file, int $status = 200, array $headers = [], bool $public = true, ?string $contentDisposition = null, bool $autoEtag = false, bool $autoLastModified = true)
|
||||
{
|
||||
parent::__construct(null, $status, $headers);
|
||||
|
||||
|
@ -56,14 +56,36 @@ class BinaryFileResponse extends Response
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \SplFileInfo|string $file The file to stream
|
||||
* @param int $status The response status code
|
||||
* @param array $headers An array of response headers
|
||||
* @param bool $public Files are public by default
|
||||
* @param string|null $contentDisposition The type of Content-Disposition to set automatically with the filename
|
||||
* @param bool $autoEtag Whether the ETag header should be automatically set
|
||||
* @param bool $autoLastModified Whether the Last-Modified header should be automatically set
|
||||
*
|
||||
* @return static
|
||||
*
|
||||
* @deprecated since Symfony 5.2, use __construct() instead.
|
||||
*/
|
||||
public static function create($file = null, int $status = 200, array $headers = [], bool $public = true, ?string $contentDisposition = null, bool $autoEtag = false, bool $autoLastModified = true)
|
||||
{
|
||||
trigger_deprecation('symfony/http-foundation', '5.2', 'The "%s()" method is deprecated, use "new %s()" instead.', __METHOD__, static::class);
|
||||
|
||||
return new static($file, $status, $headers, $public, $contentDisposition, $autoEtag, $autoLastModified);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the file to stream.
|
||||
*
|
||||
* @param \SplFileInfo|string $file The file to stream
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @throws FileException
|
||||
*/
|
||||
public function setFile(\SplFileInfo|string $file, ?string $contentDisposition = null, bool $autoEtag = false, bool $autoLastModified = true): static
|
||||
public function setFile($file, ?string $contentDisposition = null, bool $autoEtag = false, bool $autoLastModified = true)
|
||||
{
|
||||
if (!$file instanceof File) {
|
||||
if ($file instanceof \SplFileInfo) {
|
||||
|
@ -96,8 +118,10 @@ class BinaryFileResponse extends Response
|
|||
|
||||
/**
|
||||
* Gets the file.
|
||||
*
|
||||
* @return File
|
||||
*/
|
||||
public function getFile(): File
|
||||
public function getFile()
|
||||
{
|
||||
return $this->file;
|
||||
}
|
||||
|
@ -107,7 +131,7 @@ class BinaryFileResponse extends Response
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setChunkSize(int $chunkSize): static
|
||||
public function setChunkSize(int $chunkSize): self
|
||||
{
|
||||
if ($chunkSize < 1 || $chunkSize > \PHP_INT_MAX) {
|
||||
throw new \LogicException('The chunk size of a BinaryFileResponse cannot be less than 1 or greater than PHP_INT_MAX.');
|
||||
|
@ -123,9 +147,9 @@ class BinaryFileResponse extends Response
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setAutoLastModified(): static
|
||||
public function setAutoLastModified()
|
||||
{
|
||||
$this->setLastModified(\DateTimeImmutable::createFromFormat('U', $this->file->getMTime()));
|
||||
$this->setLastModified(\DateTime::createFromFormat('U', $this->file->getMTime()));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@ -135,7 +159,7 @@ class BinaryFileResponse extends Response
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setAutoEtag(): static
|
||||
public function setAutoEtag()
|
||||
{
|
||||
$this->setEtag(base64_encode(hash_file('sha256', $this->file->getPathname(), true)));
|
||||
|
||||
|
@ -151,7 +175,7 @@ class BinaryFileResponse extends Response
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setContentDisposition(string $disposition, string $filename = '', string $filenameFallback = ''): static
|
||||
public function setContentDisposition(string $disposition, string $filename = '', string $filenameFallback = '')
|
||||
{
|
||||
if ('' === $filename) {
|
||||
$filename = $this->file->getFilename();
|
||||
|
@ -177,7 +201,10 @@ class BinaryFileResponse extends Response
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function prepare(Request $request): static
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepare(Request $request)
|
||||
{
|
||||
if ($this->isInformational() || $this->isEmpty()) {
|
||||
parent::prepare($request);
|
||||
|
@ -221,7 +248,7 @@ class BinaryFileResponse extends Response
|
|||
$parts = HeaderUtils::split($request->headers->get('X-Accel-Mapping', ''), ',=');
|
||||
foreach ($parts as $part) {
|
||||
[$pathPrefix, $location] = $part;
|
||||
if (str_starts_with($path, $pathPrefix)) {
|
||||
if (substr($path, 0, \strlen($pathPrefix)) === $pathPrefix) {
|
||||
$path = $location.substr($path, \strlen($pathPrefix));
|
||||
// Only set X-Accel-Redirect header if a valid URI can be produced
|
||||
// as nginx does not serve arbitrary file paths.
|
||||
|
@ -289,11 +316,14 @@ class BinaryFileResponse extends Response
|
|||
return $lastModified->format('D, d M Y H:i:s').' GMT' === $header;
|
||||
}
|
||||
|
||||
public function sendContent(): static
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function sendContent()
|
||||
{
|
||||
try {
|
||||
if (!$this->isSuccessful()) {
|
||||
return $this;
|
||||
return parent::sendContent();
|
||||
}
|
||||
|
||||
if (0 === $this->maxlen) {
|
||||
|
@ -340,9 +370,11 @@ class BinaryFileResponse extends Response
|
|||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @throws \LogicException when the content is not null
|
||||
*/
|
||||
public function setContent(?string $content): static
|
||||
public function setContent(?string $content)
|
||||
{
|
||||
if (null !== $content) {
|
||||
throw new \LogicException('The content cannot be set on a BinaryFileResponse instance.');
|
||||
|
@ -351,15 +383,16 @@ class BinaryFileResponse extends Response
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function getContent(): string|false
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getContent()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Trust X-Sendfile-Type header.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function trustXSendfileTypeHeader()
|
||||
{
|
||||
|
@ -372,7 +405,7 @@ class BinaryFileResponse extends Response
|
|||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function deleteFileAfterSend(bool $shouldDelete = true): static
|
||||
public function deleteFileAfterSend(bool $shouldDelete = true)
|
||||
{
|
||||
$this->deleteFileAfterSend = $shouldDelete;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue