Skip to content

Commit 623886a

Browse files
authored
[12.x] Fix ResponseFactory should also accept null callback (#55833)
`Symfony\Component\HttpFoundation\StreamedResponse` supports `callable|null` but we currently expect `$callback` to just be `Closure`. Fixes #55831 Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
1 parent 626bb80 commit 623886a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Illuminate/Routing/ResponseFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,14 +186,14 @@ public function eventStream(Closure $callback, array $headers = [], StreamedEven
186186
/**
187187
* Create a new streamed response instance.
188188
*
189-
* @param callable $callback
189+
* @param callable|null $callback
190190
* @param int $status
191191
* @param array $headers
192192
* @return \Symfony\Component\HttpFoundation\StreamedResponse
193193
*/
194194
public function stream($callback, $status = 200, array $headers = [])
195195
{
196-
if ((new ReflectionFunction($callback))->isGenerator()) {
196+
if (! is_null($callback) && (new ReflectionFunction($callback))->isGenerator()) {
197197
return new StreamedResponse(function () use ($callback) {
198198
foreach ($callback() as $chunk) {
199199
echo $chunk;

0 commit comments

Comments
 (0)