Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[VarExporter] Generate proxies for static abstract methods #48742

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/Symfony/Component/VarExporter/ProxyHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -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 = <<<EOPHP
if (isset(\$this->lazyObjectReal)) {
\$this->lazyObjectReal->{$method->name}(...\\func_get_args());
Expand Down
7 changes: 7 additions & 0 deletions src/Symfony/Component/VarExporter/Tests/ProxyHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down