@param AbstractNode $node

@return QueryBuilderInterface

@throws \Exception
769594
public function addToArrayNode(AbstractNode $node): QueryBuilderInterface
    {
        if (!$this->node instanceof ArrayNode) {
            throw new \Exception(sprintf('You cannot call %s on node type: %s', __FUNCTION__, get_class($this->node)));
        }

        $this->node->add($node);
        $this->reassignParent($node);

        return $this;
    }
255460
public function apply(AbstractNode $node)
    {
        if (preg_match('([A-Za-z0-9]+Bridge$)', $node->getName()) === 0) {
            return;
        }

        $this->verifyClass($node);
        $this->verifyInterface($node);
    }
525939
public function removeNode(AbstractNode $node) {
        if (true === array_key_exists($node->id, $this->index)) {
            unset($this->nodes[$this->index[$node->id]]);
            unset($this->index[$node->id]);
            $node->parent = null;
        }
        return $this;
    }
792380
public function apply(AbstractNode $node)
    {
        if (preg_match('([A-Za-z0-9]+Bridge$)', $node->getName()) === 0 ||
            preg_match('#.*\\\\Dependency\\\\.*#', $node->getNamespaceName()) === 0) {
            return;
        }

        preg_match('#(?<moduleName>[\w]+)\\\\Dependency\\\\(?<layerName>[\w]+)#is', $node->getNamespaceName(), $namespaceParts);

        $this->verifyClass($node, $namespaceParts);
        $this->verifyInterface($node, $namespaceParts);
    }
163712
public function getLastChild(AbstractNestedNode $node)
    {
        $children = $this->getDescendants($node, 1);
        if (0 < count($children)) {
            return $children[count($children) - 1];
        }

        return;
    }
359897
protected function extendsAbstractPlugin(AbstractNode $node): bool
    {
        if (!($this instanceof ClassAware)) {
            return false;
        }

        $parentClass = $this->getAstClass($node)->getParentClass();

        if (!($parentClass instanceof ASTClass)) {
            return false;
        }

        if ($parentClass->getName() === static::EXTENDS_CLASS_NAME) {
            return true;
        }

        return false;
    }
18803
public function getClosestDocument(NodeInterface $node)
    {
        if ($node->getNodeType()->isOfType('Neos.Neos:Document')) {
            return $node;
        }

        $flowQuery = new FlowQuery([$node]);

        return $flowQuery->closest('[instanceof Neos.Neos:Document]')->get(0);
    }
1129643
public function apply(AbstractNode $node): void
    {
        if (!$this->isPlugin($node)) {
            return;
        }

        $className = $node->getName();
        $suffix = substr($className, -strlen(static::EXPECTED_INTERFACE_NAME_SUFFIX));
        if ($suffix !== static::EXPECTED_INTERFACE_NAME_SUFFIX) {
            $this->addViolation($node, [$node->getName()]);
        }
    }
1267186
protected function verifyClass(AbstractNode $node): void
    {
        if (preg_match('#.*\\\\Dependency\\\\.*#', $node->getNamespaceName()) !== 0) {
            return;
        }

        $message = sprintf(
            'The bridge is not lie in "Dependency" folder. That violates the rule "%s"',
            static::CLASS_RULE
        );
        $this->addViolation($node, [$message]);
    }
390815
public function apply(AbstractNode $node): void
    {
        if (!$this->isPlugin($node)) {
            return;
        }

        $classNodeInterfaces = $node->getInterfaces();

        if (!$classNodeInterfaces->count()) {
            $message = sprintf(
                'The Plugin `%s` doesn\'t have any interfaces.',
                $node->getName()
            );
            $this->addViolation($node, [$message]);

            return;
        }

        $firstInterface = $classNodeInterfaces[0];

        if ($firstInterface === null) {
            return;
        }

        $interfaceReflection = new ReflectionClass($firstInterface->getNamespacedName());

        $this->verifyInterface($node, $interfaceReflection);
    }
127713
public function dispatch(AbstractNode $node)
    {
        $methodName = sprintf('walk%s', $node->getName());

        if (!method_exists($this, $methodName)) {
            throw new InvalidArgumentException(sprintf(
                'Do not know how to walk node of type "%s"',
                $node->getName()
            ));
        }

        return $this->$methodName($node);
    }
781622
public function apply(AbstractNode $node)
    {
        if (preg_match('([A-Za-z0-9]+Constants$)', $node->getName()) === 0) {
            return;
        }

        foreach ($node->getMethods() as $method) {
            $this->addViolation(
                $node,
                [
                    sprintf(
                        'Interface %s defines a method %s() which violates rule "%s"',
                        $node->getFullQualifiedName(),
                        $method->getName(),
                        static::RULE
                    ),
                ]
            );
        }
    }
444181
public function end(): QueryBuilderInterface
    {
        if (null === $this->node = $this->node->getParent()) {
            throw new \Exception(sprintf('You cannot call %s on main node', __FUNCTION__));
        }

        return $this;
    }
1150935
public function apply(AbstractNode $node): void
    {
        if (!$this->isPlugin($node)) {
            return;
        }

        $className = $node->getName();

        if (!$this->isSuffixValid($className)) {
            $this->addViolation($node, [$node->getName()]);
        }
    }
551708
public function apply(AbstractNode $node): void
    {
        if (!$this->isFacade($node)) {
            return;
        }

        $this->applyRule($node);
    }
987832
public function apply(AbstractNode $node)
    {
        if (!$this->isDependencyProvider($node, 'Zed')) {
            return;
        }

        $this->applyRule($node, $this->allowedProvideMethodNames);
    }
162065
public function addNode(AbstractNode $node) {
        $node->parent           = $this;
        $this->index[$node->id] = count($this->nodes);
        $this->nodes[]          = $node;
        return $this;
    }