Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a671816

Browse filesBrowse files
bug #48172 [HttpKernel] Don’t try to wire Response argument with controller.service_arguments (MatTheCat)
This PR was submitted for the 6.2 branch but it was merged into the 5.4 branch instead. Discussion ---------- [HttpKernel] Don’t try to wire Response argument with controller.service_arguments | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #48138 | License | MIT | Doc PR | N/A Commits ------- 7832d8d [HttpKernel] Don’t try to wire Response argument with controller.service_arguments
2 parents d84aec5 + 7832d8d commit a671816
Copy full SHA for a671816

File tree

2 files changed

+24
-1
lines changed
Filter options

2 files changed

+24
-1
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/DependencyInjection/RegisterControllerArgumentLocatorsPass.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use Symfony\Component\DependencyInjection\Reference;
2525
use Symfony\Component\DependencyInjection\TypedReference;
2626
use Symfony\Component\HttpFoundation\Request;
27+
use Symfony\Component\HttpFoundation\Response;
2728
use Symfony\Component\HttpFoundation\Session\SessionInterface;
2829

2930
/**
@@ -174,7 +175,7 @@ public function process(ContainerBuilder $container)
174175
$invalidBehavior = ContainerInterface::RUNTIME_EXCEPTION_ON_INVALID_REFERENCE;
175176
}
176177

177-
if (Request::class === $type || SessionInterface::class === $type) {
178+
if (Request::class === $type || SessionInterface::class === $type || Response::class === $type) {
178179
continue;
179180
}
180181

‎src/Symfony/Component/HttpKernel/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php
+22Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
use Symfony\Component\DependencyInjection\Reference;
2424
use Symfony\Component\DependencyInjection\ServiceLocator;
2525
use Symfony\Component\DependencyInjection\TypedReference;
26+
use Symfony\Component\HttpFoundation\Response;
2627
use Symfony\Component\HttpKernel\DependencyInjection\RegisterControllerArgumentLocatorsPass;
2728
use Symfony\Component\HttpKernel\Tests\Fixtures\Suit;
2829

@@ -447,6 +448,20 @@ public function testBindWithTarget()
447448
];
448449
$this->assertEquals($expected, $locator->getArgument(0));
449450
}
451+
452+
public function testResponseArgumentIsIgnored()
453+
{
454+
$container = new ContainerBuilder();
455+
$resolver = $container->register('argument_resolver.service', 'stdClass')->addArgument([]);
456+
457+
$container->register('foo', WithResponseArgument::class)
458+
->addTag('controller.service_arguments');
459+
460+
(new RegisterControllerArgumentLocatorsPass())->process($container);
461+
462+
$locator = $container->getDefinition((string) $resolver->getArgument(0))->getArgument(0);
463+
$this->assertEmpty(array_keys($locator), 'Response typed argument is ignored');
464+
}
450465
}
451466

452467
class RegisterTestController
@@ -527,3 +542,10 @@ public function fooAction(
527542
) {
528543
}
529544
}
545+
546+
class WithResponseArgument
547+
{
548+
public function fooAction(Response $response, ?Response $nullableResponse)
549+
{
550+
}
551+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.