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


PHP PHP_CodeSniffer_File::getClassProperties方法代码示例

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


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

示例1: process

 /**
  * Processes this test, when one of its tokens is encountered.
  *
  * @param PHP_CodeSniffer_File $phpcsFile The current file being processed.
  * @param int                  $stackPtr  The position of the current token
  *                                        in the stack passed in $tokens.
  *
  * @return void
  */
 public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
 {
     $tokens = $phpcsFile->getTokens();
     $className = $phpcsFile->findNext(T_STRING, $stackPtr);
     $name = trim($tokens[$className]['content']);
     $errorData = array(ucfirst($tokens[$stackPtr]['content']));
     $classProperties = $phpcsFile->getClassProperties($stackPtr);
     $startsWithAbstract = substr($name, 0, 8) == 'Abstract';
     if ($classProperties['is_abstract'] && !$startsWithAbstract) {
         $error = '%s name must begin with "Abstract"';
         $phpcsFile->addError($error, $stackPtr, 'StartWithAbstract', $errorData);
     }
     if (!$classProperties['is_abstract'] && $startsWithAbstract) {
         $error = '%s name must not begin with "Abstract"';
         $phpcsFile->addError($error, $stackPtr, 'StartNotWithAbstract', $errorData);
     }
 }
开发者ID:mybb,项目名称:standards,代码行数:26,代码来源:AbstractClassConventionSniff.php

示例2: process

 /**
  * Processes this test, when one of its tokens is encountered.
  *
  * @param PHP_CodeSniffer_File $phpcsFile All the tokens found in the document.
  * @param int                  $stackPtr  The position of the current token in the stack passed in $tokens.
  *
  * @return void
  */
 public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
 {
     $properties = $phpcsFile->getClassProperties($stackPtr);
     if (!$properties['is_abstract']) {
         return;
     }
     $tokens = $phpcsFile->getTokens();
     $line = $tokens[$stackPtr]['line'];
     while ($tokens[$stackPtr]['line'] == $line) {
         if ('T_STRING' == $tokens[$stackPtr]['type']) {
             if (substr($tokens[$stackPtr]['content'], 0, 8) != 'Abstract') {
                 $phpcsFile->addError('Class name is not prefixed with "Abstract"', $stackPtr);
             }
             break;
         }
         $stackPtr++;
     }
 }
开发者ID:kewlar,项目名称:ongr-strict-standard,代码行数:26,代码来源:AbstractClassPrefixSniff.php


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