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


PHP UnionType::genericArrayElementTypes方法代码示例

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


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

示例1: visitList

 /**
  * @param Node $node
  * A node to parse
  *
  * @return Context
  * A new or an unchanged context resulting from
  * parsing the node
  */
 public function visitList(Node $node) : Context
 {
     // Figure out the type of elements in the list
     $element_type = $this->right_type->genericArrayElementTypes();
     foreach ($node->children ?? [] as $child_node) {
         // Some times folks like to pass a null to
         // a list to throw the element away. I'm not
         // here to judge.
         if (!$child_node instanceof Node) {
             continue;
         }
         $variable = Variable::fromNodeInContext($child_node, $this->context, $this->code_base, false);
         // Set the element type on each element of
         // the list
         $variable->setUnionType($element_type);
         // Note that we're not creating a new scope, just
         // adding variables to the existing scope
         $this->context->addScopeVariable($variable);
     }
     return $this->context;
 }
开发者ID:ablyler,项目名称:phan,代码行数:29,代码来源:AssignmentVisitor.php

示例2: visitList

 /**
  * @param Node $node
  * A node to parse
  *
  * @return Context
  * A new or an unchanged context resulting from
  * parsing the node
  */
 public function visitList(Node $node) : Context
 {
     // Figure out the type of elements in the list
     $element_type = $this->right_type->genericArrayElementTypes();
     foreach ($node->children ?? [] as $child_node) {
         // Some times folks like to pass a null to
         // a list to throw the element away. I'm not
         // here to judge.
         if (!$child_node instanceof Node) {
             continue;
         }
         if ($child_node->kind == \ast\AST_VAR) {
             $variable = Variable::fromNodeInContext($child_node, $this->context, $this->code_base, false);
             // Set the element type on each element of
             // the list
             $variable->setUnionType($element_type);
             // Note that we're not creating a new scope, just
             // adding variables to the existing scope
             $this->context->addScopeVariable($variable);
         } else {
             if ($child_node->kind == \ast\AST_PROP) {
                 try {
                     $property = (new ContextNode($this->code_base, $this->context, $child_node))->getProperty($child_node->children['prop']);
                     // Set the element type on each element of
                     // the list
                     $property->setUnionType($element_type);
                 } catch (UnanalyzableException $exception) {
                     // Ignore it. There's nothing we can do.
                 } catch (NodeException $exception) {
                     // Ignore it. There's nothing we can do.
                 } catch (IssueException $exception) {
                     Issue::maybeEmitInstance($this->code_base, $this->context, $exception->getIssueInstance());
                     return $this->context;
                 }
             }
         }
     }
     return $this->context;
 }
开发者ID:etsy,项目名称:phan,代码行数:47,代码来源:AssignmentVisitor.php


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