Skip to content

Commit f3e3bcc

Browse files
committed
Squiz.Formatting.OperatorBracket no longer reports false positives in match() structures
1 parent 9370b00 commit f3e3bcc

File tree

4 files changed

+14
-0
lines changed

4 files changed

+14
-0
lines changed

package.xml

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
3030
-- Thanks to Gary Jones (@GaryJones) for the patch
3131
- Generic.PHP.LowerCaseType sniff now correctly examines types inside arrow functions
3232
-- Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
33+
- Squiz.Formatting.OperatorBracket no longer reports false positives in match() structures
3334
- Fixed bug #3616 : Squiz.PHP.DisallowComparisonAssignment false positive for PHP 8 match expression
3435
-- Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
3536
- Fixed bug #3618 : Generic.WhiteSpace.ArbitraryParenthesesSpacing false positive for return new parent()

src/Standards/Squiz/Sniffs/Formatting/OperatorBracketSniff.php

+1
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ public function process(File $phpcsFile, $stackPtr)
109109
T_OPEN_SHORT_ARRAY => true,
110110
T_CASE => true,
111111
T_EXIT => true,
112+
T_MATCH_ARROW => true,
112113
];
113114

114115
if (isset($invalidTokens[$tokens[$previousToken]['code']]) === true) {

src/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.inc

+6
Original file line numberDiff line numberDiff line change
@@ -193,3 +193,9 @@ $expr = match (true) {
193193
if ($pos === count(value: $this->tokens) - 1) {
194194
$file = '...'.substr(string: $file, offset: $padding * -1 + 3);
195195
}
196+
197+
match ($a) {
198+
'a' => -1,
199+
'b', 'c', 'd' => -2,
200+
default => -3,
201+
};

src/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.inc.fixed

+6
Original file line numberDiff line numberDiff line change
@@ -193,3 +193,9 @@ $expr = match (true) {
193193
if ($pos === (count(value: $this->tokens) - 1)) {
194194
$file = '...'.substr(string: $file, offset: ($padding * -1 + 3));
195195
}
196+
197+
match ($a) {
198+
'a' => -1,
199+
'b', 'c', 'd' => -2,
200+
default => -3,
201+
};

0 commit comments

Comments
 (0)