Skip to content

Commit ab9677e

Browse files
Merge branch '6.0' into 6.1
* 6.0: [Messenger] cs fix [Messenger] Fix time-limit check exception [Console] Fix console `ProgressBar::override()` after manual `ProgressBar::cleanup()` [FrameworkBundle] typo default_lifetime example [HttpClient] Handle Amp HTTP client v5 incompatibility gracefully [HttpKernel] Don’t try to wire Response argument with controller.service_arguments [PhpUnitBridge] Fix language deprecations incorrectly marked as direct [FrameworkBundle] Removed unused $willBeAvailable params on Configuration [Cache] Remove extra type condition in MemcachedAdapter::createConnection() Tell about messenger:consume invalid limit options [Messenger] Do not throw 'no handlers' exception when skipping due to duplicate handling
2 parents c5907fa + a564504 commit ab9677e

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

DependencyInjection/RegisterControllerArgumentLocatorsPass.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use Symfony\Component\DependencyInjection\Reference;
2626
use Symfony\Component\DependencyInjection\TypedReference;
2727
use Symfony\Component\HttpFoundation\Request;
28+
use Symfony\Component\HttpFoundation\Response;
2829
use Symfony\Component\HttpFoundation\Session\SessionInterface;
2930

3031
/**
@@ -154,7 +155,7 @@ public function process(ContainerBuilder $container)
154155
$invalidBehavior = ContainerInterface::RUNTIME_EXCEPTION_ON_INVALID_REFERENCE;
155156
}
156157

157-
if (Request::class === $type || SessionInterface::class === $type) {
158+
if (Request::class === $type || SessionInterface::class === $type || Response::class === $type) {
158159
continue;
159160
}
160161

Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use Symfony\Component\DependencyInjection\Reference;
2525
use Symfony\Component\DependencyInjection\ServiceLocator;
2626
use Symfony\Component\DependencyInjection\TypedReference;
27+
use Symfony\Component\HttpFoundation\Response;
2728
use Symfony\Component\HttpKernel\DependencyInjection\RegisterControllerArgumentLocatorsPass;
2829
use Symfony\Component\HttpKernel\Tests\Fixtures\Suit;
2930

@@ -443,6 +444,20 @@ public function testBindWithTarget()
443444
$this->assertEquals($expected, $locator->getArgument(0));
444445
}
445446

447+
public function testResponseArgumentIsIgnored()
448+
{
449+
$container = new ContainerBuilder();
450+
$resolver = $container->register('argument_resolver.service', 'stdClass')->addArgument([]);
451+
452+
$container->register('foo', WithResponseArgument::class)
453+
->addTag('controller.service_arguments');
454+
455+
(new RegisterControllerArgumentLocatorsPass())->process($container);
456+
457+
$locator = $container->getDefinition((string) $resolver->getArgument(0))->getArgument(0);
458+
$this->assertEmpty(array_keys($locator), 'Response typed argument is ignored');
459+
}
460+
446461
public function testAutowireAttribute()
447462
{
448463
if (!class_exists(Autowire::class)) {
@@ -558,6 +573,13 @@ public function fooAction(
558573
}
559574
}
560575

576+
class WithResponseArgument
577+
{
578+
public function fooAction(Response $response, ?Response $nullableResponse)
579+
{
580+
}
581+
}
582+
561583
class WithAutowireAttribute
562584
{
563585
public function fooAction(

0 commit comments

Comments
 (0)