Skip to content

Commit

Permalink
Merge branch 'feature/isreference-bugfix-closure-return-by-reference'…
Browse files Browse the repository at this point in the history
  • Loading branch information
gsherwood committed Jun 22, 2020
2 parents 3a1dc78 + 1ae9566 commit 57a67b0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Files/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -1937,6 +1937,7 @@ public function isReference($stackPtr)
);

if ($this->tokens[$tokenBefore]['code'] === T_FUNCTION
|| $this->tokens[$tokenBefore]['code'] === T_CLOSURE
|| $this->tokens[$tokenBefore]['code'] === T_FN
) {
// Function returns a reference.
Expand Down
3 changes: 3 additions & 0 deletions tests/Core/File/IsReferenceTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,6 @@ $closure = function() use (&$var){};

/* testArrowFunctionReturnByReference */
fn&($x) => $x;

/* testClosureReturnByReference */
$closure = function &($param) use ($value) {};
4 changes: 4 additions & 0 deletions tests/Core/File/IsReferenceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,10 @@ public function dataIsReference()
'/* testArrowFunctionReturnByReference */',
true,
],
[
'/* testClosureReturnByReference */',
true,
],
];

}//end dataIsReference()
Expand Down

0 comments on commit 57a67b0

Please sign in to comment.