Skip to content

Commit 6d1b209

Browse files
committed
Improve collision detection with other sniffs
1 parent 6a3e468 commit 6d1b209

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
namespace PHP_CodeSniffer\Standards\PEAR\Sniffs\Functions;
1111

1212
use PHP_CodeSniffer\Files\File;
13+
use PHP_CodeSniffer\Ruleset;
1314
use PHP_CodeSniffer\Sniffs\Sniff;
1415
use PHP_CodeSniffer\Util\Tokens;
1516

@@ -40,6 +41,13 @@ class FunctionCallSignatureSniff implements Sniff
4041
*/
4142
public $allowMultipleArguments = true;
4243

44+
/**
45+
* If TRUE, we are running at the same time as a conflicting sniff
46+
*
47+
* @var boolean
48+
*/
49+
private bool $isConflictWithGenericWhitespace;
50+
4351
/**
4452
* How many spaces should follow the opening bracket.
4553
*
@@ -539,10 +547,21 @@ public function processMultiLineCall(File $phpcsFile, $stackPtr, $openBracket, $
539547
$foundIndent = $tokens[$i]['length'];
540548
}
541549

550+
if (!isset($this->isConflictWithGenericWhitespace)) {
551+
$this->isConflictWithGenericWhitespace = false;
552+
$ruleset = new Ruleset($phpcsFile->config);
553+
foreach ($ruleset->sniffCodes as $sniff) {
554+
if ($sniff === \PHP_CodeSniffer\Standards\Generic\Sniffs\WhiteSpace\ScopeIndentSniff::class) {
555+
$this->isConflictWithGenericWhitespace = true;
556+
break;
557+
}
558+
}
559+
}
560+
542561
if (($foundIndent < $expectedIndent
543562
|| ($inArg === false
544563
&& $expectedIndent !== $foundIndent))
545-
&& in_array('Generic.WhiteSpace.ScopeIndent', $phpcsFile->config->sniffs, true) === false
564+
&& $this->isConflictWithGenericWhitespace === false
546565
) {
547566
$error = 'Multi-line function call not indented correctly; expected %s spaces but found %s';
548567
$data = [

0 commit comments

Comments
 (0)