Don't call class_exists() on null

This commit is contained in:
Alexander M. Turek 2021-05-15 01:35:14 +02:00
parent 9c3ee3d82e
commit 88520e53b2
2 changed files with 8 additions and 3 deletions

View File

@ -43,7 +43,7 @@ class LazyLoadingValueHolderGenerator extends BaseGenerator
public function getProxifiedClass(Definition $definition): ?string
{
if (!$definition->hasTag('proxy')) {
return class_exists($class = $definition->getClass()) || interface_exists($class, false) ? $class : null;
return ($class = $definition->getClass()) && (class_exists($class) || interface_exists($class, false)) ? $class : null;
}
if (!$definition->isLazy()) {
throw new \InvalidArgumentException(sprintf('Invalid definition for service of class "%s": setting the "proxy" tag on a service requires it to be "lazy".', $definition->getClass()));

View File

@ -88,8 +88,13 @@ final class CheckTypeDeclarationsPass extends AbstractRecursivePass
return parent::processValue($value, $isRoot);
}
if (!$this->autoload && !class_exists($class = $value->getClass(), false) && !interface_exists($class, false)) {
return parent::processValue($value, $isRoot);
if (!$this->autoload) {
if (!$class = $value->getClass()) {
return parent::processValue($value, $isRoot);
}
if (!class_exists($class, false) && !interface_exists($class, false)) {
return parent::processValue($value, $isRoot);
}
}
if (ServiceLocator::class === $value->getClass()) {