@param \PHPMD\AbstractNode $node

@return bool
349753
protected function isServiceProvider(AbstractNode $node): bool
    {
        if (!($this instanceof ClassAware)) {
            return false;
        }

        $interfaceReferences = $this->getInterfaceReferences($node);

        if (!$interfaceReferences) {
            return false;
        }

        foreach ($interfaceReferences as $interfaceReference) {
            if ($interfaceReference->getType()->getName() === 'ServiceProviderInterface' || $interfaceReference->getType()->getName() === 'ControllerProviderInterface') {
                return true;
            }
        }

        return false;
    }
969864
public function addNode(Node $node): bool {
        $added = $this->add($node->getKey(), $node->getValue());
        return $added;
    }
259641
private function isWritten($node) {
    $oidStr = $node->getOID()->__toString();
    return (isset($this->writtenNodes[$oidStr]));
  }
1162841
protected function isWrapped(DomNode $node)
    {
        while ($node = $node->parentNode) {
            if ($node->localName === 'eztemplate' || $node->localName === 'eztemplateinline') {
                return true;
            }
        }

        return false;
    }
1029496
protected function refreshExistingNode(AbstractNestedNode $node)
    {
        if (true === $this->_em->contains($node)) {
            $this->_em->refresh($node);
        } elseif (null === $node = $this->find($node->getUid())) {
            $this->_em->persist($node);
        }

        return $this;
    }
976943
public function checkComparison(array $rule, AbstractNode $node): bool
    {
        if ($rule['key'] == 'plaintext') {
            // plaintext search
            $nodeValue = $node->text();
        } else {
            // normal search
            $nodeValue = $node->getAttribute($rule['key']);
        }

        $check = $this->match($rule['operator'], $rule['value'], $nodeValue);

        // handle multiple classes
        if ( ! $check && $rule['key'] == 'class') {
            $nodeClasses = explode(' ', $node->getAttribute('class'));
            foreach ($nodeClasses as $class) {
                if ( ! empty($class)) {
                    $check = $this->match($rule['operator'], $rule['value'], $class);
                }
                if ($check) {
                    break;
                }
            }
        }

        return $check;
    }
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;
    }
663764
protected function verifyInterface(AbstractNode $node, array $namespaceParts): void
    {
        $classNodeInterfaces = $node->getInterfaces();

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

            return;
        }

        $firstInterface = $classNodeInterfaces[0];

        $interfaceNode = new InterfaceNode($firstInterface);

        $expectedBridgeInterfaceNameRegexp = '#^' . $namespaceParts['moduleName'] . 'To[\w]+' . $namespaceParts['layerName'] . 'Interface$#';

        if (preg_match($expectedBridgeInterfaceNameRegexp, $interfaceNode->getName()) === 0) {
            $message = sprintf(
                'The bridge interface name is not \'%sTo{target_module_name}%sInterface\'. That violates the rule "%s"',
                $namespaceParts['moduleName'],
                $namespaceParts['layerName'],
                static::INTERFACE_RULE
            );
            $this->addViolation($interfaceNode, [$message]);

            return;
        }

        if (str_replace('Interface', 'Bridge', $interfaceNode->getName()) !== $node->getName()) {
            $message = 'The bridge interface name must have the same name postfix as the bridge class has.';
            $this->addViolation($interfaceNode, [$message]);

            return;
        }
    }
1066686
protected function isFactory(AbstractNode $node): bool
    {
        $className = $this->getClassName($node);

        if (preg_match(static::PATTERN_FACTORY, $className) === 0) {
            return false;
        }

        return true;
    }
50448
public function saveConfig(Node $node = null) : bool
    {
        if (null === $node) {
            return $this->saveNode();
        }

        return true;
    }
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
            );
        }
    }
1269988
protected function verifyInterface(AbstractNode $node): void
    {
        $classNodeInterfaces = $node->getInterfaces();

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

            return;
        }

        $firstInterface = $classNodeInterfaces[0];
        $interfaceNode = new InterfaceNode($firstInterface);

        if (preg_match('#.*\\\\Dependency\\\\.*#', $interfaceNode->getNamespaceName()) !== 0) {
            return;
        }

        $message = sprintf(
            'The bridge interface is not lie in "Dependency" folder. That violates the rule "%s"',
            static::INTERFACE_RULE
        );
        $this->addViolation($interfaceNode, [$message]);
    }
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);
        }
    }
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;
    }
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
                    ),
                ]
            );
        }
    }
1282797
protected function checkKey(array $rule, AbstractNode $node): bool
    {
        if ($rule['noKey']) {
            if ( ! is_null($node->getAttribute($rule['key']))) {
                return false;
            }
        } else {
            if ($rule['key'] != 'plaintext' && !$node->hasAttribute($rule['key'])) {
                return false;
            }
        }

        return true;
    }
121499
private function hasNotAllowedChildren(MethodNode $node)
    {
        $children = $node->findChildrenOfType('ScopeStatement');

        $allowedChildren = explode(
            $this->getStringProperty('delimiter'),
            $this->getStringProperty('allowedChildren')
        );

        /** @var AbstractNode $child */
        foreach ($children as $child) {
            if (true === in_array($child->getImage(), $allowedChildren) || true === $this->isChildOfTry($child)) {
                continue;
            }

            return true;
        }

        return false;
    }