Skip to content

Commit 97c10e9

Browse files
authored
Merge pull request #989 from PHPCSStandards/phpcs-4.0/feature/sq-2823-remove-some-public-error-properties
Remove public error properties of sniffs that don't need them
2 parents d91b9f2 + e560f26 commit 97c10e9

File tree

5 files changed

+5
-41
lines changed

5 files changed

+5
-41
lines changed

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
*
@@ -377,11 +370,7 @@ public function checkAlignment($phpcsFile, $stackPtr, $end=null)
377370
$foundText,
378371
];
379372

380-
if ($this->error === true) {
381-
$fix = $phpcsFile->addFixableError($error, $assignment, $type, $errorData);
382-
} else {
383-
$fix = $phpcsFile->addFixableWarning($error, $assignment, $type.'Warning', $errorData);
384-
}
373+
$fix = $phpcsFile->addFixableWarning($error, $assignment, $type, $errorData);
385374

386375
$errorGenerated = true;
387376

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
*
@@ -94,11 +87,7 @@ public function process(File $phpcsFile, $stackPtr)
9487
}
9588

9689
$error = 'String concat is not required here; use a single string instead';
97-
if ($this->error === true) {
98-
$phpcsFile->addError($error, $stackPtr, 'Found');
99-
} else {
100-
$phpcsFile->addWarning($error, $stackPtr, 'Found');
101-
}
90+
$phpcsFile->addError($error, $stackPtr, 'Found');
10291

10392
}//end process()
10493

src/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.1.inc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,3 @@ $shouldNotTrigger = 'My' /* comment */ . 'string';
2828
$string = 'Multiline strings are allowed '
2929
. 'when setting is enabled.';
3030
// phpcs:set Generic.Strings.UnnecessaryStringConcat allowMultiline false
31-
32-
// phpcs:set Generic.Strings.UnnecessaryStringConcat error false
33-
$throwWarning = 'My' . 'string';
34-
// phpcs:set Generic.Strings.UnnecessaryStringConcat error true

src/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.php

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,21 +56,11 @@ public function getErrorList($testFile='')
5656
* The key of the array should represent the line number and the value
5757
* should represent the number of warnings that should occur on that line.
5858
*
59-
* @param string $testFile The name of the file being tested.
60-
*
6159
* @return array<int, int>
6260
*/
63-
public function getWarningList($testFile='')
61+
public function getWarningList()
6462
{
65-
switch ($testFile) {
66-
case 'UnnecessaryStringConcatUnitTest.1.inc':
67-
return [
68-
33 => 1,
69-
];
70-
71-
default:
72-
return [];
73-
}
63+
return [];
7464

7565
}//end getWarningList()
7666

src/Standards/Squiz/ruleset.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@
4646

4747
<!-- Have 20 chars padding maximum and always show as errors -->
4848
<rule ref="Generic.Formatting.MultipleStatementAlignment">
49+
<type>error</type>
4950
<properties>
5051
<property name="maxPadding" value="20"/>
51-
<property name="error" value="true"/>
5252
</properties>
5353
</rule>
5454

0 commit comments

Comments
 (0)