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


PHP XHPASTNode::getChildByIndex方法代码示例

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


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

示例1: isInAnonymousFunction

 private function isInAnonymousFunction(XHPASTNode $node)
 {
     while ($node) {
         if ($node->getTypeName() == 'n_FUNCTION_DECLARATION' && $node->getChildByIndex(2)->getTypeName() == 'n_EMPTY') {
             return true;
         }
         $node = $node->getParentNode();
     }
 }
开发者ID:milindc2031,项目名称:Test,代码行数:9,代码来源:ArcanistUnexpectedReturnValueXHPASTLinterRule.php

示例2: getModifiers

 /**
  * Get class/method modifiers.
  *
  * @param  XHPASTNode         A node of type `n_CLASS_DECLARATION` or
  *                            `n_METHOD_DECLARATION`.
  * @return map<string, bool>  Class/method modifiers.
  */
 protected final function getModifiers(XHPASTNode $node)
 {
     $modifier_list = $node->getChildByIndex(0);
     switch ($modifier_list->getTypeName()) {
         case 'n_CLASS_ATTRIBUTES':
         case 'n_CLASS_MEMBER_MODIFIER_LIST':
         case 'n_METHOD_MODIFIER_LIST':
             break;
         default:
             return array();
     }
     $modifiers = array();
     foreach ($modifier_list->selectDescendantsOfType('n_STRING') as $modifier) {
         $modifiers[strtolower($modifier->getConcreteString())] = true;
     }
     return $modifiers;
 }
开发者ID:barcelonascience,项目名称:arcanist,代码行数:24,代码来源:ArcanistXHPASTLinterRule.php

示例3: analyze_phutil_require_module

/**
 * Parses meaning from calls to phutil_require_module() in __init__.php files.
 *
 * @group module
 */
function analyze_phutil_require_module(XHPASTNode $call, PhutilModuleRequirements $requirements, $create_dependency)
{
    $name = $call->getChildByIndex(0);
    $params = $call->getChildByIndex(1)->getChildren();
    if (count($params) !== 2) {
        $requirements->addLint($call, $call->getConcreteString(), ArcanistPhutilModuleLinter::LINT_ANALYZER_SIGNATURE, "Call to phutil_require_module() must have exactly two arguments.");
        return;
    }
    $module_param = array_pop($params);
    $library_param = array_pop($params);
    $library_value = $library_param->getStringLiteralValue();
    if ($library_value === null) {
        $requirements->addLint($library_param, $library_param->getConcreteString(), ArcanistPhutilModuleLinter::LINT_ANALYZER_SIGNATURE, "phutil_require_module() parameters must be string literals.");
        return;
    }
    $module_value = $module_param->getStringLiteralValue();
    if ($module_value === null) {
        $requirements->addLint($module_param, $module_param->getConcreteString(), ArcanistPhutilModuleLinter::LINT_ANALYZER_SIGNATURE, "phutil_require_module() parameters must be string literals.");
        return;
    }
    if ($create_dependency) {
        $requirements->addModuleDependency($name, $library_value . ':' . $module_value);
    }
}
开发者ID:nik-kor,项目名称:arcanist,代码行数:29,代码来源:phutil_analyzer.php

示例4: parseReturnType

 private function parseReturnType(DivinerAtom $atom, XHPASTNode $decl)
 {
     $return_spec = array();
     $metadata = $atom->getDocblockMeta();
     $return = idx($metadata, 'return');
     $type = null;
     $docs = null;
     if (!$return) {
         $return = idx($metadata, 'returns');
         if ($return) {
             $atom->addWarning(pht('Documentation uses `%s`, but should use `%s`.', '@returns', '@return'));
         }
     }
     $return = (array) $return;
     if (count($return) > 1) {
         $atom->addWarning(pht('Documentation specifies `%s` multiple times.', '@return'));
     }
     $return = head($return);
     if ($atom->getName() == '__construct' && $atom->getType() == 'method') {
         $return_spec = array('doctype' => 'this', 'docs' => '//Implicit.//');
         if ($return) {
             $atom->addWarning(pht('Method `%s` has explicitly documented `%s`. The `%s` method ' . 'always returns `%s`. Diviner documents this implicitly.', '__construct()', '@return', '__construct()', '$this'));
         }
     } else {
         if ($return) {
             $split = preg_split('/(?<!,)\\s+/', trim($return), 2);
             if (!empty($split[0])) {
                 $type = $split[0];
             }
             if ($decl->getChildByIndex(1)->getTypeName() == 'n_REFERENCE') {
                 $type = $type . ' &';
             }
             if (!empty($split[1])) {
                 $docs = $split[1];
             }
             $return_spec = array('doctype' => $type, 'docs' => $docs);
         } else {
             $return_spec = array('type' => 'wild');
         }
     }
     $atom->setProperty('return', $return_spec);
 }
开发者ID:endlessm,项目名称:phabricator,代码行数:42,代码来源:DivinerPHPAtomizer.php

示例5: parseReturnType

 private function parseReturnType(DivinerAtom $atom, XHPASTNode $decl)
 {
     $return_spec = array();
     $metadata = $atom->getDocblockMeta();
     $return = idx($metadata, 'return');
     if (!$return) {
         $return = idx($metadata, 'returns');
         if ($return) {
             $atom->addWarning(pht('Documentation uses `@returns`, but should use `@return`.'));
         }
     }
     if ($atom->getName() == '__construct' && $atom->getType() == 'method') {
         $return_spec = array('doctype' => 'this', 'docs' => '//Implicit.//');
         if ($return) {
             $atom->addWarning('Method __construct() has explicitly documented @return. The ' . '__construct() method always returns $this. Diviner documents ' . 'this implicitly.');
         }
     } else {
         if ($return) {
             $split = preg_split('/\\s+/', trim($return), $limit = 2);
             if (!empty($split[0])) {
                 $type = $split[0];
             }
             if ($decl->getChildByIndex(1)->getTypeName() == 'n_REFERENCE') {
                 $type = $type . ' &';
             }
             $docs = null;
             if (!empty($split[1])) {
                 $docs = $split[1];
             }
             $return_spec = array('doctype' => $type, 'docs' => $docs);
         } else {
             $return_spec = array('type' => 'wild');
         }
     }
     $atom->setProperty('return', $return_spec);
 }
开发者ID:denghp,项目名称:phabricator,代码行数:36,代码来源:DivinerPHPAtomizer.php


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