Skip to content

Commit

Permalink
fix(app-helper): Fix func call on variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliver Nybroe committed Nov 29, 2021
1 parent f5c9939 commit e0eff4e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/PHPStan/Laravel/DisallowAppHelperUsageRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
],
]);
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

class CallsOtherAppHelper
{
public function container()
{
$var = function () {

};

return $var();
}
}

?>

0 comments on commit e0eff4e

Please sign in to comment.