@param \PHPMD\Node\MethodNode $method

@return bool
423455
protected function isIndirectFactoryMethod(MethodNode $method)
    {
        $primaryPrefixes = $method->findChildrenOfType('MemberPrimaryPrefix');
        if (count($primaryPrefixes) < 1) {
            return false;
        }

        $firstPrimaryPrefix = $primaryPrefixes[0];

        if ($firstPrimaryPrefix->getChild(0)->getName() === '$this' && $this->isMethodNameStartsWithCreate($firstPrimaryPrefix->getChild(1)->getName())) {
            return true;
        }

        if ($firstPrimaryPrefix->getChild(0)->getName() === '$this' && substr($firstPrimaryPrefix->getChild(1)->getName(), 0, 2) === '->') {
            if ($this->isMethodNameStartsWithCreate($primaryPrefixes[1]->getChild(0)->getName())) {
                return true;
            }
        }

        if ($firstPrimaryPrefix->getParent()->getName() === 'return' &&
            $this->isMethodNameStartsWithCreate($firstPrimaryPrefix->getChild(1)->getNode()->getImage()) &&
            $this->isStaticMethodCall($firstPrimaryPrefix)
        ) {
            return true;
        }

        foreach ($primaryPrefixes as $primaryPrefix) {
            if ($primaryPrefix->getParent()->getName() === 'return') {
                $returnNodeChildren = $primaryPrefix->findChildrenOfType('MethodPostfix');

                foreach ($returnNodeChildren as $returnNodeChild) {
                    if ($this->isMethodNameStartsWithCreate($returnNodeChild->getChild(0)->getName())) {
                        return true;
                    }
                }
            }
        }

        return false;
    }
683609
private function countThis(MethodNode $node)
    {
        $count = 0;
        $variables = $node->findChildrenOfType('Variable');

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

        return $count;
    }
1111999
public static boolean hasAnnotation(final MethodNode methodNode, final Class<? extends Annotation> annotationClass) {
        return !methodNode.getAnnotations(new ClassNode(annotationClass)).isEmpty();
    }
1146658
protected function applyRule(MethodNode $method)
    {
        if (preg_match('/^(\_\_|create|get).+/', $method->getName()) !== 0) {
            return;
        }

        $message = sprintf(
            'The factory method %s() violates rule "%s"',
            $method->getName(),
            static::RULE
        );

        $this->addViolation($method, [$message]);
    }
169673
public function isTypeAndChainCalls(Node $node, string $type, array $methods): bool
    {
        if (! $node instanceof MethodCall) {
            return false;
        }

        // node chaining is in reverse order than code
        $methods = array_reverse($methods);

        foreach ($methods as $method) {
            $activeMethodName = $this->nameResolver->resolve($node);
            if ($activeMethodName !== $method) {
                return false;
            }

            $node = $node->var;
            if ($node instanceof MethodCall) {
                continue;
            }
        }

        $variableTypes = $this->nodeTypeResolver->resolve($node);

        return in_array($type, $variableTypes, true);
    }
518331
protected function getFactoryCallsNumber(MethodNode $method)
    {
        $factoryCallNumber = 0;
        $primaryPrefixes = $method->findChildrenOfType('MemberPrimaryPrefix');

        foreach ($primaryPrefixes as $key => $primaryPrefix) {
            if (!$this->isChildNameEqual($primaryPrefix, 0, static::PSEUDO_VAR_THIS)) {
                continue;
            }

            if (!$this->isChildNameEqual($primaryPrefix, 1, static::OBJECT_OPERATOR)) {
                continue;
            }

            if (!isset($primaryPrefixes[$key + 1])) {
                continue;
            }

            if ($this->isChildNameEqual($primaryPrefixes[$key + 1], 0, static::GET_FACTORY_METHOD)) {
                $factoryCallNumber++;
            }
        }

        return $factoryCallNumber;
    }
1098488
public function methodMatch($methods, $requestMethod, Request $request)
    {
        $match = false;
        if ($requestMethod === null) {
            $requestMethod = ($request->getRequestMethod()) ? $request->getRequestMethod() : 'GET';
        }
        $methods = explode('|', $methods);
        foreach ($methods as $method) {
            if (strcasecmp($requestMethod, $method) === 0) {
                $match = true;
                break;
            } else {
                continue;
            }
        }
        if ($match === true) {
            return true;
        }

        return false;
    }
621035
public function hasValidMandateForMethod($method)
    {
        $mandates = $this->mandates();
        foreach ($mandates as $mandate) {
            if ($mandate->method === $method && $mandate->isValid()) {
                return true;
            }
        }

        return false;
    }
975935
public function isMethodFinal($className, $methodName)
    {
        $className = $this->prepareClassReflectionForUsage($className);
        return isset($this->classReflectionData[$className][self::DATA_CLASS_METHODS][$methodName][self::DATA_METHOD_FINAL]);
    }
105745
protected function isMethodDeprecated(MethodNode $node): bool
    {
        if (preg_match('#\@deprecated#', $node->getNode()->getDocComment()) !== 0) {
            return true;
        }

        return false;
    }
849562
protected function applyRule(MethodNode $method, array $allowedProvideMethodNames)
    {
        if ($this->isMethodDeprecated($method)) {
            return;
        }

        if (in_array($method->getName(), $allowedProvideMethodNames)) {
            return;
        }

        if (preg_match('/^(add|get).+/', $method->getName()) !== 0) {
            return;
        }

        $this->addViolationMessage($method);
    }
1302420
public function checkToken($method = 'post') {
        $token = $this->getFormToken();

        if (!$this->input->$method->get($token, '', 'alnum')) {
            if ($this->getSession()->isNew()) {
                // Redirect to login screen.
                $this->redirect('/login');
                $this->close();
            }

            return false;
        }

        return true;
    }
1226248
protected function applyRule(MethodNode $method)
    {
        if (substr($method->getName(), 0, 3) !== 'get') {
            return;
        }

        $count = count($method->findChildrenOfType('AllocationExpression'));
        if ($count === 0) {
            return;
        }

        $this->addViolation(
            $method,
            [
                sprintf(
                    'The factory method %s contains %d new statements which violates rule "' . static::RULE . '"',
                    $method->getFullQualifiedName(),
                    $count
                ),
            ]
        );
    }
223889
public function isValidHttpMethod($method)
    {
        $method = strtoupper($method);

        if (in_array('ANY', $this->methods)) {
            return true;
        }

        return (bool)in_array($method, $this->methods);
    }
1302976
protected function hasMethodAnnotation($method, $annotation)
	{
		if (!$this->getReflection()->hasMethod($method))
		{
			return FALSE;
		}

		$rm = Method::from($this->getReflection()->getName(), $method);
		return $rm->hasAnnotation($annotation);
	}
287277
private function isMethodCall(Node\Node $node, string $objectName, string $methodName): bool
    {
        if ($node instanceof Node\CallExpression) {
            $callee = $node->getCallee();

            if ($callee instanceof Node\MemberExpression) {
                $object = $callee->getObject();
                $property = $callee->getProperty();

                if ($object instanceof Node\Identifier && $property instanceof Node\Identifier) {
                    return $object->getName() === $objectName && $property->getName() === $methodName;
                }
            }
        }

        return false;
    }
800350
public function hasMethod( $methodName, $callableOnly = TRUE )
	{
		if( $callableOnly )
			return method_exists( $this, $methodName ) && is_callable( array( $this, $methodName ) );
		else
			return method_exists( $this, $methodName );
	}