10000 bug #41233 [DependencyInjection][ProxyManagerBridge] Don't call class… · symfony/symfony@9e12a38 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9e12a38

Browse files
bug #41233 [DependencyInjection][ProxyManagerBridge] Don't call class_exists() on null (derrabus)
This PR was merged into the 4.4 branch. Discussion ---------- [DependencyInjection][ProxyManagerBridge] Don't call class_exists() on null | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | N/A | License | MIT | Doc PR | N/A PHP 8.1 complains if we pass `null` to `class_exists()` or `interface_exists()`: > class_exists(): Passing null to parameter `#1` ($class) of type string is deprecated Commits ------- 88520e5 Don't call class_exists() on null
2 parents a7d3533 + 88520e5 commit 9e12a38

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/LazyLoadingValueHolderGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function generate(\ReflectionClass $originalClass, ClassGenerator $classG
4343
public function getProxifiedClass(Definition $definition): ?string
4444
{
4545
if (!$definition->hasTag('proxy')) {
46-
return class_exists($class = $definition->getClass()) || interface_exists($class, false) ? $class : null;
46+
return ($class = $definition->getClass()) && (class_exists($class) || interface_exists($class, false)) ? $class : null;
4747
}
4848
if (!$definition->isLazy()) {
4949
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()));

src/Symfony/Component/DependencyInjection/Compiler/CheckTypeDeclarationsPass.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,13 @@ protected function processValue($value, $isRoot = false)
8888
return parent::processValue($value, $isRoot);
8989
}
9090

91-
if (!$this->autoload && !class_exists($class = $value->getClass(), false) && !interface_exists($class, false)) {
92-
return parent::processValue($value, $isRoot);
91+
if (!$this->autoload) {
92+
if (!$class = $value->getClass()) {
93+
return parent::processValue($value, $isRoot);
94+
}
95+
if (!class_exists($class, false) && !interface_exists($class, false)) {
96+
return parent::processValue($value, $isRoot);
97+
}
9398
}
9499

95100
if (ServiceLocator::class === $value->getClass()) {

0 commit comments

Comments
 (0)
0