Skip to content

Commit

Permalink
fix: Formatting\ReturnTypeSniff to use new type of token for parenthesis
Browse files Browse the repository at this point in the history
Since [PHP_CodeSniffer 3.10.0](https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/tag/3.10.0) parenthesis token has been changed to:
- T_TYPE_OPEN_PARENTHESIS (from T_OPEN_PARENTHESIS)
- T_TYPE_CLOSE_PARENTHESIS (from T_CLOSE_PARENTHESIS)

and therefore the sniff did not work correctly for composite return type declarations.

Bump minimum PHP_CodeSniffer version to 3.10.3 so the new tokens are defined.
  • Loading branch information
michalbundyra committed Oct 15, 2024
1 parent 341543c commit dd59bb2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
],
"require": {
"php": "^7.3 || ^8.0",
"squizlabs/php_codesniffer": "^3.7.2"
"squizlabs/php_codesniffer": "^3.10.3"
},
"require-dev": {
"phpunit/phpunit": "^9.6.15"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@
use const T_NULL;
use const T_NULLABLE;
use const T_OPEN_CURLY_BRACKET;
use const T_OPEN_PARENTHESIS;
use const T_PARENT;
use const T_SELF;
use const T_SEMICOLON;
use const T_STRING;
use const T_TRUE;
use const T_TYPE_CLOSE_PARENTHESIS;
use const T_TYPE_INTERSECTION;
use const T_TYPE_OPEN_PARENTHESIS;
use const T_TYPE_UNION;
use const T_USE;
use const T_WHITESPACE;
Expand Down Expand Up @@ -116,8 +117,8 @@ public function process(File $phpcsFile, $stackPtr)
T_TYPE_UNION,
T_PARENT,
T_WHITESPACE,
T_OPEN_PARENTHESIS,
T_CLOSE_PARENTHESIS,
T_TYPE_OPEN_PARENTHESIS,
T_TYPE_CLOSE_PARENTHESIS,
],
$parenthesisCloser + 1,
$eol,
Expand Down Expand Up @@ -150,8 +151,8 @@ public function process(File $phpcsFile, $stackPtr)
}

$notTypes = [
T_OPEN_PARENTHESIS,
T_CLOSE_PARENTHESIS,
T_TYPE_OPEN_PARENTHESIS,
T_TYPE_CLOSE_PARENTHESIS,
T_BITWISE_AND,
T_BITWISE_OR,
T_TYPE_INTERSECTION,
Expand Down

0 comments on commit dd59bb2

Please sign in to comment.