當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。