Laravel 5.6 updates
Travis config update Removed HHVM script as Laravel no longer support HHVM after releasing 5.3
This commit is contained in:
@@ -11,8 +11,15 @@
|
||||
|
||||
namespace Symfony\Component\HttpFoundation\File;
|
||||
|
||||
use Symfony\Component\HttpFoundation\File\Exception\CannotWriteFileException;
|
||||
use Symfony\Component\HttpFoundation\File\Exception\ExtensionFileException;
|
||||
use Symfony\Component\HttpFoundation\File\Exception\FileException;
|
||||
use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException;
|
||||
use Symfony\Component\HttpFoundation\File\Exception\FormSizeFileException;
|
||||
use Symfony\Component\HttpFoundation\File\Exception\IniSizeFileException;
|
||||
use Symfony\Component\HttpFoundation\File\Exception\NoFileException;
|
||||
use Symfony\Component\HttpFoundation\File\Exception\NoTmpDirFileException;
|
||||
use Symfony\Component\HttpFoundation\File\Exception\PartialFileException;
|
||||
use Symfony\Component\HttpFoundation\File\MimeType\ExtensionGuesser;
|
||||
|
||||
/**
|
||||
@@ -27,7 +34,6 @@ class UploadedFile extends File
|
||||
private $test = false;
|
||||
private $originalName;
|
||||
private $mimeType;
|
||||
private $size;
|
||||
private $error;
|
||||
|
||||
/**
|
||||
@@ -47,7 +53,6 @@ class UploadedFile extends File
|
||||
* @param string $path The full temporary path to the file
|
||||
* @param string $originalName The original file name of the uploaded file
|
||||
* @param string|null $mimeType The type of the file as provided by PHP; null defaults to application/octet-stream
|
||||
* @param int|null $size The file size provided by the uploader
|
||||
* @param int|null $error The error constant of the upload (one of PHP's UPLOAD_ERR_XXX constants); null defaults to UPLOAD_ERR_OK
|
||||
* @param bool $test Whether the test mode is active
|
||||
* Local files are used in test mode hence the code should not enforce HTTP uploads
|
||||
@@ -55,13 +60,19 @@ class UploadedFile extends File
|
||||
* @throws FileException If file_uploads is disabled
|
||||
* @throws FileNotFoundException If the file does not exist
|
||||
*/
|
||||
public function __construct($path, $originalName, $mimeType = null, $size = null, $error = null, $test = false)
|
||||
public function __construct(string $path, string $originalName, string $mimeType = null, int $error = null, $test = false)
|
||||
{
|
||||
$this->originalName = $this->getName($originalName);
|
||||
$this->mimeType = $mimeType ?: 'application/octet-stream';
|
||||
$this->size = $size;
|
||||
|
||||
if (4 < \func_num_args() ? !\is_bool($test) : null !== $error && @filesize($path) === $error) {
|
||||
@trigger_error(sprintf('Passing a size as 4th argument to the constructor of "%s" is deprecated since Symfony 4.1.', __CLASS__), E_USER_DEPRECATED);
|
||||
$error = $test;
|
||||
$test = 5 < \func_num_args() ? func_get_arg(5) : false;
|
||||
}
|
||||
|
||||
$this->error = $error ?: UPLOAD_ERR_OK;
|
||||
$this->test = (bool) $test;
|
||||
$this->test = $test;
|
||||
|
||||
parent::__construct($path, UPLOAD_ERR_OK === $this->error);
|
||||
}
|
||||
@@ -141,11 +152,15 @@ class UploadedFile extends File
|
||||
* It is extracted from the request from which the file has been uploaded.
|
||||
* Then it should not be considered as a safe value.
|
||||
*
|
||||
* @return int|null The file size
|
||||
* @deprecated since Symfony 4.1, use getSize() instead.
|
||||
*
|
||||
* @return int|null The file sizes
|
||||
*/
|
||||
public function getClientSize()
|
||||
{
|
||||
return $this->size;
|
||||
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1. Use getSize() instead.', __METHOD__), E_USER_DEPRECATED);
|
||||
|
||||
return $this->getSize();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -204,6 +219,23 @@ class UploadedFile extends File
|
||||
return $target;
|
||||
}
|
||||
|
||||
switch ($this->error) {
|
||||
case UPLOAD_ERR_INI_SIZE:
|
||||
throw new IniSizeFileException($this->getErrorMessage());
|
||||
case UPLOAD_ERR_FORM_SIZE:
|
||||
throw new FormSizeFileException($this->getErrorMessage());
|
||||
case UPLOAD_ERR_PARTIAL:
|
||||
throw new PartialFileException($this->getErrorMessage());
|
||||
case UPLOAD_ERR_NO_FILE:
|
||||
throw new NoFileException($this->getErrorMessage());
|
||||
case UPLOAD_ERR_CANT_WRITE:
|
||||
throw new CannotWriteFileException($this->getErrorMessage());
|
||||
case UPLOAD_ERR_NO_TMP_DIR:
|
||||
throw new NoTmpDirFileException($this->getErrorMessage());
|
||||
case UPLOAD_ERR_EXTENSION:
|
||||
throw new ExtensionFileException($this->getErrorMessage());
|
||||
}
|
||||
|
||||
throw new FileException($this->getErrorMessage());
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user