Chris@0: Chris@0: * Chris@0: * For the full copyright and license information, please view the LICENSE Chris@0: * file that was distributed with this source code. Chris@0: */ Chris@0: Chris@0: namespace Symfony\Component\DependencyInjection\Compiler; Chris@0: Chris@0: use Symfony\Component\DependencyInjection\Definition; Chris@17: use Symfony\Component\DependencyInjection\Exception\RuntimeException; Chris@0: use Symfony\Component\DependencyInjection\Reference; Chris@0: Chris@0: /** Chris@0: * Checks the validity of references. Chris@0: * Chris@0: * The following checks are performed by this pass: Chris@0: * - target definitions are not abstract Chris@0: * Chris@0: * @author Johannes M. Schmitt Chris@0: */ Chris@14: class CheckReferenceValidityPass extends AbstractRecursivePass Chris@0: { Chris@14: protected function processValue($value, $isRoot = false) Chris@14: { Chris@14: if ($isRoot && $value instanceof Definition && ($value->isSynthetic() || $value->isAbstract())) { Chris@14: return $value; Chris@14: } Chris@14: if ($value instanceof Reference && $this->container->hasDefinition((string) $value)) { Chris@14: $targetDefinition = $this->container->getDefinition((string) $value); Chris@0: Chris@14: if ($targetDefinition->isAbstract()) { Chris@17: throw new RuntimeException(sprintf('The definition "%s" has a reference to an abstract definition "%s". Abstract definitions cannot be the target of references.', $this->currentId, $value)); Chris@0: } Chris@0: } Chris@0: Chris@14: return parent::processValue($value, $isRoot); Chris@0: } Chris@0: }