Skip to content

Commit c0bd2bb

Browse files
jrfnlgsherwood
andauthored
Removed all parse error warnings from sniffs (#990)
* Removed all parse error warnings from sniffs Ref: * squizlabs/PHP_CodeSniffer 2455 --------- Co-authored-by: Greg Sherwood <gsherwood@squiz.net> Co-authored-by: jrfnl <jrfnl@users.noreply.github.com>
1 parent 97c10e9 commit c0bd2bb

20 files changed

+22
-55
lines changed

src/Standards/Generic/Sniffs/Classes/OpeningBraceSameLineSniff.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ public function process(File $phpcsFile, $stackPtr)
4949
$errorData = [strtolower($tokens[$stackPtr]['content']).' '.$tokens[$scopeIdentifier]['content']];
5050

5151
if (isset($tokens[$stackPtr]['scope_opener']) === false) {
52-
$error = 'Possible parse error: %s missing opening or closing brace';
53-
$phpcsFile->addWarning($error, $stackPtr, 'MissingBrace', $errorData);
52+
// Parse error or live coding.
5453
return;
5554
}
5655

src/Standards/Generic/Tests/Classes/OpeningBraceSameLineUnitTest.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class Test_Class_Bad_H extends Test_Class_Bad_G {
4747
class Test_Class_Bad_I implements Test_Interface_Bad_C{
4848
}
4949

50-
// This one should be flagged as a potential parse error.
50+
// This one should be ignored as a potential parse error.
5151
class Test_Class_Bad_H
5252

5353
// This is OK.

src/Standards/Generic/Tests/Classes/OpeningBraceSameLineUnitTest.inc.fixed

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class Test_Class_Bad_H extends Test_Class_Bad_G {
4747
class Test_Class_Bad_I implements Test_Interface_Bad_C {
4848
}
4949

50-
// This one should be flagged as a potential parse error.
50+
// This one should be ignored as a potential parse error.
5151
class Test_Class_Bad_H
5252

5353
// This is OK.

src/Standards/Generic/Tests/Classes/OpeningBraceSameLineUnitTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function getErrorList()
6060
*/
6161
public function getWarningList()
6262
{
63-
return [51 => 1];
63+
return [];
6464

6565
}//end getWarningList()
6666

src/Standards/PEAR/Sniffs/Classes/ClassDeclarationSniff.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ public function process(File $phpcsFile, $stackPtr)
4848
$errorData = [strtolower($tokens[$stackPtr]['content'])];
4949

5050
if (isset($tokens[$stackPtr]['scope_opener']) === false) {
51-
$error = 'Possible parse error: %s missing opening or closing brace';
52-
$phpcsFile->addWarning($error, $stackPtr, 'MissingBrace', $errorData);
51+
// Parse error or live coding.
5352
return;
5453
}
5554

src/Standards/PEAR/Tests/Classes/ClassDeclarationUnitTest.2.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ if (!class_exists('ClassOpeningBraceTabIndented')) {
77
}
88

99

10-
// Needs to be last test in the file. Intentional parse error.
10+
// Needs to be last test in the file. Intentional parse error. Should be ignored.
1111
class MyParseError extends Exception

src/Standards/PEAR/Tests/Classes/ClassDeclarationUnitTest.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,6 @@ public function getErrorList($testFile='')
8888
*/
8989
public function getWarningList($testFile='')
9090
{
91-
if ($testFile === 'ClassDeclarationUnitTest.2.inc') {
92-
return [11 => 1];
93-
}
94-
9591
return[];
9692

9793
}//end getWarningList()

src/Standards/Squiz/Sniffs/Classes/ValidClassNameSniff.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ public function process(File $phpcsFile, $stackPtr)
4949
$tokens = $phpcsFile->getTokens();
5050

5151
if (isset($tokens[$stackPtr]['scope_opener']) === false) {
52-
$error = 'Possible parse error: %s missing opening or closing brace';
53-
$data = [$tokens[$stackPtr]['content']];
54-
$phpcsFile->addWarning($error, $stackPtr, 'MissingBrace', $data);
52+
// Parse error or live coding.
5553
return;
5654
}
5755

src/Standards/Squiz/Sniffs/Commenting/ClosingDeclarationCommentSniff.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ public function process(File $phpcsFile, $stackPtr)
6262
}
6363

6464
if (isset($tokens[$stackPtr]['scope_closer']) === false) {
65-
$error = 'Possible parse error: non-abstract method defined as abstract';
66-
$phpcsFile->addWarning($error, $stackPtr, 'Abstract');
65+
// Parse error or live coding.
6766
return;
6867
}
6968

@@ -80,9 +79,7 @@ public function process(File $phpcsFile, $stackPtr)
8079
}//end if
8180

8281
if (isset($tokens[$stackPtr]['scope_closer']) === false) {
83-
$error = 'Possible parse error: %s missing opening or closing brace';
84-
$data = [$tokens[$stackPtr]['content']];
85-
$phpcsFile->addWarning($error, $stackPtr, 'MissingBrace', $data);
82+
// Parse error or live coding.
8683
return;
8784
}
8885

src/Standards/Squiz/Sniffs/ControlStructures/ForEachLoopDeclarationSniff.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,12 @@ public function process(File $phpcsFile, $stackPtr)
5959

6060
$openingBracket = $phpcsFile->findNext(T_OPEN_PARENTHESIS, $stackPtr);
6161
if ($openingBracket === false) {
62-
$error = 'Possible parse error: FOREACH has no opening parenthesis';
63-
$phpcsFile->addWarning($error, $stackPtr, 'MissingOpenParenthesis');
62+
// Parse error or live coding.
6463
return;
6564
}
6665

6766
if (isset($tokens[$openingBracket]['parenthesis_closer']) === false) {
68-
$error = 'Possible parse error: FOREACH has no closing parenthesis';
69-
$phpcsFile->addWarning($error, $stackPtr, 'MissingCloseParenthesis');
67+
// Parse error or live coding.
7068
return;
7169
}
7270

@@ -134,8 +132,7 @@ public function process(File $phpcsFile, $stackPtr)
134132

135133
$asToken = $phpcsFile->findNext(T_AS, $openingBracket);
136134
if ($asToken === false) {
137-
$error = 'Possible parse error: FOREACH has no AS statement';
138-
$phpcsFile->addWarning($error, $stackPtr, 'MissingAs');
135+
// Parse error or live coding.
139136
return;
140137
}
141138

0 commit comments

Comments
 (0)