8000 bug fix with test for #54321 · jan-simbera/symfony@c1b826e · GitHub
[go: up one dir, main page]

Skip to content

Commit c1b826e

Browse files
author
simbera
committed
bug fix with test for symfony#54321
1 parent 968d80c commit c1b826e

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/Symfony/Component/HttpFoundation/Request.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,12 @@ public static function create(string $uri, string $method = 'GET', array $parame
382382
*/
383383
public static function setFactory(?callable $callable): void
384384
{
385-
self::$requestFactory = $callable;
385+
if(null === $callable) {
386+
self::$requestFactory = null;
387+
return;
388+
}
389+
390+
self::$requestFactory = $callable(...);
386391
}
387392

388393
/**

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2197,6 +2197,23 @@ public function testFactory()
21972197
Request::setFactory(null);
21982198
}
21992199

2200+
public function testFactoryCallable()
2201+
{
2202+
$request_factory = new class {
2203+
public function createRequest(array $query = [], array $request = [], array $attributes = [], array $cookies = [], array $files = [], array $server = [], $content = null): Request
2204+
{
2205+
return new NewRequest();
2206+
}
2207+
};
2208+
2209+
Request::setFactory([$request_factory, 'createRequest']);
2210+
2211+
$this->assertEquals('foo', Request::create('/')->getFoo());
2212+
2213+
Request::setFactory(null);
2214+
2215+
}
2216+
22002217
/**
22012218
* @dataProvider getLongHostNames
22022219
*/

0 commit comments

Comments
 (0)
0