Skip to content

Commit

Permalink
[Php70] Handle crash on First class callable on ThisCallOnStaticMetho…
Browse files Browse the repository at this point in the history
…dToStaticCallRector (#3003)
  • Loading branch information
samsonasik committed Oct 19, 2022
1 parent 71ffc80 commit e4ec1f9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace Rector\Tests\Php70\Rector\MethodCall\ThisCallOnStaticMethodToStaticCallRector\Fixture;

final class SkipFirstClassCallable
{
public function getFunctions(): array
{
return [
new TwigFunction('top_level_domain', $this->topLevelDomain(...)),
];
}

public static function topLevelDomain(?string $host = null): string
{
if (null === $host) {
$host = $_SERVER['HTTP_HOST'];
}

$urlPieces = explode('.', (string) $host);

return end($urlPieces);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ public function refactor(Node $node): ?Node
return null;
}

if ($node->isFirstClassCallable()) {
return null;
}

$objectReference = $this->resolveClassSelf($node);
return $this->nodeFactory->createStaticCall($objectReference, $methodName, $node->args);
}
Expand Down

0 comments on commit e4ec1f9

Please sign in to comment.