Skip to content

Commit

Permalink
Merge branch 'operator-spacing' of https://github.com/kukulich/PHP_Co…
Browse files Browse the repository at this point in the history
  • Loading branch information
gsherwood committed Sep 10, 2022
2 parents 195176e + c0a8bb7 commit 9370b00
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,13 @@ public function register()

// Returning/printing a negative value; eg. (return -1).
$this->nonOperandTokens += [
T_RETURN => T_RETURN,
T_ECHO => T_ECHO,
T_EXIT => T_EXIT,
T_PRINT => T_PRINT,
T_YIELD => T_YIELD,
T_FN_ARROW => T_FN_ARROW,
T_RETURN => T_RETURN,
T_ECHO => T_ECHO,
T_EXIT => T_EXIT,
T_PRINT => T_PRINT,
T_YIELD => T_YIELD,
T_FN_ARROW => T_FN_ARROW,
T_MATCH_ARROW => T_MATCH_ARROW,
];

// Trying to use a negative value; eg. myFunction($var, -2).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -477,5 +477,11 @@ $a = 'a '.-$b;
$a = 'a '.- MY_CONSTANT;
$a = 'a '.- $b;

match ($a) {
'a' => -1,
'b', 'c', 'd' => -2,
default => -3,
};

/* Intentional parse error. This has to be the last test in the file. */
$a = 10 +
Original file line number Diff line number Diff line change
Expand Up @@ -471,5 +471,11 @@ $a = 'a '.-$b;
$a = 'a '.- MY_CONSTANT;
$a = 'a '.- $b;

match ($a) {
'a' => -1,
'b', 'c', 'd' => -2,
default => -3,
};

/* Intentional parse error. This has to be the last test in the file. */
$a = 10 +

0 comments on commit 9370b00

Please sign in to comment.