Skip to content

Commit 01370ba

Browse files
VincentLangletgsherwood
authored andcommitted
Improve error message when using allowOnly
1 parent 861acb1 commit 01370ba

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/Standards/PSR12/Sniffs/ControlStructures/BooleanOperatorPlacementSniff.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,18 @@ public function process(File $phpcsFile, $stackPtr)
154154
return;
155155
}
156156

157-
$error = 'Boolean operators between conditions must be at the beginning or end of the line, but not both';
158-
$fix = $phpcsFile->addFixableError($error, $stackPtr, 'FoundMixed');
157+
switch ($this->allowOnly) {
158+
case 'first':
159+
$error = 'Boolean operators between conditions must be at the beginning of the line';
160+
break;
161+
case 'last':
162+
$error = 'Boolean operators between conditions must be at the end of the line';
163+
break;
164+
default:
165+
$error = 'Boolean operators between conditions must be at the beginning or end of the line, but not both';
166+
}
167+
168+
$fix = $phpcsFile->addFixableError($error, $stackPtr, 'FoundMixed');
159169
if ($fix === false) {
160170
return;
161171
}

0 commit comments

Comments
 (0)