From e560f26eeae30e97716d108fc9e237b75dd97853 Mon Sep 17 00:00:00 2001 From: Greg Sherwood Date: Tue, 12 May 2020 09:23:06 +1000 Subject: [PATCH] Remove public error properties of sniffs that don't need them Fixes squizlabs/PHP_CodeSniffer 2823 Related to 186 Co-authored-by: jrfnl --- .../Formatting/MultipleStatementAlignmentSniff.php | 13 +------------ .../Strings/UnnecessaryStringConcatSniff.php | 13 +------------ .../Strings/UnnecessaryStringConcatUnitTest.1.inc | 4 ---- .../Strings/UnnecessaryStringConcatUnitTest.php | 14 ++------------ src/Standards/Squiz/ruleset.xml | 2 +- 5 files changed, 5 insertions(+), 41 deletions(-) diff --git a/src/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php b/src/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php index 87becd7449..e82c8244fc 100644 --- a/src/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php +++ b/src/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php @@ -19,13 +19,6 @@ class MultipleStatementAlignmentSniff implements Sniff { - /** - * If true, an error will be thrown; otherwise a warning. - * - * @var boolean - */ - public $error = false; - /** * The maximum amount of padding before the alignment is ignored. * @@ -377,11 +370,7 @@ public function checkAlignment($phpcsFile, $stackPtr, $end=null) $foundText, ]; - if ($this->error === true) { - $fix = $phpcsFile->addFixableError($error, $assignment, $type, $errorData); - } else { - $fix = $phpcsFile->addFixableWarning($error, $assignment, $type.'Warning', $errorData); - } + $fix = $phpcsFile->addFixableWarning($error, $assignment, $type, $errorData); $errorGenerated = true; diff --git a/src/Standards/Generic/Sniffs/Strings/UnnecessaryStringConcatSniff.php b/src/Standards/Generic/Sniffs/Strings/UnnecessaryStringConcatSniff.php index 6660aaee71..13d6b4b525 100644 --- a/src/Standards/Generic/Sniffs/Strings/UnnecessaryStringConcatSniff.php +++ b/src/Standards/Generic/Sniffs/Strings/UnnecessaryStringConcatSniff.php @@ -16,13 +16,6 @@ class UnnecessaryStringConcatSniff implements Sniff { - /** - * If true, an error will be thrown; otherwise a warning. - * - * @var boolean - */ - public $error = true; - /** * If true, strings concatenated over multiple lines are allowed. * @@ -94,11 +87,7 @@ public function process(File $phpcsFile, $stackPtr) } $error = 'String concat is not required here; use a single string instead'; - if ($this->error === true) { - $phpcsFile->addError($error, $stackPtr, 'Found'); - } else { - $phpcsFile->addWarning($error, $stackPtr, 'Found'); - } + $phpcsFile->addError($error, $stackPtr, 'Found'); }//end process() diff --git a/src/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.1.inc b/src/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.1.inc index d2ac790d14..26251fa7a5 100644 --- a/src/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.1.inc +++ b/src/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.1.inc @@ -28,7 +28,3 @@ $shouldNotTrigger = 'My' /* comment */ . 'string'; $string = 'Multiline strings are allowed ' . 'when setting is enabled.'; // phpcs:set Generic.Strings.UnnecessaryStringConcat allowMultiline false - -// phpcs:set Generic.Strings.UnnecessaryStringConcat error false -$throwWarning = 'My' . 'string'; -// phpcs:set Generic.Strings.UnnecessaryStringConcat error true diff --git a/src/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.php b/src/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.php index 9d42a4dbab..e0f02ac7e5 100644 --- a/src/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.php +++ b/src/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.php @@ -56,21 +56,11 @@ public function getErrorList($testFile='') * The key of the array should represent the line number and the value * should represent the number of warnings that should occur on that line. * - * @param string $testFile The name of the file being tested. - * * @return array */ - public function getWarningList($testFile='') + public function getWarningList() { - switch ($testFile) { - case 'UnnecessaryStringConcatUnitTest.1.inc': - return [ - 33 => 1, - ]; - - default: - return []; - } + return []; }//end getWarningList() diff --git a/src/Standards/Squiz/ruleset.xml b/src/Standards/Squiz/ruleset.xml index 0b5af6b85d..d1d16588e1 100644 --- a/src/Standards/Squiz/ruleset.xml +++ b/src/Standards/Squiz/ruleset.xml @@ -46,9 +46,9 @@ + error -