Skip to content

Commit 17cb34f

Browse files
committed
Check that a function uses something before assuming it does, preventing PHP notices
Props keesiemeijer. See #206.
1 parent 2b4a8bf commit 17cb34f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/class-file-reflector.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,10 @@ public function leaveNode( \PHPParser_Node $node ) {
171171
break;
172172

173173
case 'Stmt_Function':
174-
end( $this->functions )->uses = array_pop( $this->location )->uses;
174+
$function = array_pop( $this->location );
175+
if ( isset( $function->uses ) && ! empty( $function->uses ) ) {
176+
end( $this->functions )->uses = $function->uses;
177+
}
175178
break;
176179

177180
case 'Stmt_ClassMethod':

0 commit comments

Comments
 (0)