当前位置: 首页>>代码示例>>PHP>>正文


PHP PHP_CodeSniffer::isUnderscoreName方法代码示例

本文整理汇总了PHP中PHP_CodeSniffer::isUnderscoreName方法的典型用法代码示例。如果您正苦于以下问题:PHP PHP_CodeSniffer::isUnderscoreName方法的具体用法?PHP PHP_CodeSniffer::isUnderscoreName怎么用?PHP PHP_CodeSniffer::isUnderscoreName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PHP_CodeSniffer的用法示例。


在下文中一共展示了PHP_CodeSniffer::isUnderscoreName方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: process

 public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
 {
     $tokens = $phpcsFile->getTokens();
     if (empty($tokens[$stackPtr]['conditions']) === true) {
         $functionName = $phpcsFile->getDeclarationName($stackPtr);
         if (false === strpos($phpcsFile->getFilename(), 'helper')) {
             $error = 'Defining functions is NOT permitted expecting helper functions.';
             $phpcsFile->addError($error, $stackPtr);
         }
         if (!PHP_CodeSniffer::isUnderscoreName($functionName)) {
             $error = 'Function name must use underscores in accordance.' . $functionName;
             $phpcsFile->addError($error, $stackPtr);
         }
     }
 }
开发者ID:te-koyama,项目名称:openpne,代码行数:15,代码来源:GlobalFunctionSniff.php

示例2: processPackage

 /**
  * Process the package tag.
  *
  * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
  * @param array $tags The tokens for these tags.
  *
  */
 protected function processPackage(PHP_CodeSniffer_File $phpcsFile, array $tags)
 {
     $tokens = $phpcsFile->getTokens();
     foreach ($tags as $tag) {
         if ($tokens[$tag + 2]['code'] !== T_DOC_COMMENT_STRING) {
             // No content.
             continue;
         }
         $namespace = $this->extractNamespace($phpcsFile);
         $content = $tokens[$tag + 2]['content'];
         if ($namespace !== $content) {
             $phpcsFile->addError('Package name "%s" should be "%s"', $tag, 'InvalidPackage', [$content, $namespace]);
             continue;
         }
         if (PHP_CodeSniffer::isUnderscoreName($content) === true) {
             continue;
         }
         $newContent = str_replace(' ', '_', $content);
         $newContent = trim($newContent, '_');
         $newContent = preg_replace('/[^A-Za-z_]/', '', $newContent);
         $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 = 'Package name "%s" is not valid; consider "%s" instead';
         $validName = trim($newName, '_');
         $data = [$content, $validName];
         $phpcsFile->addError($error, $tag, 'InvalidPackage', $data);
     }
 }
开发者ID:MarkVaughn,项目名称:standard,代码行数:41,代码来源:ClassCommentSniff.php

示例3: processSubpackage

 /**
  * Process the subpackage tag.
  *
  * @param int $errorPos The line number where the error occurs.
  *
  * @return void
  */
 protected function processSubpackage($errorPos)
 {
     $package = $this->commentParser->getSubpackage();
     if ($package !== null) {
         $content = $package->getContent();
         if ($content !== '') {
             if (PHP_CodeSniffer::isUnderscoreName($content) !== true) {
                 $newContent = str_replace(' ', '_', $content);
                 $nameBits = explode('_', $newContent);
                 $firstBit = array_shift($nameBits);
                 $newName = strtoupper($firstBit[0]) . substr($firstBit, 1) . '_';
                 foreach ($nameBits as $bit) {
                     $newName .= strtoupper($bit[0]) . substr($bit, 1) . '_';
                 }
                 $validName = trim($newName, '_');
                 $error = "Subpackage name \"{$content}\" is not valid; consider \"{$validName}\" instead";
                 $this->currentFile->addError($error, $errorPos);
             }
         } else {
             $error = '@subpackage tag must contain a name';
             $this->currentFile->addError($error, $errorPos);
         }
     }
 }
开发者ID:Weltraumschaf,项目名称:SxsCs,代码行数:31,代码来源:FileCommentSniff.php

示例4: processSubpackage

 /**
  * 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(PHP_CodeSniffer_File $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 (PHP_CodeSniffer::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
 }
开发者ID:ppwalks33,项目名称:cleansure,代码行数:36,代码来源:FileCommentSniff.php

示例5: processSubpackage

 /**
  * The subpackage name must be camel-cased.
  *
  * @param int $errorPos The line number where the error occurs.
  *
  * @return void
  */
 protected function processSubpackage($errorPos)
 {
     $subpackage = $this->commentParser->getSubpackage();
     if ($subpackage !== null) {
         $content = $subpackage->getContent();
         if (empty($content) === true) {
             $error = 'Content missing for @subpackage tag in file comment';
             $this->currentFile->addError($error, $errorPos);
         } else {
             if (PHP_CodeSniffer::isUnderscoreName($content) !== true) {
                 // Subpackage name must be properly camel-cased.
                 $nameBits = explode('_', $content);
                 $firstBit = array_shift($nameBits);
                 $newName = strtoupper($firstBit[0]) . substr($firstBit, 1) . '_';
                 foreach ($nameBits as $bit) {
                     $newName .= strtoupper($bit[0]) . substr($bit, 1) . '_';
                 }
                 $validName = trim($newName, '_');
                 $error = "Subpackage name \"{$content}\" is not valid; ";
                 $error .= "consider \"{$validName}\" instead";
                 $this->currentFile->addError($error, $errorPos);
             }
         }
     }
 }
开发者ID:josephj,项目名称:modev,代码行数:32,代码来源:FileCommentSniff.php

示例6: processSubpackage

 /**
  * Process the subpackage tag.
  *
  * @param int $errorPos The line number where the error occurs.
  *
  * @return void
  */
 protected function processSubpackage($errorPos)
 {
     $package = $this->commentParser->getSubpackage();
     if ($package !== null) {
         $content = $package->getContent();
         if ($content !== '') {
             if (PHP_CodeSniffer::isUnderscoreName($content) !== true) {
                 //                    $newContent = str_replace(' ', '_', $content);
                 //                    $nameBits   = explode('_', $newContent);
                 //                    $firstBit   = array_shift($nameBits);
                 //                    $newName    = strtoupper($firstBit{0}).substr($firstBit, 1).'_';
                 //                    foreach ($nameBits as $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,
                 //                                 );
                 //                    $this->currentFile->addError($error, $errorPos, 'InvalidSubpackage', $data);
             }
         } else {
             $error = '@subpackage tag must contain a name';
             $this->currentFile->addError($error, $errorPos, 'EmptySubpackage');
         }
     }
 }
开发者ID:ventoviro,项目名称:coding-standards,代码行数:36,代码来源:FileCommentSniff.php

示例7: processSubpackage

	/**
	 * Process the subpackage tag.
	 *
	 * @param int $errorPos The line number where the error occurs.
	 *
	 * @return void
	 */
	protected function processSubpackage($errorPos)
	{
		$package = $this->commentParser->getSubpackage();
		if ($package !== null) {
			$content = $package->getContent();
			if ($content !== '') {
				if (PHP_CodeSniffer::isUnderscoreName($content) !== true) {
					// Ignore..
				}
			} else {
				$error = '@subpackage tag must contain a name';
				$this->currentFile->addError($error, $errorPos);
			}
		}

	}//end processSubpackage()
开发者ID:ro-ka,项目名称:Elastica,代码行数:23,代码来源:FileCommentSniff.php

示例8: checkSubpackage

 /**
  * check subpackage tag
  *
  * @param   string	  $content Tag content
  * @access  protected
  * @return  array
  * @since   1.0.0
  */
 protected function checkSubpackage($content)
 {
     $result = array(true, $content);
     if (PHP_CodeSniffer::isUnderscoreName($content) !== true) {
         $result = array(false, $this->sanitazeUnderscoreName($content));
     }
     return $result;
 }
开发者ID:kingsj,项目名称:core,代码行数:16,代码来源:TagsSniff.php

示例9: getUses

 /**
  * Process the depreciated tag
  *
  * @return void
  */
 public function getUses()
 {
     $uses = $this->commentParser->getUses();
     if ($uses !== null) {
         foreach ($uses as $use) {
             $content = $use->getContent();
             if ($content !== '') {
                 if (PHP_CodeSniffer::isUnderscoreName($content) !== true) {
                     $newContent = str_replace(' ', '_', $content);
                     $nameBits = explode('_', $newContent);
                     $firstBit = array_shift($nameBits);
                     $newName = strtoupper($firstBit[0]) . substr($firstBit, 1) . '_';
                     foreach ($nameBits as $bit) {
                         $newName .= strtoupper($bit[0]) . substr($bit, 1) . '_';
                     }
                     $validName = trim($newName, '_');
                     $error = "34Uses name \"{$content}\" is not valid; consider \"{$validName}\" instead";
                     $this->currentFile->addError($error, $errorPos, 'UsesNameClassComment');
                 }
             } else {
                 $error = '35@uses tag must contain a name';
                 $this->currentFile->addError($error, $errorPos, 'UsesTagMustContainNameClassComment');
             }
         }
     }
 }
开发者ID:proofek,项目名称:SQLI_CodeSniffer,代码行数:31,代码来源:ClassCommentSniff.php


注:本文中的PHP_CodeSniffer::isUnderscoreName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。