Skip to content

Commit c9b3906

Browse files
committed
SlevomatCodingStandard.Classes.ParentCallSpacing: Fixed false positives with parent call used in match()
1 parent 3c7b2cd commit c9b3906

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

SlevomatCodingStandard/Sniffs/Classes/ParentCallSpacingSniff.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use const T_COLON;
1616
use const T_INLINE_ELSE;
1717
use const T_INLINE_THEN;
18+
use const T_MATCH_ARROW;
1819
use const T_OPEN_SHORT_ARRAY;
1920
use const T_RETURN;
2021
use const T_STRING_CONCAT;
@@ -62,7 +63,7 @@ public function process(File $phpcsFile, $parentPointer): void
6263
Tokens::$assignmentTokens,
6364
Tokens::$equalityTokens,
6465
Tokens::$booleanOperators,
65-
[T_RETURN, T_YIELD, T_YIELD_FROM, T_COLON, T_STRING_CONCAT, T_INLINE_THEN, T_INLINE_ELSE, T_COALESCE]
66+
[T_RETURN, T_YIELD, T_YIELD_FROM, T_COLON, T_STRING_CONCAT, T_INLINE_THEN, T_INLINE_ELSE, T_COALESCE, T_MATCH_ARROW]
6667
);
6768
if (in_array($tokens[$previousPointer]['code'], $tokensToIgnore, true)) {
6869
return;

tests/Sniffs/Classes/data/parentCallSpacingNoErrors.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php // lint >= 7.4
1+
<?php // lint >= 8.1
22

33
class X extends Whatever
44
{
@@ -80,4 +80,12 @@ public function p()
8080
return @parent::foo();
8181
}
8282

83+
public function q()
84+
{
85+
return match (true) {
86+
false => parent::q(),
87+
default => parent::q(),
88+
};
89+
}
90+
8391
}

0 commit comments

Comments
 (0)