src/Visitor/ReflectionVisitor.php
private function isInsideFunction(Node $node): bool
    {
        if (!$node->hasAttribute(ParentConnectorVisitor::PARENT_KEY)) {
            return false;
        }

        $parent = $node->getAttribute(ParentConnectorVisitor::PARENT_KEY);

        if ($parent->getAttribute(self::IS_INSIDE_FUNCTION_KEY)) {
            return true;
        }

        if ($this->isFunctionLikeNode($parent)) {
            return true;
        }

        return $this->isInsideFunction($parent);
    }
private function isInsideFunction(Node $node): bool
    {
        if (!$node->hasAttribute(ParentConnectorVisitor::PARENT_KEY)) {
            return false;
        }

        $parent = $node->getAttribute(ParentConnectorVisitor::PARENT_KEY);

        if ($parent->getAttribute(self::IS_INSIDE_FUNCTION_KEY)) {
            return true;
        }

        if ($this->isFunctionLikeNode($parent)) {
            return true;
        }

        return $this->isInsideFunction($parent);
    }
private function isInsideFunction ( Node $ node ) : bool { if ( ! $ node -> hasAttribute ( ParentConnectorVisitor :: PARENT_KEY ) ) { return false ; } $ parent = $ node -> getAttribute ( ParentConnectorVisitor :: PARENT_KEY ) ; if ( $ parent -> getAttribute ( self :: IS_INSIDE_FUNCTION_KEY ) ) { return true ; } if ( $ this -> isFunctionLikeNode ( $ parent ) ) { return true ; } return $ this -> isInsideFunction ( $ parent ) ; }
Recursively determine whether the node is inside the function
Recursively determine whether the node is inside the function