Chris@0: getFilename())); Chris@0: $fileExtension = end($nameParts); Chris@0: // Only check in *.module files. Chris@0: if ($fileExtension !== 'module' && $fileExtension !== 'install') { Chris@0: return; Chris@0: } Chris@0: Chris@0: $tokens = $phpcsFile->getTokens(); Chris@0: $argument = $this->getArgument(1); Chris@0: if ($tokens[$argument['start']]['code'] !== T_CONSTANT_ENCAPSED_STRING) { Chris@0: // Not a string literal, so this is some obscure constant that we ignore. Chris@0: return; Chris@0: } Chris@0: Chris@0: $moduleName = reset($nameParts); Chris@0: $expectedStart = strtoupper($moduleName); Chris@0: // Remove the quotes around the string litral. Chris@0: $constant = substr($tokens[$argument['start']]['content'], 1, -1); Chris@0: if (strpos($constant, $expectedStart) !== 0) { Chris@0: $warning = 'All constants defined by a module must be prefixed with the module\'s name, expected "%s" but found "%s"'; Chris@0: $data = array( Chris@0: $expectedStart."_$constant", Chris@0: $constant, Chris@0: ); Chris@0: $phpcsFile->addWarning($warning, $stackPtr, 'ConstantStart', $data); Chris@0: } Chris@0: Chris@0: }//end processFunctionCall() Chris@0: Chris@0: Chris@0: }//end class