Skip to content

Commit 08a0d1c

Browse files
committed
resolve static call names correctly
1 parent 13631c5 commit 08a0d1c

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/Support/NameResolver.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ public static function resolve($node)
3737
}
3838

3939
if ($node instanceof Node\Expr\StaticCall) {
40-
$name = $node->name->toString();
41-
$class = $node->class->getType();
40+
if (is_array($class)) {
41+
$class = $name;
42+
}
43+
4244
return [$class, "{$class}::{$name}"];
4345
}
4446

src/Visitors/StaticCallVisitor.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Permafrost\PhpCodeSearch\Results\FileSearchResults;
66
use Permafrost\PhpCodeSearch\Results\Nodes\StaticMethodCallNode;
77
use Permafrost\PhpCodeSearch\Support\Arr;
8+
use Permafrost\PhpCodeSearch\Support\NameResolver;
89
use PhpParser\Node;
910
use PhpParser\NodeVisitorAbstract;
1011

@@ -24,7 +25,7 @@ public function __construct(FileSearchResults $results, array $names)
2425
public function enterNode(Node $node)
2526
{
2627
if ($node instanceof Node\Expr\StaticCall) {
27-
$name = $node->class->getType();
28+
$name = NameResolver::resolve($node)[0] ?? $node->class->toString();
2829
$methodName = $node->name->toString();
2930

3031
if (Arr::matches($name, $this->names, true) || Arr::matches("{$name}::{$methodName}", $this->names, true)) {

0 commit comments

Comments
 (0)