diff --git a/src/PHPStan/Laravel/DisallowAppHelperUsageRule.php b/src/PHPStan/Laravel/DisallowAppHelperUsageRule.php index 51a8493..0b3971f 100644 --- a/src/PHPStan/Laravel/DisallowAppHelperUsageRule.php +++ b/src/PHPStan/Laravel/DisallowAppHelperUsageRule.php @@ -25,7 +25,13 @@ public function getNodeType(): string */ public function processNode(Node $node, Scope $scope): array { - $functionName = $node->name->toString(); + $nodeName = $node->name; + + if (!$nodeName instanceof Node\Name\FullyQualified) { + return []; + } + + $functionName = $nodeName->toString(); if ($functionName !== self::FUNCTION_NAME) { return []; diff --git a/tests/PHPStan/Laravel/DisallowAppUsageRule/DisallowAppUsageRuleTest.php b/tests/PHPStan/Laravel/DisallowAppUsageRule/DisallowAppUsageRuleTest.php index 0de26d9..ea16f51 100644 --- a/tests/PHPStan/Laravel/DisallowAppUsageRule/DisallowAppUsageRuleTest.php +++ b/tests/PHPStan/Laravel/DisallowAppUsageRule/DisallowAppUsageRuleTest.php @@ -23,7 +23,10 @@ 7, ], ], - 'calls app function from other namespace' => [ + 'skips app function from other namespace' => [ __DIR__ . '/Fixture/skip_app_function_in_namespace.php.inc', - ] + ], + 'skips function call on variable' => [ + __DIR__ . '/Fixture/skip_variable_call.php.inc', + ], ]); diff --git a/tests/PHPStan/Laravel/DisallowAppUsageRule/Fixture/skip_variable_call.php.inc b/tests/PHPStan/Laravel/DisallowAppUsageRule/Fixture/skip_variable_call.php.inc new file mode 100644 index 0000000..b9dc7b1 --- /dev/null +++ b/tests/PHPStan/Laravel/DisallowAppUsageRule/Fixture/skip_variable_call.php.inc @@ -0,0 +1,15 @@ +