Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fdb0ea9

Browse files
[DI] Enhance service locator error message
1 parent d32ecff commit fdb0ea9

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/Symfony/Component/DependencyInjection/Compiler/ServiceLocatorTagPass.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ protected function processValue($value, $isRoot = false)
7878
public static function register(ContainerBuilder $container, array $refMap)
7979
{
8080
foreach ($refMap as $id => $ref) {
81+
if (!$ref instanceof Reference) {
82+
throw new InvalidArgumentException(sprintf('Invalid service locator definition: only services can be referenced, "%s" found for key "%s". Inject parameter values using constructors instead.', is_object($ref) ? get_class($ref) : gettype($ref), $id));
83+
}
8184
$refMap[$id] = new ServiceClosureArgument($ref);
8285
}
8386
ksort($refMap);

0 commit comments

Comments
 (0)