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


PHP PHP_CodeSniffer_File::getmethodproperties方法代码示例

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


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

示例1: processtokenwithinscope

 /**
  * Processes the tokens within the scope.
  *
  * @param PHP_CodeSniffer_File $phpcsfile The file being processed.
  * @param int                  $stackptr  The position where this token was
  *                                        found.
  * @param int                  $currscope The position of the current scope.
  *
  * @return void
  */
 protected function processtokenwithinscope(PHP_CodeSniffer_File $phpcsfile, $stackptr, $currscope)
 {
     $classname = $phpcsfile->getdeclarationname($currscope);
     $methodname = $phpcsfile->getdeclarationname($stackptr);
     // Is this a magic method. IE. is prefixed with "__".
     if (preg_match('|^__|', $methodname) !== 0) {
         $magicpart = substr($methodname, 2);
         if (in_array($magicpart, $this->_magicmethods) === false) {
             $error = "method name \"{$classname}::{$methodname}\" is invalid; " . 'only PHP magic methods should be prefixed with a double underscore';
             $phpcsfile->adderror($error, $stackptr);
         }
         return;
     }
     // PHP4 constructors are allowed to break our rules.
     if ($methodname === $classname) {
         return;
     }
     // PHP4 destructors are allowed to break our rules.
     if ($methodname === '_' . $classname) {
         return;
     }
     $methodprops = $phpcsfile->getmethodproperties($stackptr);
     $ispublic = $methodprops['scope'] === 'private' ? false : true;
     $scope = $methodprops['scope'];
     $scopespecified = $methodprops['scope_specified'];
     // Only lower-case accepted
     if (preg_match('/[A-Z]+/', $methodname)) {
         if ($scopespecified === true) {
             $error = ucfirst($scope) . " method name \"{$classname}::{$methodname}\" must be in lower-case letters only";
         } else {
             $error = "method name \"{$classname}::{$methodname}\" must be in lower-case letters only";
         }
         $phpcsfile->adderror($error, $stackptr);
         return;
     }
     // No numbers accepted
     if (preg_match('/[0-9]+/', $methodname)) {
         if ($scopespecified === true) {
             $error = ucfirst($scope) . " method name \"{$classname}::{$methodname}\" must only contain letters";
         } else {
             $error = "Method name \"{$classname}::{$methodname}\" must only contain letters";
         }
         $phpcsfile->adderror($error, $stackptr);
         return;
     }
 }
开发者ID:vuchannguyen,项目名称:web,代码行数:56,代码来源:ValidFunctionNameSniff.php


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