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

Skip to content

Commit a3ac58b

Browse files
Add test
1 parent 5803d25 commit a3ac58b

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
namespace Pr5596;
4+
5+
use PhpParser\Node\Expr\CallLike;
6+
use PhpParser\Node\Expr\FuncCall;
7+
use PhpParser\Node\Expr\MethodCall;
8+
use PhpParser\Node\Expr\New_;
9+
use PhpParser\Node\Expr\StaticCall;
10+
use PhpParser\Node\Identifier;
11+
use PhpParser\Node\Name;
12+
use PHPStan\Analyser\Scope;
13+
14+
use function PHPStan\Testing\assertType;
15+
16+
class Test
17+
{
18+
private function whitelistAllowedCallables(
19+
CallLike $node,
20+
Scope $scope
21+
): void
22+
{
23+
if ($node instanceof MethodCall && $node->name instanceof Identifier) {
24+
assertType('PhpParser\Node\Expr\MethodCall', $node);
25+
assertType('PhpParser\Node\Identifier', $node->name);
26+
assertType('PhpParser\Node\Expr', $node->var);
27+
} elseif ($node instanceof StaticCall && $node->name instanceof Identifier && $node->class instanceof Name) {
28+
assertType('PhpParser\Node\Expr\StaticCall', $node);
29+
assertType('PhpParser\Node\Identifier', $node->name);
30+
assertType('PhpParser\Node\Name', $node->class);
31+
} elseif ($node instanceof New_ && $node->class instanceof Name) {
32+
assertType('PhpParser\Node\Expr\New_', $node);
33+
assertType('PhpParser\Node\Name', $node->class);
34+
} elseif ($node instanceof FuncCall && $node->name instanceof Name) {
35+
assertType('PhpParser\Node\Expr\FuncCall', $node);
36+
assertType('PhpParser\Node\Name', $node->name);
37+
} elseif ($node instanceof FuncCall) {
38+
assertType('PhpParser\Node\Expr\FuncCall', $node);
39+
assertType('PhpParser\Node\Expr', $node->name);
40+
}
41+
}
42+
}

0 commit comments

Comments
 (0)