Skip to content

Commit 1de2674

Browse files
committed
Merge branch '6.1' into 6.2
* 6.1: [Notifier][SMSBiuras] Fix CS Fix SmsBiurasTransportTest::testTestMode [Notifier][SmsBiuras] Simplify test and data provider [Notifier] [SMSBiuras] `true`/`false` mismatch for `test_mode` option [HttpKernel] Fix message for unresovable arguments of invokable controllers ignore const expressions read by phpdocumentor [DependencyInjection] Process bindings in ServiceLocatorTagPass
2 parents 9e5e334 + 72fba35 commit 1de2674

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

Controller/ArgumentResolver/NotTaggedControllerValueResolver.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,10 @@ public function resolve(Request $request, ArgumentMetadata $argument): array
7272
$controller = ltrim($controller, '\\');
7373
}
7474

75-
if (!$this->container->has($controller) && false !== $i = strrpos($controller, ':')) {
76-
$controller = substr($controller, 0, $i).strtolower(substr($controller, $i));
75+
if (!$this->container->has($controller)) {
76+
$controller = (false !== $i = strrpos($controller, ':'))
77+
? substr($controller, 0, $i).strtolower(substr($controller, $i))
78+
: $controller.'::__invoke';
7779
}
7880

7981
if ($this->container->has($controller)) {

Tests/Controller/ArgumentResolver/NotTaggedControllerValueResolverTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,17 @@ public function testControllerNameIsAnArray()
108108
$resolver->resolve($request, $argument);
109109
}
110110

111+
public function testInvokableController()
112+
{
113+
$this->expectException(RuntimeException::class);
114+
$this->expectExceptionMessage('Could not resolve argument $dummy of "App\Controller\Mine::__invoke()", maybe you forgot to register the controller as a service or missed tagging it with the "controller.service_arguments"?');
115+
$resolver = new NotTaggedControllerValueResolver(new ServiceLocator([]));
116+
$argument = new ArgumentMetadata('dummy', \stdClass::class, false, false, null);
117+
$request = $this->requestWithAttributes(['_controller' => 'App\Controller\Mine']);
118+
$this->assertTrue($resolver->supports($request, $argument));
119+
$resolver->resolve($request, $argument);
120+
}
121+
111122
private function requestWithAttributes(array $attributes)
112123
{
113124
$request = Request::create('/');

0 commit comments

Comments
 (0)