Skip to content

Commit

Permalink
Check that a function uses something before assuming it does, prevent…
Browse files Browse the repository at this point in the history
…ing PHP notices

Props keesiemeijer.
See #206.
  • Loading branch information
coffee2code committed Nov 14, 2020
1 parent 2b4a8bf commit 17cb34f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/class-file-reflector.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,10 @@ public function leaveNode( \PHPParser_Node $node ) {
break;

case 'Stmt_Function':
end( $this->functions )->uses = array_pop( $this->location )->uses;
$function = array_pop( $this->location );
if ( isset( $function->uses ) && ! empty( $function->uses ) ) {
end( $this->functions )->uses = $function->uses;
}
break;

case 'Stmt_ClassMethod':
Expand Down

0 comments on commit 17cb34f

Please sign in to comment.