diff --git a/Slim/CallableResolver.php b/Slim/CallableResolver.php index a622dcbee..c1c351276 100644 --- a/Slim/CallableResolver.php +++ b/Slim/CallableResolver.php @@ -146,6 +146,9 @@ private function resolveSlimNotation(string $toResolve): array $instance = $this->container->get($class); } else { if (!class_exists($class)) { + if ($method) { + $class .= '::' . $method . '()'; + } throw new RuntimeException(sprintf('Callable %s does not exist', $class)); } $instance = new $class($this->container); diff --git a/tests/CallableResolverTest.php b/tests/CallableResolverTest.php index 8d739154b..27e0823a5 100644 --- a/tests/CallableResolverTest.php +++ b/tests/CallableResolverTest.php @@ -475,7 +475,7 @@ public function testMiddlewareFunctionNotFoundThrowException() public function testClassNotFoundThrowException() { $this->expectException(RuntimeException::class); - $this->expectExceptionMessage('Callable Unknown does not exist'); + $this->expectExceptionMessage('Callable Unknown::notFound() does not exist'); /** @var ContainerInterface $container */ $container = $this->containerProphecy->reveal(); @@ -486,7 +486,7 @@ public function testClassNotFoundThrowException() public function testRouteClassNotFoundThrowException() { $this->expectException(RuntimeException::class); - $this->expectExceptionMessage('Callable Unknown does not exist'); + $this->expectExceptionMessage('Callable Unknown::notFound() does not exist'); /** @var ContainerInterface $container */ $container = $this->containerProphecy->reveal(); @@ -497,7 +497,7 @@ public function testRouteClassNotFoundThrowException() public function testMiddlewareClassNotFoundThrowException() { $this->expectException(RuntimeException::class); - $this->expectExceptionMessage('Callable Unknown does not exist'); + $this->expectExceptionMessage('Callable Unknown::notFound() does not exist'); /** @var ContainerInterface $container */ $container = $this->containerProphecy->reveal(); @@ -508,7 +508,7 @@ public function testMiddlewareClassNotFoundThrowException() public function testCallableClassNotFoundThrowException() { $this->expectException(RuntimeException::class); - $this->expectExceptionMessage('Callable Unknown does not exist'); + $this->expectExceptionMessage('Callable Unknown::notFound() does not exist'); /** @var ContainerInterface $container */ $container = $this->containerProphecy->reveal(); @@ -519,7 +519,7 @@ public function testCallableClassNotFoundThrowException() public function testRouteCallableClassNotFoundThrowException() { $this->expectException(RuntimeException::class); - $this->expectExceptionMessage('Callable Unknown does not exist'); + $this->expectExceptionMessage('Callable Unknown::notFound() does not exist'); /** @var ContainerInterface $container */ $container = $this->containerProphecy->reveal(); @@ -530,7 +530,7 @@ public function testRouteCallableClassNotFoundThrowException() public function testMiddlewareCallableClassNotFoundThrowException() { $this->expectException(RuntimeException::class); - $this->expectExceptionMessage('Callable Unknown does not exist'); + $this->expectExceptionMessage('Callable Unknown::notFound() does not exist'); /** @var ContainerInterface $container */ $container = $this->containerProphecy->reveal();