Phan\Analysis\AssignmentVisitor::visitList PHP Метод

visitList() публичный Метод

public visitList ( ast\Node $node ) : Context
$node ast\Node A node to parse
Результат Phan\Language\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;
    }