Augmentation vers version 3.3.0

This commit is contained in:
Gauvain Boiché
2020-03-31 15:31:03 +02:00
parent d926806907
commit a1864c0414
2618 changed files with 406015 additions and 31377 deletions

View File

@@ -21,12 +21,12 @@ use Symfony\Component\HttpFoundation\File\UploadedFile;
*/
class FileBag extends ParameterBag
{
private static $fileKeys = array('error', 'name', 'size', 'tmp_name', 'type');
private static $fileKeys = ['error', 'name', 'size', 'tmp_name', 'type'];
/**
* @param array $parameters An array of HTTP files
*/
public function __construct(array $parameters = array())
public function __construct(array $parameters = [])
{
$this->replace($parameters);
}
@@ -34,9 +34,9 @@ class FileBag extends ParameterBag
/**
* {@inheritdoc}
*/
public function replace(array $files = array())
public function replace(array $files = [])
{
$this->parameters = array();
$this->parameters = [];
$this->add($files);
}
@@ -55,7 +55,7 @@ class FileBag extends ParameterBag
/**
* {@inheritdoc}
*/
public function add(array $files = array())
public function add(array $files = [])
{
foreach ($files as $key => $file) {
$this->set($key, $file);
@@ -75,8 +75,8 @@ class FileBag extends ParameterBag
return $file;
}
$file = $this->fixPhpFilesArray($file);
if (\is_array($file)) {
$file = $this->fixPhpFilesArray($file);
$keys = array_keys($file);
sort($keys);
@@ -87,7 +87,7 @@ class FileBag extends ParameterBag
$file = new UploadedFile($file['tmp_name'], $file['name'], $file['type'], $file['size'], $file['error']);
}
} else {
$file = array_map(array($this, 'convertFileInformation'), $file);
$file = array_map([$this, 'convertFileInformation'], $file);
if (array_keys($keys) === $keys) {
$file = array_filter($file);
}
@@ -109,14 +109,12 @@ class FileBag extends ParameterBag
* It's safe to pass an already converted array, in which case this method
* just returns the original array unmodified.
*
* @param array $data
*
* @return array
*/
protected function fixPhpFilesArray($data)
{
if (!\is_array($data)) {
return $data;
}
$keys = array_keys($data);
sort($keys);
@@ -130,13 +128,13 @@ class FileBag extends ParameterBag
}
foreach ($data['name'] as $key => $name) {
$files[$key] = $this->fixPhpFilesArray(array(
$files[$key] = $this->fixPhpFilesArray([
'error' => $data['error'][$key],
'name' => $name,
'type' => $data['type'][$key],
'tmp_name' => $data['tmp_name'][$key],
'size' => $data['size'][$key],
));
]);
}
return $files;