Skip to content

Commit 8765771

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 485ff63 commit 8765771

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
@@ -2006,6 +2006,7 @@ public function isReference($stackPtr)
20062006
if ($owner['code'] === T_FUNCTION
20072007
|| $owner['code'] === T_CLOSURE
20082008
|| $owner['code'] === T_FN
2009+
|| $owner['code'] === T_USE
20092010
) {
20102011
$params = $this->getMethodParameters($this->tokens[$lastBracket]['parenthesis_owner']);
20112012
foreach ($params as $param) {
@@ -2015,19 +2016,6 @@ public function isReference($stackPtr)
20152016
}
20162017
}
20172018
}//end if
2018-
} else {
2019-
$prev = false;
2020-
for ($t = ($this->tokens[$lastBracket]['parenthesis_opener'] - 1); $t >= 0; $t--) {
2021-
if ($this->tokens[$t]['code'] !== T_WHITESPACE) {
2022-
$prev = $t;
2023-
break;
2024-
}
2025-
}
2026-
2027-
if ($prev !== false && $this->tokens[$prev]['code'] === T_USE) {
2028-
// Closure use by reference.
2029-
return true;
2030-
}
20312019
}//end if
20322020
}//end if
20332021

0 commit comments

Comments
 (0)