Updates to vendors etc

This commit is contained in:
Chris Hunt
2025-07-11 15:57:48 +01:00
parent d972cbcd0a
commit 8fb6438254
8043 changed files with 248005 additions and 189479 deletions

View File

@@ -21,7 +21,7 @@ use Symfony\Component\HttpFoundation\File\UploadedFile;
*/
class FileBag extends ParameterBag
{
private const FILE_KEYS = ['error', 'name', 'size', 'tmp_name', 'type'];
private const FILE_KEYS = ['error', 'full_path', 'name', 'size', 'tmp_name', 'type'];
/**
* @param array|UploadedFile[] $parameters An array of HTTP files
@@ -31,19 +31,13 @@ class FileBag extends ParameterBag
$this->replace($parameters);
}
/**
* @return void
*/
public function replace(array $files = [])
public function replace(array $files = []): void
{
$this->parameters = [];
$this->add($files);
}
/**
* @return void
*/
public function set(string $key, mixed $value)
public function set(string $key, mixed $value): void
{
if (!\is_array($value) && !$value instanceof UploadedFile) {
throw new \InvalidArgumentException('An uploaded file must be an array or an instance of UploadedFile.');
@@ -52,10 +46,7 @@ class FileBag extends ParameterBag
parent::set($key, $this->convertFileInformation($value));
}
/**
* @return void
*/
public function add(array $files = [])
public function add(array $files = []): void
{
foreach ($files as $key => $file) {
$this->set($key, $file);
@@ -74,18 +65,18 @@ class FileBag extends ParameterBag
}
$file = $this->fixPhpFilesArray($file);
$keys = array_keys($file);
$keys = array_keys($file + ['full_path' => null]);
sort($keys);
if (self::FILE_KEYS == $keys) {
if (\UPLOAD_ERR_NO_FILE == $file['error']) {
if (self::FILE_KEYS === $keys) {
if (\UPLOAD_ERR_NO_FILE === $file['error']) {
$file = null;
} else {
$file = new UploadedFile($file['tmp_name'], $file['name'], $file['type'], $file['error'], false);
$file = new UploadedFile($file['tmp_name'], $file['full_path'] ?? $file['name'], $file['type'], $file['error'], false);
}
} else {
$file = array_map(fn ($v) => $v instanceof UploadedFile || \is_array($v) ? $this->convertFileInformation($v) : $v, $file);
if (array_keys($keys) === $keys) {
if (array_is_list($file)) {
$file = array_filter($file);
}
}
@@ -107,12 +98,10 @@ class FileBag extends ParameterBag
*/
protected function fixPhpFilesArray(array $data): array
{
// Remove extra key added by PHP 8.1.
unset($data['full_path']);
$keys = array_keys($data);
$keys = array_keys($data + ['full_path' => null]);
sort($keys);
if (self::FILE_KEYS != $keys || !isset($data['name']) || !\is_array($data['name'])) {
if (self::FILE_KEYS !== $keys || !isset($data['name']) || !\is_array($data['name'])) {
return $data;
}
@@ -128,7 +117,9 @@ class FileBag extends ParameterBag
'type' => $data['type'][$key],
'tmp_name' => $data['tmp_name'][$key],
'size' => $data['size'][$key],
]);
] + (isset($data['full_path'][$key]) ? [
'full_path' => $data['full_path'][$key],
] : []));
}
return $files;