Skip to content

Commit 92bd8c9

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 3935729 commit 92bd8c9

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
@@ -1968,6 +1968,7 @@ public function isReference($stackPtr)
19681968
if ($owner['code'] === T_FUNCTION
19691969
|| $owner['code'] === T_CLOSURE
19701970
|| $owner['code'] === T_FN
1971+
|| $owner['code'] === T_USE
19711972
) {
19721973
$params = $this->getMethodParameters($this->tokens[$lastBracket]['parenthesis_owner']);
19731974
foreach ($params as $param) {
@@ -1977,19 +1978,6 @@ public function isReference($stackPtr)
19771978
}
19781979
}
19791980
}//end if
1980-
} else {
1981-
$prev = false;
1982-
for ($t = ($this->tokens[$lastBracket]['parenthesis_opener'] - 1); $t >= 0; $t--) {
1983-
if ($this->tokens[$t]['code'] !== T_WHITESPACE) {
1984-
$prev = $t;
1985-
break;
1986-
}
1987-
}
1988-
1989-
if ($prev !== false && $this->tokens[$prev]['code'] === T_USE) {
1990-
// Closure use by reference.
1991-
return true;
1992-
}
19931981
}//end if
19941982
}//end if
19951983

0 commit comments

Comments
 (0)