Skip to content

Commit 1fc3fa8

Browse files
committed
chore:
- constructor cleanup - adds the file/type in exception message
1 parent 03800d3 commit 1fc3fa8

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

HeaderTrait.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function withAddedHeader($name, $value): static
9393
if (isset($instance->headersMap[$header = \strtolower($name)])) {
9494
$header = $instance->headersMap[$header];
9595
$instance->headers[$header] = \array_unique(
96-
\array_merge_recursive($instance->headers[$header], $value)
96+
@\array_merge_recursive($instance->headers[$header], $value)
9797
);
9898
} else {
9999
$instance->headersMap[$header] = $name;
@@ -203,15 +203,13 @@ protected function normalizeHeaderName(string $name): string
203203
*
204204
* @return array
205205
*/
206-
protected function normalizeHeaderValue(string $name, $value): array
206+
protected function normalizeHeaderValue(string $name, mixed $value): array
207207
{
208-
if (false === \is_array($value)) {
208+
// if (false === \is_array($value)) {
209209
$value = (array)$value;
210-
}
210+
// }
211211
try {
212-
if (empty($value = \array_map(function($v): string {
213-
return \trim(\preg_replace('/\s+/', ' ', $v));
214-
}, $value))) {
212+
if (empty($value = \array_map(fn($v): string => \trim(\preg_replace('/\s+/', ' ', $v)), $value))) {
215213
throw new \InvalidArgumentException(
216214
\sprintf('The value for header "%s" cannot be empty', $name),
217215
HttpStatus::BAD_REQUEST);

Tests/UploadedFileTest.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,8 @@ public function test_constructor()
3232
/**
3333
* @dataProvider invalidTmpName
3434
*/
35-
public function test_stream_should_pass_when_file_is_null($resource)
35+
public function test_should_fail_when_tmp_name_is_invalid($resource)
3636
{
37-
$this->markTestSkipped('Check the PSR...');
3837
$this->expectException(InvalidArgumentException::class);
3938

4039
$SUT = $this->prepareFile($resource);
@@ -98,15 +97,14 @@ protected function setUp(): void
9897

9998
protected function tearDown(): void
10099
{
101-
unlink($this->file);
100+
@unlink($this->file);
102101
@unlink('/tmp/test-moved-to/filename.txt');
103102
}
104103

105104
private function prepareFile($resource): UploadedFIle
106105
{
107-
$file = (include __DIR__ . '/fixtures/simple-file-array.php')['test'];
106+
$file = (include __DIR__ . '/fixtures/simple-file-array.php')['test'];
108107
$file['tmp_name'] = $resource;
109-
110108
return new UploadedFile($file);
111109
}
112110
}

0 commit comments

Comments
 (0)