Skip to content

Commit ccacdd8

Browse files
committed
Squiz/ValidFunctionName: don't hide one message behind another
1 parent a9c9566 commit ccacdd8

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/Standards/Squiz/Sniffs/NamingConventions/ValidFunctionNameSniff.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ protected function processTokenOutsideScope(File $phpcsFile, $stackPtr)
3939
if (preg_match('|^__[^_]|', $functionName) !== 0) {
4040
$error = 'Function name "%s" is invalid; only PHP magic methods should be prefixed with a double underscore';
4141
$phpcsFile->addError($error, $stackPtr, 'DoubleUnderscore', $errorData);
42-
return;
42+
43+
$functionName = ltrim($functionName, '_');
4344
}
4445

4546
if (Common::isCamelCaps($functionName, false, true, false) === false) {

src/Standards/Squiz/Tests/NamingConventions/ValidFunctionNameUnitTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function getErrorList()
3535
11 => 1,
3636
12 => 1,
3737
13 => 1,
38-
14 => 1,
38+
14 => 2,
3939
];
4040

4141
}//end getErrorList()

0 commit comments

Comments
 (0)