@param \PHPMD\AbstractNode $node

@return bool
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;
    }
1152751
protected function getNextChild(AbstractNode $node, AbstractNode $currentChild)
    {
        try {
            // get next child
            $child = $node->nextChild($currentChild->id());
        } catch (ChildNotFoundException $e) {
            // no more children
            $child = null;
        }

        return $child;
    }
179684
public function delete(AbstractNestedNode $node)
    {
        if (true === $node->isRoot()) {
            return false;
        }

        $this->createQueryBuilder('n')
                ->set('n._parent', 'NULL')
                ->andIsDescendantOf($node)
                ->update()
                ->getQuery()
                ->execute();

        $this->createQueryBuilder('n')
                ->delete()
                ->andIsDescendantOf($node)
                ->getQuery()
                ->execute();

        $this->shiftRlValues($node->getParent(), $node->getLeftnode(), -$node->getWeight());

        return true;
    }
529820
public function isChildOf($node) {
        $result = $this->owner->getAttribute($this->leftAttribute) > $node->getAttribute($this->leftAttribute) && $this->owner->getAttribute($this->rightAttribute) < $node->getAttribute($this->rightAttribute);

        if ($result && $this->treeAttribute !== false) {
            $result = $this->owner->getAttribute($this->treeAttribute) === $node->getAttribute($this->treeAttribute);
        }

        return $result;
    }
903775
private function shouldCheckOption($node): Bool
    {
        if (!$node instanceof Node) {
            return true;
        }
        if ($node->kind === \ast\AST_CONST) {
            return true;
        }
        if ($node->kind === \ast\AST_BINARY_OP && $node->flags === \ast\flags\BINARY_BITWISE_OR) {
            return true;
        }

        return false;
    }
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);
    }
1013120
protected function isEntity(ClassNode $node)
    {
        $docComment = $node->getDocComment();

        if (0 < preg_match($this->getStringProperty('classIsEntityRegex'), $docComment)) {
            return true;
        }

        if (true === $node->isAbstract()) {
            return false;
        }

        if (0 < preg_match($this->getStringProperty('entityRegex'), $docComment)) {
            return true;
        }

        return false;
    }
128719
protected function childbearing(\DOMNode $node)
    {
        if ($node->hasChildNodes())
        {
            foreach ($node->childNodes as $child)
            {
                if ($child->nodeType === XML_ELEMENT_NODE)
                {
                    return true;
                }
            }
        }

        return false;
    }
1156257
public function leaveNode(Node $node)
    {
        if ($node instanceof Class_) {
            $count = \count($this->abstractMethods);
            if ($count > 0 && !$node->isAbstract()) {
                $msg = \sprintf(
                    'Class %s contains %d abstract method%s must therefore be declared abstract or implement the remaining methods (%s)',
                    $node->name,
                    $count,
                    ($count === 1) ? '' : 's',
                    \implode(', ', $this->abstractMethods)
                );
                throw new FatalErrorException($msg, 0, E_ERROR, null, $node->getLine());
            }
        }
    }
55525
public function insert(?IBinaryNode $node) {
        if (!$node instanceof BinaryNode) {
            return false;
        }
        if (null === $this->getRoot()) {
            $this->setRoot($node);
            $this->size++;
            return true;
        }
        /** @var BinaryNode $current */
        $current = $this->getRoot();
        if ($node->getValue() < $current->getValue()) {
            while (null !== $current->getLeft()) {
                $current = $current->getLeft();
            }
            $this->size++;
            $current->setLeft($node);
            return true;
        } else if ($node->getValue() > $current->getValue()) {
            while (null !== $current->getRight()) {
                $current = $current->getRight();
            }
            $current->setRight($node);
            $this->size++;
            return true;
        }
        return false;
    }
475324
public function apply(AbstractNode $node): void
    {
        if (!$this->isPlugin($node)) {
            return;
        }

        $pluginMethods = $node->getMethods();

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

        $className = $node->getName();

        if (!$this->isSuffixValid($className)) {
            $this->addViolation($node, [$node->getName()]);
        }
    }
851685
public function apply(AbstractNode $node)
    {
        $patterns = $this->collectPatterns($node);

        $this->applyPatterns($node, $patterns);

        /** @var \PHPMD\Node\AbstractTypeNode $node */
        foreach ($node->getMethods() as $method) {
            $this->applyPatterns(
                $method,
                $patterns
            );
        }
    }
228738
public function apply(AbstractNode $node)
    {
        if (preg_match('#[A-Za-z0-9]+Constants$#', $node->getName()) === 0 ||
            preg_match('#\\\\Shared\\\\#', $node->getNamespaceName()) !== 0) {
            return;
        }

        $message = sprintf(
            'The environment configuration is not lie in "Shared" layer. That violates the rule "%s"',
            static::RULE
        );

        $this->addViolation($node, [$message]);
    }
675280
public function nodeGranted($node)
    {
        if ($this->tokenStorage->getToken() === null) {
            return false;
        }

        /* @var $nodes TreeNodeInterface[] */

        if ($node instanceof ContentTreeContext) {
            $nodes = array($node->getNode());
        } elseif (is_array($node)) {
            $nodes = $node;
        } elseif (!$node instanceof TreeNodeInterface) {
            return false;
        } else {
            $nodes = array($node);
        }

        foreach ($nodes as $node) {
            if ($node instanceof ContentTreeContext) {
                $node = $node->getNode();
            }

            if ($this->authorizationChecker->isGranted(new Expression($node->getSecurityExpression()))) {
                return true;
            }
        }

        return false;
    }
527121
protected function detachOrPersistNode(AbstractNestedNode $node)
    {
        if (null !== $refreshed = $this->find($node->getUid())) {
            return $this->detachFromTree($refreshed)
                            ->refreshExistingNode($node);
        }

        if (false === $this->_em->contains($node)) {
            $this->_em->persist($node);
        }

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

        if ($this->isExcludedModule($node)) {
            return;
        }

        if ($this->isRepository($node)) {
            return;
        }

        if ($this->isEntityManager($node)) {
            return;
        }

        $allocatedClasses = $node->findChildrenOfType('AllocationExpression');

        if (count($allocatedClasses) === 0) {
            return;
        }

        foreach ($allocatedClasses as $allocatedClass) {
            $this->applyRule($allocatedClass, $node);
        }
    }