Skip to content

Commit

Permalink
Improve error message when using allowOnly
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet authored and gsherwood committed Sep 29, 2020
1 parent 861acb1 commit 01370ba
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,18 @@ public function process(File $phpcsFile, $stackPtr)
return;
}

$error = 'Boolean operators between conditions must be at the beginning or end of the line, but not both';
$fix = $phpcsFile->addFixableError($error, $stackPtr, 'FoundMixed');
switch ($this->allowOnly) {
case 'first':
$error = 'Boolean operators between conditions must be at the beginning of the line';
break;
case 'last':
$error = 'Boolean operators between conditions must be at the end of the line';
break;
default:
$error = 'Boolean operators between conditions must be at the beginning or end of the line, but not both';
}

$fix = $phpcsFile->addFixableError($error, $stackPtr, 'FoundMixed');
if ($fix === false) {
return;
}
Expand Down

0 comments on commit 01370ba

Please sign in to comment.