Skip to content

Commit

Permalink
Merge pull request #17 from elkuku/cs-private-members-no-underscore
Browse files Browse the repository at this point in the history
Change code style
  • Loading branch information
eddieajau committed Feb 24, 2013
2 parents ae5d8b9 + ecf901b commit 005a921
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions Sniffs/NamingConventions/ValidVariableNameSniff.php
Expand Up @@ -54,7 +54,6 @@ protected function processMemberVar(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
}

$memberName = ltrim($tokens[$stackPtr]['content'], '$');
$isPublic = ($memberProps['scope'] === 'private') ? false : true;
$scope = $memberProps['scope'];
$scopeSpecified = $memberProps['scope_specified'];

Expand Down Expand Up @@ -88,16 +87,8 @@ protected function processMemberVar(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
$isDeprecated = false;
}

// If it's a private member, it must have an underscore on the front.
if ($isPublic === false && $memberName{0} !== '_') {
$error = 'Private member variable "%s" must be prefixed with an underscore';
$data = array($memberName);
$phpcsFile->addError($error, $stackPtr, 'PrivateNoUnderscore', $data);
return;
}

// If it's not a private member, it must not have an underscore on the front.
if ($isDeprecated === false && $isPublic === true && $scopeSpecified === true && $memberName{0} === '_') {
// Member vars must not be prefixed by an underscore.
if ($isDeprecated === false && $scopeSpecified === true && $memberName{0} === '_') {
$error = '%s member variable "%s" must not be prefixed with an underscore';
$data = array(
ucfirst($scope),
Expand Down

0 comments on commit 005a921

Please sign in to comment.