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


PHP XHPASTNode::getTokens方法代码示例

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


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

示例1: process

 public function process(XHPASTNode $root)
 {
     $tokens = $root->getTokens();
     foreach ($tokens as $token) {
         if ($token->getTypeName() === 'T_OPEN_TAG_WITH_ECHO') {
             $this->raiseLintAtToken($token, pht('Avoid the PHP echo short form, "%s".', '<?='));
         }
     }
 }
开发者ID:lewisf,项目名称:arcanist,代码行数:9,代码来源:ArcanistPHPEchoTagXHPASTLinterRule.php

示例2: process

 public function process(XHPASTNode $root)
 {
     $tokens = $root->getTokens();
     foreach ($tokens as $token) {
         if ($token->getTypeName() === 'T_OPEN_TAG') {
             if (trim($token->getValue()) === '<?') {
                 $this->raiseLintAtToken($token, pht('Use the full form of the PHP open tag, "%s".', '<?php'), "<?php\n");
             }
             break;
         }
     }
 }
开发者ID:lewisf,项目名称:arcanist,代码行数:12,代码来源:ArcanistPHPShortTagXHPASTLinterRule.php

示例3: process

 public function process(XHPASTNode $root)
 {
     $tokens = $root->getTokens();
     foreach ($tokens as $token) {
         switch ($token->getTypeName()) {
             case 'T_OPEN_TAG':
             case 'T_CLOSE_TAG':
             case 'T_WHITESPACE':
                 break;
             default:
                 return;
         }
     }
     $this->raiseLintAtPath(pht("Empty files usually don't serve any useful purpose."));
 }
开发者ID:milindc2031,项目名称:Test,代码行数:15,代码来源:ArcanistEmptyFileXHPASTLinterRule.php

示例4: process

 public function process(XHPASTNode $root)
 {
     $tokens = $root->getTokens();
     foreach ($tokens as $token) {
         if ($token->getTypeName() === 'T_OPEN_TAG') {
             break;
         } else {
             if ($token->getTypeName() === 'T_OPEN_TAG_WITH_ECHO') {
                 break;
             } else {
                 if (!preg_match('/^#!/', $token->getValue())) {
                     $this->raiseLintAtToken($token, pht('PHP files should start with `%s`, which may be preceded by ' . 'a `%s` line for scripts.', '<?php', '#!'));
                 }
                 break;
             }
         }
     }
 }
开发者ID:barcelonascience,项目名称:arcanist,代码行数:18,代码来源:ArcanistPHPOpenTagXHPASTLinterRule.php

示例5: process

 public function process(XHPASTNode $root)
 {
     foreach ($root->getTokens() as $id => $token) {
         switch ($token->getTypeName()) {
             case 'T_IF':
             case 'T_ELSE':
             case 'T_FOR':
             case 'T_FOREACH':
             case 'T_WHILE':
             case 'T_DO':
             case 'T_SWITCH':
             case 'T_CATCH':
                 $after = $token->getNonsemanticTokensAfter();
                 if (empty($after)) {
                     $this->raiseLintAtToken($token, pht('Convention: put a space after control statements.'), $token->getValue() . ' ');
                 } else {
                     if (count($after) === 1) {
                         $space = head($after);
                         // If we have an else clause with braces, $space may not be
                         // a single white space. e.g.,
                         //
                         //   if ($x)
                         //     echo 'foo'
                         //   else          // <- $space is not " " but "\n  ".
                         //     echo 'bar'
                         //
                         // We just require it starts with either a whitespace or a newline.
                         if ($token->getTypeName() === 'T_ELSE' || $token->getTypeName() === 'T_DO') {
                             break;
                         }
                         if ($space->isAnyWhitespace() && $space->getValue() !== ' ') {
                             $this->raiseLintAtToken($space, pht('Convention: put a single space after control statements.'), ' ');
                         }
                     }
                 }
                 break;
         }
     }
 }
开发者ID:barcelonascience,项目名称:arcanist,代码行数:39,代码来源:ArcanistControlStatementSpacingXHPASTLinterRule.php

示例6: findAtomDocblock

 private function findAtomDocblock(DivinerAtom $atom, XHPASTNode $node)
 {
     $token = $node->getDocblockToken();
     if ($token) {
         $atom->setDocblockRaw($token->getValue());
         return true;
     } else {
         $tokens = $node->getTokens();
         if ($tokens) {
             $prev = head($tokens);
             while ($prev = $prev->getPrevToken()) {
                 if ($prev->isAnyWhitespace()) {
                     continue;
                 }
                 break;
             }
             if ($prev && $prev->isComment()) {
                 $value = $prev->getValue();
                 $matches = null;
                 if (preg_match('/@(return|param|task|author)/', $value, $matches)) {
                     $atom->addWarning(pht('Atom "%s" is preceded by a comment containing `%s`, but ' . 'the comment is not a documentation comment. Documentation ' . 'comments must begin with `%s`, followed by a newline. Did ' . 'you mean to use a documentation comment? (As the comment is ' . 'not a documentation comment, it will be ignored.)', $atom->getName(), '@' . $matches[1], '/**'));
                 }
             }
         }
         $atom->setDocblockRaw('');
         return false;
     }
 }
开发者ID:endlessm,项目名称:phabricator,代码行数:28,代码来源:DivinerPHPAtomizer.php


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