Phan\Analysis\PreOrderAnalysisVisitor::visitCatch PHP Метод

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

public visitCatch ( 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 visitCatch(Node $node) : Context
    {
        try {
            $union_type = UnionTypeVisitor::unionTypeFromClassNode($this->code_base, $this->context, $node->children['class']);
            $class_list = (new ContextNode($this->code_base, $this->context, $node->children['class']))->getClassList();
            foreach ($class_list as $class) {
                $class->addReference($this->context);
            }
        } catch (CodeBaseException $exception) {
            $this->emitIssue(Issue::UndeclaredClassCatch, $node->lineno ?? 0, (string) $exception->getFQSEN());
        }
        $variable_name = (new ContextNode($this->code_base, $this->context, $node->children['var']))->getVariableName();
        if (!empty($variable_name)) {
            $variable = Variable::fromNodeInContext($node->children['var'], $this->context, $this->code_base, false);
            if (!$union_type->isEmpty()) {
                $variable->setUnionType($union_type);
            }
            $this->context->addScopeVariable($variable);
        }
        return $this->context;
    }