@param \PHPMD\Node\MethodNode $node

@return void
552011
protected function applyRule(MethodNode $node): void
    {
        if ($node->isPublic()) {
            return;
        }

        $method = $node->getName();

        $message = sprintf(
            'The factory method \'%s()\' is not public which violates the rule "%s"',
            $method,
            static::RULE
        );

        $this->addViolation($node, [$message]);
    }
1135277
public function execute(NodeData $node)
    {
        $nodeType = $this->nodeTypeManager->getNodeType($this->newType);
        $node->setNodeType($nodeType);
    }
562948
protected function applyRule(ClassNode $node)
    {
        foreach ($node->getMethods() as $method) {
            $this->checkVisibility($method);
        }
    }
1237203
private function deleteChildren( $node ) {
		while ( isset( $node->firstChild ) ) {
			$this->deleteChildren( $node->firstChild );
			$node->removeChild( $node->firstChild );
		}
	}
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);
        }
    }
1041731
private function hasCorrectPrefix(MethodNode $node)
    {
        foreach ($this->allowedPrefixes as $prefix) {
            if ($prefix === substr($node->getImage(), 0, strlen($prefix))) {
                return true;
            }
        }

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

        $this->verifyClass($node);
        $this->verifyInterface($node);
    }
163749
protected function applyNoLoopsInMethod(MethodNode $method)
    {
        foreach ($method->findChildrenOfType('Statement') as $statement) {
            if (!in_array(strtolower($statement->getImage()), $this->forbiddenStatements)) {
                continue;
            }

            $message = sprintf(
                'The method %s contains a "%s" statement which violates rule "' . static::RULE . '"',
                $method->getFullQualifiedName(),
                $statement->getImage()
            );

            $this->addViolation($method, [$message]);
        }
    }
1213664
public function leaveNode(Node $node)
    {
        if ($node instanceof Node\FunctionLike) {
            foreach ($node->params as $param) {
                if ($param->variadic) {
                    $vParam = array_pop($node->params);
                    $node->stmts = $this->addFuncGetArgs(
                        $node->stmts,
                        $node->params,
                        $vParam
                    );
                    $node->params = [];
                    return;
                }
            }
        }
    }
436331
public function apply(AbstractNode $node)
    {
        if (preg_match('(\\\\[^\\\\]+Controller$)', $node->getFullQualifiedName()) === 0) {
            return;
        }
        if ($node->getName() === 'AbstractController') {
            return;
        }

        /** @var \PHPMD\Node\ClassNode $node */
        foreach ($node->getMethods() as $method) {
            $this->applyPublicMethodsHaveActionSuffix($method);
        }
    }
475324
public function apply(AbstractNode $node): void
    {
        if (!$this->isPlugin($node)) {
            return;
        }

        $pluginMethods = $node->getMethods();

        foreach ($pluginMethods as $pluginMethod) {
            $this->applyRule($pluginMethod);
        }
    }
471422
public function invoke($node, NodeInterface $parent): void
    {
        if (! $node instanceof Node\Stmt\Trait_ || ! $parent instanceof PhpFileModelInterface) {
            throw new Exception('TraitNodeParser is made to parse a trait node');
        }

        $trait = new TraitModel();
        $trait->setParentNode($parent);
        $trait->setName(ClassLikeNameHelper::getName($node));
        $parent->addConcreteUse($parent->getFullNameFor($trait->getName()), $trait->getName());

        if (($documentation = $node->getDocComment()) !== null) {
            $this->documentationNodeParser->invoke($documentation, $trait);
        }

        $this->parseSubNodes($node->stmts, $trait);

        $parent->addTrait($trait);
    }
49109
protected function handle($event): void
    {
        $method = $this->getApplyMethod($event);

        if (!method_exists($this, $method)) {
            return;
        }

        $this->$method($event);
    }
263440
public function enterNode(Node $node)
    {
        parent::enterNode($node);

        if (self::isConditional($node)) {
            $this->conditionalScopes++;
        } else {
            // @todo add an "else" here which adds a runtime check for instances where we can't tell
            // whether a class is being redefined by static analysis alone.
            if ($this->conditionalScopes === 0) {
                if ($node instanceof Class_) {
                    $this->validateClassStatement($node);
                } elseif ($node instanceof Interface_) {
                    $this->validateInterfaceStatement($node);
                } elseif ($node instanceof Trait_) {
                    $this->validateTraitStatement($node);
                }
            }
        }
    }
683609
private function countThis(MethodNode $node)
    {
        $count = 0;
        $variables = $node->findChildrenOfType('Variable');

        foreach ($variables as $variable) {
            if ('$this' === $variable->getImage()) {
                $count++;
            }
        }

        return $count;
    }
1250631
protected function applyPropelQueryMethodNameRule(MethodNode $method): void
    {
        $methodName = $method->getName();

        if (preg_match(static::PATTERN_PROPEL_QUERY_DEPENDENCY_PROVIDER_METHOD_NAME, $methodName) !== 0) {
            return;
        }

        $this->addViolationMessage($method);
    }
1203353
public function setMethod( $method )
	{
		if ( $method == $this->getMethod() ) { return; }

		$this->_values['method'] = (string) $method;
		$this->setModified();
	}