Skip to content

Commit b32f418

Browse files
committed
PHPCS 4.x | File::isReference(): simplify code
Commit 08824f3 added support for `T_USE` tokens for closures being parentheses owners. As the `File::getMethodParameters()` method also supports closure `use` parameters already, the code in the `File::isReference()` method can now be simplified. The existing unit tests already cover this.
1 parent 8b5e6e9 commit b32f418

File tree

1 file changed

+1
-13
lines changed

1 file changed

+1
-13
lines changed

src/Files/File.php

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2061,6 +2061,7 @@ public function isReference($stackPtr)
20612061
if ($owner['code'] === T_FUNCTION
20622062
|| $owner['code'] === T_CLOSURE
20632063
|| $owner['code'] === T_FN
2064+
|| $owner['code'] === T_USE
20642065
) {
20652066
$params = $this->getMethodParameters($this->tokens[$lastBracket]['parenthesis_owner']);
20662067
foreach ($params as $param) {
@@ -2070,19 +2071,6 @@ public function isReference($stackPtr)
20702071
}
20712072
}
20722073
}//end if
2073-
} else {
2074-
$prev = false;
2075-
for ($t = ($this->tokens[$lastBracket]['parenthesis_opener'] - 1); $t >= 0; $t--) {
2076-
if ($this->tokens[$t]['code'] !== T_WHITESPACE) {
2077-
$prev = $t;
2078-
break;
2079-
}
2080-
}
2081-
2082-
if ($prev !== false && $this->tokens[$prev]['code'] === T_USE) {
2083-
// Closure use by reference.
2084-
return true;
2085-
}
20862074
}//end if
20872075
}//end if
20882076

0 commit comments

Comments
 (0)