Skip to content

Commit

Permalink
Prevent possible warnings on unset variables (#542)
Browse files Browse the repository at this point in the history
Co-authored-by: Roy <rdmartines@vcn.nl>
  • Loading branch information
sudo-plz and Roy committed Apr 8, 2023
1 parent 54cff69 commit bfe7c39
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/ServerRequest.php
Expand Up @@ -144,10 +144,10 @@ private static function normalizeNestedFileSpec(array $files = []): array
foreach (array_keys($files['tmp_name']) as $key) {
$spec = [
'tmp_name' => $files['tmp_name'][$key],
'size' => $files['size'][$key],
'error' => $files['error'][$key],
'name' => $files['name'][$key],
'type' => $files['type'][$key],
'size' => $files['size'][$key] ?? null,
'error' => $files['error'][$key] ?? null,
'name' => $files['name'][$key] ?? null,
'type' => $files['type'][$key] ?? null,
];
$normalizedFiles[$key] = self::createUploadedFileFromSpec($spec);
}
Expand Down
18 changes: 18 additions & 0 deletions tests/ServerRequestTest.php
Expand Up @@ -163,6 +163,7 @@ public function dataNormalizeFiles(): iterable
'tmp_name' => [
0 => '/tmp/php/hp9hskjhf',
1 => '/tmp/php/php1h4j1o',
2 => '/tmp/php/w0ensl4ar',
],
'error' => [
0 => '0',
Expand All @@ -173,6 +174,11 @@ public function dataNormalizeFiles(): iterable
1 => '7349',
],
],
'minimum_data' => [
'tmp_name' => [
0 => '/tmp/php/hp9hskjhf',
],
],
'nested' => [
'name' => [
'other' => 'Flag.txt',
Expand Down Expand Up @@ -227,6 +233,18 @@ public function dataNormalizeFiles(): iterable
'Image.png',
'image/png'
),
2 => new UploadedFile(
'/tmp/php/w0ensl4ar',
null,
UPLOAD_ERR_OK
),
],
'minimum_data' => [
0 => new UploadedFile(
'/tmp/php/hp9hskjhf',
0,
UPLOAD_ERR_OK
),
],
'nested' => [
'other' => new UploadedFile(
Expand Down

0 comments on commit bfe7c39

Please sign in to comment.