[HttpFoundation] fix FileBag under PHP 8.1
This commit is contained in:
parent
e5c96c4051
commit
dc3504989b
|
@ -113,6 +113,8 @@ class FileBag extends ParameterBag
|
|||
*/
|
||||
protected function fixPhpFilesArray($data)
|
||||
{
|
||||
// Remove extra key added by PHP 8.1.
|
||||
unset($data['full_path']);
|
||||
$keys = array_keys($data);
|
||||
sort($keys);
|
||||
|
||||
|
|
|
@ -45,6 +45,23 @@ class FileBagTest extends TestCase
|
|||
$this->assertEquals($file, $bag->get('file'));
|
||||
}
|
||||
|
||||
public function testShouldConvertsUploadedFilesPhp81()
|
||||
{
|
||||
$tmpFile = $this->createTempFile();
|
||||
$file = new UploadedFile($tmpFile, basename($tmpFile), 'text/plain');
|
||||
|
||||
$bag = new FileBag(['file' => [
|
||||
'name' => basename($tmpFile),
|
||||
'full_path' => basename($tmpFile),
|
||||
'type' => 'text/plain',
|
||||
'tmp_name' => $tmpFile,
|
||||
'error' => 0,
|
||||
'size' => null,
|
||||
]]);
|
||||
|
||||
$this->assertEquals($file, $bag->get('file'));
|
||||
}
|
||||
|
||||
public function testShouldSetEmptyUploadedFilesToNull()
|
||||
{
|
||||
$bag = new FileBag(['file' => [
|
||||
|
|
Reference in New Issue