Skip to content

Commit

Permalink
File::isReference(): simplify code
Browse files Browse the repository at this point in the history
The `File::getMethodParameters()` returns a `reference_token` index, so no need to do any token walking.
  • Loading branch information
jrfnl committed Sep 5, 2020
1 parent 1371c59 commit 76fce40
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions src/Files/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -1981,19 +1981,7 @@ public function isReference($stackPtr)
) {
$params = $this->getMethodParameters($this->tokens[$lastBracket]['parenthesis_owner']);
foreach ($params as $param) {
$varToken = $tokenAfter;
if ($param['variable_length'] === true) {
$varToken = $this->findNext(
(Util\Tokens::$emptyTokens + [T_ELLIPSIS]),
($stackPtr + 1),
null,
true
);
}

if ($param['token'] === $varToken
&& $param['pass_by_reference'] === true
) {
if ($param['reference_token'] === $stackPtr) {
// Function parameter declared to be passed by reference.
return true;
}
Expand Down

0 comments on commit 76fce40

Please sign in to comment.