From 448e8c530e098c7e847dfda2636a4348e492c91e Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 5 Sep 2020 22:53:14 +0200 Subject: [PATCH] PHPCS 4.x | File::isReference(): simplify code Commit 08824f327ce5e20d7528c5e838dd7fade3dcd11c 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. --- src/Files/File.php | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/src/Files/File.php b/src/Files/File.php index 81aa673095..ececc47fbe 100644 --- a/src/Files/File.php +++ b/src/Files/File.php @@ -2024,6 +2024,7 @@ public function isReference($stackPtr) if ($owner['code'] === T_FUNCTION || $owner['code'] === T_CLOSURE || $owner['code'] === T_FN + || $owner['code'] === T_USE ) { $params = $this->getMethodParameters($this->tokens[$lastBracket]['parenthesis_owner']); foreach ($params as $param) { @@ -2033,19 +2034,6 @@ public function isReference($stackPtr) } } }//end if - } else { - $prev = false; - for ($t = ($this->tokens[$lastBracket]['parenthesis_opener'] - 1); $t >= 0; $t--) { - if ($this->tokens[$t]['code'] !== T_WHITESPACE) { - $prev = $t; - break; - } - } - - if ($prev !== false && $this->tokens[$prev]['code'] === T_USE) { - // Closure use by reference. - return true; - } }//end if }//end if