This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component/DependencyInjection/Compiler/ResolveClassPass.php

53 lines
1.4 KiB
PHP
Raw Normal View History

2017-01-02 13:43:40 +00:00
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\ChildDefinition;
/**
* @author Nicolas Grekas <p@tchwork.com>
*/
class ResolveClassPass implements CompilerPassInterface
{
private $changes = array();
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
{
foreach ($container->getDefinitions() as $id => $definition) {
if ($definition instanceof ChildDefinition || $definition->isSynthetic() || null !== $definition->getClass()) {
continue;
}
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)) {
$this->changes[$id] = $container->getCaseSensitiveId($id);
$definition->setClass($this->changes[$id]);
}
}
}
/**
* @internal
*
* @deprecated since 3.3, to be removed in 4.0.
*/
public function getChanges()
{
$changes = $this->changes;
$this->changes = array();
return $changes;
}
}