Skip to content

Commit e9e7b57

Browse files
committed
Zend/ValidVariableName: don't hide one message behind another
1 parent 4eb4fc8 commit e9e7b57

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/Standards/Zend/Sniffs/NamingConventions/ValidVariableNameSniff.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ protected function processMemberVar(File $phpcsFile, $stackPtr)
141141
$error = 'Public member variable "%s" must not contain a leading underscore';
142142
$data = [$varName];
143143
$phpcsFile->addError($error, $stackPtr, 'PublicHasUnderscore', $data);
144-
return;
145144
}
146145
} else {
147146
if (substr($varName, 0, 1) !== '_') {
@@ -152,11 +151,13 @@ protected function processMemberVar(File $phpcsFile, $stackPtr)
152151
$varName,
153152
];
154153
$phpcsFile->addError($error, $stackPtr, 'PrivateNoUnderscore', $data);
155-
return;
156154
}
157155
}
158156

159-
if (Common::isCamelCaps($varName, false, $public, false) === false) {
157+
// Remove a potential underscore prefix for testing CamelCaps.
158+
$varName = ltrim($varName, '_');
159+
160+
if (Common::isCamelCaps($varName, false, true, false) === false) {
160161
$error = 'Member variable "%s" is not in valid camel caps format';
161162
$data = [$varName];
162163
$phpcsFile->addError($error, $stackPtr, 'MemberVarNotCamelCaps', $data);

0 commit comments

Comments
 (0)