From 88520e53b292122a3e40b5c0f583f7a379318c68 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sat, 15 May 2021 01:35:14 +0200 Subject: [PATCH] Don't call class_exists() on null --- .../PhpDumper/LazyLoadingValueHolderGenerator.php | 2 +- .../Compiler/CheckTypeDeclarationsPass.php | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/LazyLoadingValueHolderGenerator.php b/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/LazyLoadingValueHolderGenerator.php index 2ce78cd523..141147a64c 100644 --- a/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/LazyLoadingValueHolderGenerator.php +++ b/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/LazyLoadingValueHolderGenerator.php @@ -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())); diff --git a/src/Symfony/Component/DependencyInjection/Compiler/CheckTypeDeclarationsPass.php b/src/Symfony/Component/DependencyInjection/Compiler/CheckTypeDeclarationsPass.php index 6eb305b8c5..ac56fb1eb1 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/CheckTypeDeclarationsPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/CheckTypeDeclarationsPass.php @@ -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()) {