Example #1
0
 /**
  * Process the subpackage tag.
  *
  * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
  * @param array                $tags      The tokens for these tags.
  *
  * @return void
  */
 protected function processSubpackage($phpcsFile, array $tags)
 {
     $tokens = $phpcsFile->getTokens();
     foreach ($tags as $tag) {
         if ($tokens[$tag + 2]['code'] !== T_DOC_COMMENT_STRING) {
             // No content.
             continue;
         }
         $content = $tokens[$tag + 2]['content'];
         if (Common::isUnderscoreName($content) === true) {
             continue;
         }
         $newContent = str_replace(' ', '_', $content);
         $nameBits = explode('_', $newContent);
         $firstBit = array_shift($nameBits);
         $newName = strtoupper($firstBit[0]) . substr($firstBit, 1) . '_';
         foreach ($nameBits as $bit) {
             if ($bit !== '') {
                 $newName .= strtoupper($bit[0]) . substr($bit, 1) . '_';
             }
         }
         $error = 'Subpackage name "%s" is not valid; consider "%s" instead';
         $validName = trim($newName, '_');
         $data = array($content, $validName);
         $phpcsFile->addError($error, $tag, 'InvalidSubpackage', $data);
     }
     //end foreach
 }