本文整理汇总了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".', '<?='));
}
}
}
示例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;
}
}
}
示例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."));
}
示例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;
}
}
}
}
示例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;
}
}