diff --git a/src/Symfony/Component/VarExporter/ProxyHelper.php b/src/Symfony/Component/VarExporter/ProxyHelper.php index ba24c4afb08a0..c323f0b2cd9b0 100644 --- a/src/Symfony/Component/VarExporter/ProxyHelper.php +++ b/src/Symfony/Component/VarExporter/ProxyHelper.php @@ -129,7 +129,7 @@ public static function generateLazyProxy(?\ReflectionClass $class, array $interf } foreach ($methodReflectors as $method) { - if ($method->isStatic() || isset($methods[$lcName = strtolower($method->name)])) { + if (($method->isStatic() && !$method->isAbstract()) || isset($methods[$lcName = strtolower($method->name)])) { continue; } if ($method->isFinal()) { @@ -145,7 +145,9 @@ public static function generateLazyProxy(?\ReflectionClass $class, array $interf $signature = self::exportSignature($method); $parentCall = $method->isAbstract() ? "throw new \BadMethodCallException('Cannot forward abstract method \"{$method->class}::{$method->name}()\".')" : "parent::{$method->name}(...\\func_get_args())"; - if (str_ends_with($signature, '): never') || str_ends_with($signature, '): void')) { + if ($method->isStatic()) { + $body = " $parentCall;"; + } elseif (str_ends_with($signature, '): never') || str_ends_with($signature, '): void')) { $body = <<lazyObjectReal)) { \$this->lazyObjectReal->{$method->name}(...\\func_get_args()); diff --git a/src/Symfony/Component/VarExporter/Tests/ProxyHelperTest.php b/src/Symfony/Component/VarExporter/Tests/ProxyHelperTest.php index 260980d94f870..7745a77146fb3 100644 --- a/src/Symfony/Component/VarExporter/Tests/ProxyHelperTest.php +++ b/src/Symfony/Component/VarExporter/Tests/ProxyHelperTest.php @@ -147,6 +147,11 @@ public function foo2(?\Symfony\Component\VarExporter\Tests\Bar $b): \Symfony\Com return throw new \BadMethodCallException('Cannot forward abstract method "Symfony\Component\VarExporter\Tests\TestForProxyHelperInterface2::foo2()".'); } + + public static function foo3(): string + { + throw new \BadMethodCallException('Cannot forward abstract method "Symfony\Component\VarExporter\Tests\TestForProxyHelperInterface2::foo3()".'); + } } // Help opcache.preload discover always-needed symbols @@ -236,6 +241,8 @@ public function foo1(): ?Bar; interface TestForProxyHelperInterface2 { public function foo2(?Bar $b): self; + + public static function foo3(): string; } class TestSignatureFQ extends \stdClass