Permalink
Browse files

Removed unused code and added TRAIT support (see bug #20307)

  • Loading branch information...
1 parent 648c5a2 commit b6a56f67fa889425101933663684bef558566b2d @gsherwood gsherwood committed Jun 30, 2014
@@ -116,7 +116,7 @@ protected function processVariable(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
// this: MyClass::$_variable, so we don't know its scope.
$inClass = true;
} else {
- $inClass = $phpcsFile->hasCondition($stackPtr, array(T_CLASS, T_INTERFACE));
+ $inClass = $phpcsFile->hasCondition($stackPtr, array(T_CLASS, T_INTERFACE, T_TRAIT));
}
if ($inClass === true) {
@@ -220,25 +220,14 @@ protected function processVariableInString(PHP_CodeSniffer_File $phpcsFile, $sta
continue;
}
- // There is no way for us to know if the var is public or private,
- // so we have to ignore a leading underscore if there is one and just
- // check the main part of the variable name.
- $originalVarName = $varName;
- if (substr($varName, 0, 1) === '_') {
- if ($phpcsFile->hasCondition($stackPtr, array(T_CLASS, T_INTERFACE)) === true) {
- $varName = substr($varName, 1);
- }
- }
-
if (PHP_CodeSniffer::isCamelCaps($varName, false, true, false) === false) {
- $varName = $matches[0];
$error = 'Variable "%s" is not in valid camel caps format';
- $data = array($originalVarName);
+ $data = array($varName);
$phpcsFile->addError($error, $stackPtr, 'StringNotCamelCaps', $data);
}
}
- }//end if
+ }
}//end processVariableInString()
@@ -227,24 +227,13 @@ protected function processVariableInString(PHP_CodeSniffer_File $phpcsFile, $sta
continue;
}
- // There is no way for us to know if the var is public or private,
- // so we have to ignore a leading underscore if there is one and just
- // check the main part of the variable name.
- $originalVarName = $varName;
- if (substr($varName, 0, 1) === '_') {
- if ($phpcsFile->hasCondition($stackPtr, array(T_CLASS, T_INTERFACE, T_TRAIT)) === true) {
- $varName = substr($varName, 1);
- }
- }
-
if (PHP_CodeSniffer::isCamelCaps($varName, false, true, false) === false) {
- $varName = $matches[0];
$error = 'Variable "%s" is not in valid camel caps format';
- $data = array($originalVarName);
+ $data = array($varName);
$phpcsFile->addError($error, $stackPtr, 'StringVarNotCamelCaps', $data);
} else if (preg_match('|\d|', $varName)) {
$warning = 'Variable "%s" contains numbers but this is discouraged';
- $data = array($originalVarName);
+ $data = array($varName);
$phpcsFile->addWarning($warning, $stackPtr, 'StringVarContainsNumbers', $data);
}
}

0 comments on commit b6a56f6

Please sign in to comment.