Skip to content

Commit

Permalink
Fix a crash if the isPassedByReference want to check the parent of a …
Browse files Browse the repository at this point in the history
…parent that does not exist. phpmd#1016
  • Loading branch information
tvbeek committed Feb 9, 2024
1 parent ea80ce8 commit 6a3af51
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/main/php/PHPMD/Rule/AbstractLocalVariable.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,12 +288,17 @@ protected function isPassedByReference($variable)
{
$parent = $this->getNode($variable->getParent());

if (!($parent && $parent instanceof ASTArguments)) {
if (!($parent instanceof ASTArguments)) {
return false;
}

$argumentPosition = array_search($this->getNode($variable), $parent->getChildren());
$function = $this->getNode($parent->getParent());
$parentParent = $parent->getParent();
if ($parentParent === null) {
return false;
}
$function = $this->getNode($parentParent);

$functionParent = $this->getNode($function->getParent());
$functionName = $function->getImage();

Expand Down

0 comments on commit 6a3af51

Please sign in to comment.