Skip to content

Commit 2cc7c72

Browse files
committed
ParentCallSpacingSniff: Fixed false positives
1 parent 805b97c commit 2cc7c72

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

SlevomatCodingStandard/Sniffs/Classes/ParentCallSpacingSniff.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
use function array_key_exists;
1111
use function array_merge;
1212
use function in_array;
13+
use const T_COALESCE;
1314
use const T_COLON;
15+
use const T_INLINE_ELSE;
16+
use const T_INLINE_THEN;
1417
use const T_OPEN_SHORT_ARRAY;
1518
use const T_PARENT;
1619
use const T_RETURN;
@@ -55,7 +58,7 @@ public function process(File $phpcsFile, $parentPointer): void
5558
Tokens::$assignmentTokens,
5659
Tokens::$equalityTokens,
5760
Tokens::$booleanOperators,
58-
[T_RETURN, T_YIELD, T_YIELD_FROM, T_OPEN_SHORT_ARRAY, T_COLON, T_STRING_CONCAT]
61+
[T_RETURN, T_YIELD, T_YIELD_FROM, T_OPEN_SHORT_ARRAY, T_COLON, T_STRING_CONCAT, T_INLINE_THEN, T_INLINE_ELSE, T_COALESCE]
5962
);
6063
if (in_array($tokens[$previousPointer]['code'], $tokensToIgnore, true)) {
6164
return;

tests/Sniffs/Classes/data/parentCallSpacingNoErrors.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,21 @@ function l()
5757
return '"' . parent::l() . '"';
5858
}
5959

60+
public function m(): object
61+
{
62+
return true
63+
? parent::foo()
64+
: self::bar();
65+
}
66+
67+
public function n(): object
68+
{
69+
return true ?? parent::foo();
70+
}
71+
72+
public function o(): object
73+
{
74+
return true ?: parent::foo();
75+
}
76+
6077
}

0 commit comments

Comments
 (0)