diff --git a/src/DI/Compiler.php b/src/DI/Compiler.php index f58d17f9c..efc3da169 100644 --- a/src/DI/Compiler.php +++ b/src/DI/Compiler.php @@ -240,12 +240,12 @@ public static function parseServices(ContainerBuilder $builder, array $config, $ } array_multisort($depths, $services); - foreach ($services as $origName => $def) { - if ((string) (int) $origName === (string) $origName) { + foreach ($services as $name => $def) { + if ((string) (int) $name === (string) $name) { $postfix = $def instanceof Statement && is_string($def->getEntity()) ? '.' . $def->getEntity() : (is_scalar($def) ? ".$def" : ''); $name = (count($builder->getDefinitions()) + 1) . preg_replace('#\W+#', '_', $postfix); - } else { - $name = ($namespace ? $namespace . '.' : '') . strtr($origName, '\\', '_'); + } elseif ($namespace) { + $name = $namespace . '.' . $name; } $params = $builder->parameters;