Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent possible warnings on unset variables #542

Merged
merged 5 commits into from Apr 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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