Skip to content

Commit 606d876

Browse files
committed
Remove public error properties of sniffs that don't need them (ref #2823)
1 parent ea01076 commit 606d876

File tree

3 files changed

+23
-24
lines changed

3 files changed

+23
-24
lines changed

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,24 @@ The file documents changes to the PHP_CodeSniffer project.
7070
- Removed JS-specific sniff `Squiz.WhiteSpace.PropertyLabelSpacing`
7171
- Removed the entire `Squiz.CSS` category, and all sniffs within
7272
- Removed the entire `MySource` standard, and all sniffs within
73+
- Removed `error` property of sniff `Generic.Strings.UnnecessaryStringConcat`
74+
- This sniff now always produces errors
75+
- To make this sniff produce warnings, include the following in a `ruleset.xml` file:
76+
```xml
77+
<rule ref="Generic.Strings.UnnecessaryStringConcat">
78+
<type>warning</type>
79+
</rule>
80+
```
81+
- Removed `error` property of sniff `Generic.Formatting.MultipleStatementAlignment`
82+
- This sniff now always produces warnings
83+
- Also removes the `Generic.Formatting.MultipleStatementAlignment.IncorrectWarning` sniff message
84+
- Now renamed to `Generic.Formatting.MultipleStatementAlignment.Incorrect`
85+
- Also removes the `Generic.Formatting.MultipleStatementAlignment.NotSameWarning` sniff message
86+
- Now renamed to `Generic.Formatting.MultipleStatementAlignment.NotSame`
87+
- To make this sniff produce errors, include the following in a `ruleset.xml` file:
88+
```xml
89+
<rule ref="Generic.Formatting.MultipleStatementAlignment">
90+
<type>error</type>
91+
</rule>
92+
```
93+

src/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,6 @@
1919
class MultipleStatementAlignmentSniff implements Sniff
2020
{
2121

22-
/**
23-
* If true, an error will be thrown; otherwise a warning.
24-
*
25-
* @var boolean
26-
*/
27-
public $error = false;
28-
2922
/**
3023
* The maximum amount of padding before the alignment is ignored.
3124
*
@@ -355,11 +348,7 @@ public function checkAlignment($phpcsFile, $stackPtr, $end=null)
355348
$foundText,
356349
];
357350

358-
if ($this->error === true) {
359-
$fix = $phpcsFile->addFixableError($error, $assignment, $type, $errorData);
360-
} else {
361-
$fix = $phpcsFile->addFixableWarning($error, $assignment, $type.'Warning', $errorData);
362-
}
351+
$fix = $phpcsFile->addFixableWarning($error, $assignment, $type, $errorData);
363352

364353
$errorGenerated = true;
365354

src/Standards/Generic/Sniffs/Strings/UnnecessaryStringConcatSniff.php

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,6 @@
1616
class UnnecessaryStringConcatSniff implements Sniff
1717
{
1818

19-
/**
20-
* If true, an error will be thrown; otherwise a warning.
21-
*
22-
* @var boolean
23-
*/
24-
public $error = true;
25-
2619
/**
2720
* If true, strings concatenated over multiple lines are allowed.
2821
*
@@ -86,11 +79,7 @@ public function process(File $phpcsFile, $stackPtr)
8679
}
8780

8881
$error = 'String concat is not required here; use a single string instead';
89-
if ($this->error === true) {
90-
$phpcsFile->addError($error, $stackPtr, 'Found');
91-
} else {
92-
$phpcsFile->addWarning($error, $stackPtr, 'Found');
93-
}
82+
$phpcsFile->addError($error, $stackPtr, 'Found');
9483
}//end if
9584
}//end if
9685

0 commit comments

Comments
 (0)