Skip to content

Commit 1e1b942

Browse files
committed
Merge branch 'feature/generic-spreadoperatorspacingafter-ignore-first-class-callables' of https://github.com/jrfnl/PHP_CodeSniffer
2 parents e26cc50 + dc61947 commit 1e1b942

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

src/Standards/Generic/Sniffs/WhiteSpace/SpreadOperatorSpacingAfterSniff.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ public function process(File $phpcsFile, $stackPtr)
6262
return;
6363
}
6464

65+
if ($tokens[$nextNonEmpty]['code'] === T_CLOSE_PARENTHESIS) {
66+
// Ignore PHP 8.1 first class callable syntax.
67+
return;
68+
}
69+
6570
if ($this->ignoreNewlines === true
6671
&& $tokens[$stackPtr]['line'] !== $tokens[$nextNonEmpty]['line']
6772
) {

src/Standards/Generic/Tests/WhiteSpace/SpreadOperatorSpacingAfterUnitTest.inc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,13 @@ function bar( & ... $spread ) {
6767
);
6868
}
6969

70+
// Ignore PHP 8.1 first class callable declarations.
71+
$map = array_map(strtolower(...), $map);
72+
7073
// phpcs:set Generic.WhiteSpace.SpreadOperatorSpacingAfter spacing 0
7174

75+
// Ignore PHP 8.1 first class callable declarations.
76+
$map = array_map(strtolower( ... ), $map);
77+
7278
// Intentional parse error. This has to be the last test in the file.
7379
function bar( ...

src/Standards/Generic/Tests/WhiteSpace/SpreadOperatorSpacingAfterUnitTest.inc.fixed

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,13 @@ function bar( & ... $spread ) {
6262
);
6363
}
6464

65+
// Ignore PHP 8.1 first class callable declarations.
66+
$map = array_map(strtolower(...), $map);
67+
6568
// phpcs:set Generic.WhiteSpace.SpreadOperatorSpacingAfter spacing 0
6669

70+
// Ignore PHP 8.1 first class callable declarations.
71+
$map = array_map(strtolower( ... ), $map);
72+
6773
// Intentional parse error. This has to be the last test in the file.
6874
function bar( ...

0 commit comments

Comments
 (0)