Skip to content

Commit 72fba35

Browse files
committed
Merge branch '6.0' into 6.1
* 6.0: [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 ab9677e + 61c836f commit 72fba35

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

Controller/ArgumentResolver/NotTaggedControllerValueResolver.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,9 @@ public function resolve(Request $request, ArgumentMetadata $argument): iterable
6969
}
7070

7171
if (!$this->container->has($controller)) {
72-
$i = strrpos($controller, ':');
73-
$controller = substr($controller, 0, $i).strtolower(substr($controller, $i));
72+
$controller = (false !== $i = strrpos($controller, ':'))
73+
? substr($controller, 0, $i).strtolower(substr($controller, $i))
74+
: $controller.'::__invoke';
7475
}
7576

7677
$what = sprintf('argument $%s of "%s()"', $argument->getName(), $controller);

Tests/Controller/ArgumentResolver/NotTaggedControllerValueResolverTest.php

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

101+
public function testInvokableController()
102+
{
103+
$this->expectException(RuntimeException::class);
104+
$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"?');
105+
$resolver = new NotTaggedControllerValueResolver(new ServiceLocator([]));
106+
$argument = new ArgumentMetadata('dummy', \stdClass::class, false, false, null);
107+
$request = $this->requestWithAttributes(['_controller' => 'App\Controller\Mine']);
108+
$this->assertTrue($resolver->supports($request, $argument));
109+
$resolver->resolve($request, $argument);
110+
}
111+
101112
private function requestWithAttributes(array $attributes)
102113
{
103114
$request = Request::create('/');

0 commit comments

Comments
 (0)