Skip to content

Commit d3b72a4

Browse files
Merge pull request #87 from VincentLanglet/error
✨ Throw error instead of warning
2 parents 19d708d + 188b3bf commit d3b72a4

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

SymfonyCustom/Sniffs/Formatting/StrictComparisonSniff.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use PHP_CodeSniffer\Sniffs\Sniff;
77

88
/**
9-
* Throws warning if == or != are use
9+
* Throws error if == or != are use
1010
*/
1111
class StrictComparisonSniff implements Sniff
1212
{
@@ -36,9 +36,9 @@ public function process(File $phpcsFile, $stackPtr): void
3636
{
3737
$tokens = $phpcsFile->getTokens();
3838

39-
// This warning is fixable, but it's too dangerous to add automatically fixer
40-
$phpcsFile->addWarning(
41-
'The %s comparator is not recommended, use %s instead',
39+
// This error is fixable, but it's too dangerous to add automatically fixer
40+
$phpcsFile->addError(
41+
'The %s comparator is forbidden, use %s instead',
4242
$stackPtr,
4343
'NotStrict',
4444
[

SymfonyCustom/Tests/Formatting/StrictComparisonUnitTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ class StrictComparisonUnitTest extends AbstractSniffUnitTest
1616
*/
1717
protected function getErrorList(): array
1818
{
19-
return [];
19+
return [
20+
3 => 1,
21+
5 => 1,
22+
];
2023
}
2124

2225
/**
2326
* @return array
2427
*/
2528
protected function getWarningList(): array
2629
{
27-
return [
28-
3 => 1,
29-
5 => 1,
30-
];
30+
return [];
3131
}
3232
}

SymfonyCustom/ruleset.xml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,23 @@
6969

7070
<!-- Disallow -->
7171
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
72-
<rule ref="Generic.CodeAnalysis.AssignmentInCondition"/>
73-
<rule ref="Generic.CodeAnalysis.EmptyPHPStatement"/>
72+
<rule ref="Generic.CodeAnalysis.AssignmentInCondition">
73+
<type>error</type>
74+
</rule>
75+
<rule ref="Generic.CodeAnalysis.EmptyPHPStatement">
76+
<type>error</type>
77+
</rule>
7478
<rule ref="Generic.CodeAnalysis.EmptyStatement"/>
75-
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/>
7679
<rule ref="Generic.PHP.BacktickOperator"/>
7780
<rule ref="Generic.PHP.DisallowShortOpenTag"/>
7881
<rule ref="Generic.PHP.ForbiddenFunctions"/>
7982
<rule ref="PEAR.Commenting.InlineComment"/>
80-
<rule ref="Squiz.PHP.CommentedOutCode"/>
8183
<rule ref="Squiz.PHP.DisallowMultipleAssignments"/>
8284
<rule ref="Squiz.PHP.DiscouragedFunctions"/>
8385
<rule ref="Squiz.PHP.Eval"/>
84-
<rule ref="Squiz.PHP.NonExecutableCode"/>
86+
<rule ref="Squiz.PHP.NonExecutableCode">
87+
<type>error</type>
88+
</rule>
8589
<rule ref="Squiz.Operators.ValidLogicalOperators"/>
8690

8791
<!-- Others -->

0 commit comments

Comments
 (0)