8000 [HttpFoundation] fix FileBag under PHP 8.1 · symfony/http-foundation@17a1c3d · GitHub
[go: up one dir, main page]

Skip to content

Commit 17a1c3d

Browse files
alexpottderrabus
authored andcommitted
[HttpFoundation] fix FileBag under PHP 8.1
1 parent 48f7bed commit 17a1c3d

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

FileBag.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ protected function convertFileInformation($file)
113113
*/
114114
protected function fixPhpFilesArray($data)
115115
{
116+
// Remove extra key added by PHP 8.1.
117+
unset($data['full_path']);
116118
$keys = array_keys($data);
117119
sort($keys);
118120

Tests/FileBagTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,23 @@ public function testShouldConvertsUploadedFiles()
4545
$this->assertEquals($file, $bag->get('file'));
4646
}
4747

48+
public function testShouldConvertsUploadedFilesPhp81()
49+
{
50+
$tmpFile = $this->createTempFile();
51+
$file = new UploadedFile($tmpFile, basename($tmpFile), 'text/plain');
52+
53+
$bag = new FileBag(['file' => [
54+
'name' => basename($tmpFile),
55+
'full_path' => basename($tmpFile),
56+
'type' => 'text/plain',
57+
'tmp_name' => $tmpFile,
58+
'error' => 0,
59+
'size' => null,
60+
]]);
61+
62+
$this->assertEquals($file, $bag->get('file'));
63+
}
64+
4865
public function testShouldSetEmptyUploadedFilesToNull()
4966
{
5067
$bag = new FileBag(['file' => [

0 commit comments

Comments
 (0)
0