class CheckReferenceValidityPass
Checks the validity of references.
The following checks are performed by this pass:
- target definitions are not abstract
@author Johannes M. Schmitt <schmittjoh@gmail.com>
Hierarchy
- class \Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass implements \Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface
- class \Symfony\Component\DependencyInjection\Compiler\CheckReferenceValidityPass extends \Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass
Expanded class hierarchy of CheckReferenceValidityPass
File
-
vendor/
symfony/ dependency-injection/ Compiler/ CheckReferenceValidityPass.php, line 26
Namespace
Symfony\Component\DependencyInjection\CompilerView source
class CheckReferenceValidityPass extends AbstractRecursivePass {
protected bool $skipScalars = true;
protected function processValue(mixed $value, bool $isRoot = false) : mixed {
if ($isRoot && $value instanceof Definition && ($value->isSynthetic() || $value->isAbstract())) {
return $value;
}
if ($value instanceof Reference && $this->container
->hasDefinition((string) $value)) {
$targetDefinition = $this->container
->getDefinition((string) $value);
if ($targetDefinition->isAbstract()) {
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));
}
}
return parent::processValue($value, $isRoot);
}
}