X-Git-Url: https://yaffs.net/gitweb/?a=blobdiff_plain;f=vendor%2Fsymfony%2Fdependency-injection%2FCompiler%2FCheckDefinitionValidityPass.php;h=a1967802f6a30d37a8eebd2d935f8b0704822331;hb=4e1bfbf98b844da83b18aca92ef00f11a4735806;hp=0d21ef284425204fc7ed4a96877015bb2d5db97d;hpb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;p=yaffs-website diff --git a/vendor/symfony/dependency-injection/Compiler/CheckDefinitionValidityPass.php b/vendor/symfony/dependency-injection/Compiler/CheckDefinitionValidityPass.php index 0d21ef284..a1967802f 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,14 +47,26 @@ 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)) { + if (0 === strpos($id, '\\') && 1 < substr_count($id, '\\')) { + throw new RuntimeException(sprintf( + 'The definition for "%s" has no class attribute, and appears to reference a class or interface. ' + .'Please specify the class attribute explicitly or remove the leading backslash by renaming ' + .'the service to "%s" to get rid of this error.', + $id, substr($id, 1) + )); + } + + 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 ' - .'this service dynamically at runtime, please mark it as synthetic=true. ' - .'If this is an abstract definition solely used by child definitions, ' - .'please add abstract=true, otherwise specify a class to get rid of this error.', - $id - )); + throw new RuntimeException(sprintf('The definition for "%s" has no class. If you intend to inject this service dynamically at runtime, please mark it as synthetic=true. If this is an abstract definition solely used by child definitions, please add abstract=true, otherwise specify a class to get rid of this error.', $id)); } // tag attribute values must be scalars @@ -68,6 +79,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.'); + } + } } } }