You are here

protected function Drupal_Sniffs_NamingConventions_ValidVariableNameSniff::processMemberVar in Coder 7.2

Processes class member variables.

Parameters

PHP_CodeSniffer_File $phpcsFile The file being scanned.:

int $stackPtr The position of the current token: in the stack passed in $tokens.

Return value

void

File

coder_sniffer/Drupal/Sniffs/NamingConventions/ValidVariableNameSniff.php, line 36

Class

Drupal_Sniffs_NamingConventions_ValidVariableNameSniff
Drupal_Sniffs_NamingConventions_ValidVariableNameSniff.

Code

protected function processMemberVar(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
  $tokens = $phpcsFile
    ->getTokens();
  $memberProps = $phpcsFile
    ->getMemberProperties($stackPtr);
  if (empty($memberProps) === true) {
    return;
  }
  $memberName = ltrim($tokens[$stackPtr]['content'], '$');
  if (strpos($memberName, '_') !== false) {
    $error = 'Class property %s should use lowerCamel naming without underscores';
    $data = array(
      $tokens[$stackPtr]['content'],
    );
    $phpcsFile
      ->addError($error, $stackPtr, 'LowerCamelName', $data);
  }
}