Skip to content

Commit 13fca6a

Browse files
[HttpFoundation] Remove always false condition in BinaryFileResponse
1 parent a5a1186 commit 13fca6a

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/Symfony/Component/HttpFoundation/BinaryFileResponse.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ public function getFile(): File
110110
*/
111111
public function setChunkSize(int $chunkSize): static
112112
{
113-
if ($chunkSize < 1 || $chunkSize > \PHP_INT_MAX) {
114-
throw new \LogicException('The chunk size of a BinaryFileResponse cannot be less than 1 or greater than PHP_INT_MAX.');
113+
if ($chunkSize < 1) {
114+
throw new \InvalidArgumentException('The chunk size of a BinaryFileResponse cannot be less than 1.');
115115
}
116116

117117
$this->chunkSize = $chunkSize;

src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,4 +455,14 @@ public function testCreateFromTemporaryFile()
455455
$string = ob_get_clean();
456456
$this->assertSame('foo,bar', $string);
457457
}
458+
459+
public function testSetChunkSizeTooSmall()
460+
{
461+
$response = new BinaryFileResponse(__DIR__.'/File/Fixtures/test.gif');
462+
463+
$this->expectException(\InvalidArgumentException::class);
464+
$this->expectExceptionMessage('The chunk size of a BinaryFileResponse cannot be less than 1.');
465+
466+
$response->setChunkSize(0);
467+
}
458468
}

0 commit comments

Comments
 (0)