4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\DependencyInjection\Compiler;
14 use Symfony\Component\DependencyInjection\ContainerBuilder;
15 use Symfony\Component\DependencyInjection\ChildDefinition;
16 use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
19 * @author Nicolas Grekas <p@tchwork.com>
21 class ResolveClassPass implements CompilerPassInterface
23 private $changes = array();
28 public function process(ContainerBuilder $container)
30 foreach ($container->getDefinitions() as $id => $definition) {
31 if ($definition->isSynthetic() || null !== $definition->getClass()) {
34 if (preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*+(?:\\\\[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*+)++$/', $id)) {
35 if ($definition instanceof ChildDefinition && !class_exists($id)) {
36 throw new InvalidArgumentException(sprintf('Service definition "%s" has a parent but no class, and its name looks like a FQCN. Either the class is missing or you want to inherit it from the parent service. To resolve this ambiguity, please rename this service to a non-FQCN (e.g. using dots), or create the missing class.', $id));
38 $this->changes[strtolower($id)] = $id;
39 $definition->setClass($id);
47 * @deprecated since 3.3, to be removed in 4.0.
49 public function getChanges()
51 $changes = $this->changes;
52 $this->changes = array();