Skip to content

Commit 9370b00

Browse files
committed
Merge branch 'operator-spacing' of https://github.com/kukulich/PHP_CodeSniffer
2 parents 195176e + c0a8bb7 commit 9370b00

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

src/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php

+7-6
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,13 @@ public function register()
7777

7878
// Returning/printing a negative value; eg. (return -1).
7979
$this->nonOperandTokens += [
80-
T_RETURN => T_RETURN,
81-
T_ECHO => T_ECHO,
82-
T_EXIT => T_EXIT,
83-
T_PRINT => T_PRINT,
84-
T_YIELD => T_YIELD,
85-
T_FN_ARROW => T_FN_ARROW,
80+
T_RETURN => T_RETURN,
81+
T_ECHO => T_ECHO,
82+
T_EXIT => T_EXIT,
83+
T_PRINT => T_PRINT,
84+
T_YIELD => T_YIELD,
85+
T_FN_ARROW => T_FN_ARROW,
86+
T_MATCH_ARROW => T_MATCH_ARROW,
8687
];
8788

8889
// Trying to use a negative value; eg. myFunction($var, -2).

src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.inc

+6
Original file line numberDiff line numberDiff line change
@@ -477,5 +477,11 @@ $a = 'a '.-$b;
477477
$a = 'a '.- MY_CONSTANT;
478478
$a = 'a '.- $b;
479479

480+
match ($a) {
481+
'a' => -1,
482+
'b', 'c', 'd' => -2,
483+
default => -3,
484+
};
485+
480486
/* Intentional parse error. This has to be the last test in the file. */
481487
$a = 10 +

src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.inc.fixed

+6
Original file line numberDiff line numberDiff line change
@@ -471,5 +471,11 @@ $a = 'a '.-$b;
471471
$a = 'a '.- MY_CONSTANT;
472472
$a = 'a '.- $b;
473473

474+
match ($a) {
475+
'a' => -1,
476+
'b', 'c', 'd' => -2,
477+
default => -3,
478+
};
479+
474480
/* Intentional parse error. This has to be the last test in the file. */
475481
$a = 10 +

0 commit comments

Comments
 (0)