Skip to content

Commit

Permalink
PHPCS 4.x | FunctionDeclarations::getParameters(): document T_USE han…
Browse files Browse the repository at this point in the history
…dling

`T_USE` tokens used for closure use statements are parentheses owners as of PHPCS 4.x.

The `FunctionDeclarations::getParameters()` method already handles this correctly cross-version.

This just adds documentation to confirm this has been looked at and no changes are needed for cross-version compatibility.

Refs:
* squizlabs/PHP_CodeSniffer 2593
* squizlabs/PHP_CodeSniffer@08824f3
* squizlabs/PHP_CodeSniffer 3104
  • Loading branch information
jrfnl committed May 12, 2021
1 parent ff705f0 commit 56388c5
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions PHPCSUtils/Utils/FunctionDeclarations.php
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ public static function getParameters(File $phpcsFile, $stackPtr)
}

if ($tokens[$stackPtr]['code'] === \T_USE) {
// This will work PHPCS 3.x/4.x cross-version without much overhead.
$opener = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
if ($opener === false
|| $tokens[$opener]['code'] !== \T_OPEN_PARENTHESIS
Expand Down

0 comments on commit 56388c5

Please sign in to comment.