Phan\Parse\ParseVisitor::visitReturn PHP Метод

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

Visit a node with kind \ast\AST_RETURN
public visitReturn ( 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 visitReturn(Node $node) : Context
    {
        if (Config::get()->backward_compatibility_checks) {
            (new ContextNode($this->code_base, $this->context, $node))->analyzeBackwardCompatibility();
        }
        // Make sure we're actually returning from a method.
        if (!$this->context->isInFunctionLikeScope()) {
            return $this->context;
        }
        // Get the method/function/closure we're in
        $method = $this->context->getFunctionLikeInScope($this->code_base);
        assert(!empty($method), "We're supposed to be in either method or closure scope.");
        // Mark the method as returning something
        $method->setHasReturn(($node->children['expr'] ?? null) !== null);
        return $this->context;
    }