Skip to content

Commit 9e2a834

Browse files
committed
bug #10797 [HttpFoundation] Allow File instance to be passed to BinaryFileResponse (anlutro)
This PR was merged into the 2.3 branch. Discussion ---------- [HttpFoundation] Allow File instance to be passed to BinaryFileResponse | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #10608 | License | MIT | Doc PR | See #10608 for discussion and reasoning. The docblocks get rather long with this change. The File class does extend SplFileObject so technically it could be left out of the docblock if that is more desirable. Commits ------- fc04ad2 Allow File instance to be passed to BinaryFileResponse
2 parents 37a4876 + fc04ad2 commit 9e2a834

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/Symfony/Component/HttpFoundation/BinaryFileResponse.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ public static function create($file = null, $status = 200, $headers = array(), $
8181
*/
8282
public function setFile($file, $contentDisposition = null, $autoEtag = false, $autoLastModified = true)
8383
{
84-
$file = new File((string) $file);
84+
if (!$file instanceof File) {
85+
$file = new File((string) $file);
86+
}
8587

8688
if (!$file->isReadable()) {
8789
throw new FileException('File must be readable.');

0 commit comments

Comments
 (0)