8000 Don’t try to wire Response argument with controller.service_arguments · symfony/symfony@494f812 · GitHub
[go: up one dir, main page]

Skip to content

Commit 494f812

Browse files
committed
Don’t try to wire Response argument with controller.service_arguments
1 parent b02a689 commit 494f812

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/Symfony/Component/HttpKernel/DependencyInjection/RegisterControllerArgumentLocatorsPass.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use Symfony\Component\DependencyInjection\Reference;
2323
use Symfony\Component\DependencyInjection\TypedReference;
2424
use Symfony\Component\HttpFoundation\Request;
25+
use Symfony\Component\HttpFoundation\Response;
2526
use Symfony\Component\HttpFoundation\Session\SessionInterface;
2627
use Symfony\Component\VarExporter\ProxyHelper;
2728

@@ -151,7 +152,7 @@ public function process(ContainerBuilder $container)
151152
$invalidBehavior = ContainerInterface::RUNTIME_EXCEPTION_ON_INVALID_REFERENCE;
152153
}
153154

154-
if (Request::class === $type || SessionInterface::class === $type) {
155+
if (Request::class === $type || SessionInterface::class === $type || Response::class === $type) {
155156
continue;
156157
}
157158

src/Symfony/Component/HttpKernel/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

@@ -477,6 +478,20 @@ public function testAutowireAttribute()
477478
$this->assertSame('@bar', $locator->get('escapedRawValue'));
478479
$this->assertFalse($locator->has('service2'));
479480
}
481+
482+
public function testResponseArgumentIsIgnored()
483+
{
484+
$container = new ContainerBuilder();
485+
$resolver = $container->register('argument_resolver.service', 'stdClass')->addArgument([]);
486+
487+
$container->register('foo', WithResponseArgument::class)
488+
->addTag('controller.service_arguments');
489+
490+
(new RegisterControllerArgumentLocatorsPass())->process($container);
491+
492+
$locator = $container->getDefinition((string) $resolver->getArgument(0))->getArgument(0);
493+
$this->assertEmpty(array_keys($locator), 'Response typed argument is ignored');
494+
}
480495
}
481496

482497
class RegisterTestController
@@ -580,3 +595,10 @@ public function fooAction(
580595
) {
581596
}
582597
}
598+
599+
class WithResponseArgument
600+
{
601+
public function fooAction(Response $response, ?Response $nullableResponse)
602+
{
603+
}
604+
}

0 commit comments

Comments
 (0)
0