X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fsymfony%2Fdependency-injection%2FCompiler%2FCheckDefinitionValidityPass.php;fp=vendor%2Fsymfony%2Fdependency-injection%2FCompiler%2FCheckDefinitionValidityPass.php;h=d7d44d90ce6d979a9d89200600d1a4c866a4e927;hp=0d21ef284425204fc7ed4a96877015bb2d5db97d;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0 diff --git a/vendor/symfony/dependency-injection/Compiler/CheckDefinitionValidityPass.php b/vendor/symfony/dependency-injection/Compiler/CheckDefinitionValidityPass.php index 0d21ef284..d7d44d90c 100644 --- a/vendor/symfony/dependency-injection/Compiler/CheckDefinitionValidityPass.php +++ b/vendor/symfony/dependency-injection/Compiler/CheckDefinitionValidityPass.php @@ -12,6 +12,7 @@ namespace Symfony\Component\DependencyInjection\Compiler; use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Exception\EnvParameterException; use Symfony\Component\DependencyInjection\Exception\RuntimeException; /** @@ -31,15 +32,13 @@ class CheckDefinitionValidityPass implements CompilerPassInterface /** * Processes the ContainerBuilder to validate the Definition. * - * @param ContainerBuilder $container - * * @throws RuntimeException When the Definition is invalid */ public function process(ContainerBuilder $container) { foreach ($container->getDefinitions() as $id => $definition) { // synthetic service is public - if ($definition->isSynthetic() && !$definition->isPublic()) { + if ($definition->isSynthetic() && !($definition->isPublic() || $definition->isPrivate())) { throw new RuntimeException(sprintf('A synthetic service ("%s") must be public.', $id)); } @@ -48,6 +47,15 @@ class CheckDefinitionValidityPass implements CompilerPassInterface if ($definition->getFactory()) { throw new RuntimeException(sprintf('Please add the class to service "%s" even if it is constructed by a factory since we might need to add method calls based on compile-time checks.', $id)); } + if (class_exists($id) || interface_exists($id, false)) { + throw new RuntimeException(sprintf( + 'The definition for "%s" has no class attribute, and appears to reference a ' + .'class or interface in the global namespace. Leaving out the "class" attribute ' + .'is only allowed for namespaced classes. Please specify the class attribute ' + .'explicitly to get rid of this error.', + $id + )); + } throw new RuntimeException(sprintf( 'The definition for "%s" has no class. If you intend to inject ' @@ -68,6 +76,22 @@ class CheckDefinitionValidityPass implements CompilerPassInterface } } } + + if ($definition->isPublic() && !$definition->isPrivate()) { + $resolvedId = $container->resolveEnvPlaceholders($id, null, $usedEnvs); + if (null !== $usedEnvs) { + throw new EnvParameterException(array($resolvedId), null, 'A service name ("%s") cannot contain dynamic values.'); + } + } + } + + foreach ($container->getAliases() as $id => $alias) { + if ($alias->isPublic() && !$alias->isPrivate()) { + $resolvedId = $container->resolveEnvPlaceholders($id, null, $usedEnvs); + if (null !== $usedEnvs) { + throw new EnvParameterException(array($resolvedId), null, 'An alias name ("%s") cannot contain dynamic values.'); + } + } } } }