diff vendor/symfony/dependency-injection/Compiler/CheckDefinitionValidityPass.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents 1fec387a4317
children
line wrap: on
line diff
--- a/vendor/symfony/dependency-injection/Compiler/CheckDefinitionValidityPass.php	Tue Jul 10 15:07:59 2018 +0100
+++ b/vendor/symfony/dependency-injection/Compiler/CheckDefinitionValidityPass.php	Thu Feb 28 13:21:36 2019 +0000
@@ -48,6 +48,15 @@
                     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 '
@@ -57,13 +66,7 @@
                     ));
                 }
 
-                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
@@ -80,7 +83,7 @@
             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.');
+                    throw new EnvParameterException([$resolvedId], null, 'A service name ("%s") cannot contain dynamic values.');
                 }
             }
         }
@@ -89,7 +92,7 @@
             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.');
+                    throw new EnvParameterException([$resolvedId], null, 'An alias name ("%s") cannot contain dynamic values.');
                 }
             }
         }