Parse user's class methods for relationships.

@param array $customMethods

@return array
182323
protected function parseMethodsForRelationship(array $customMethods): array
    {
        $relationships = [];

        $class = new ReflectionClass(get_class($this));

        // Get the mapped Entity class, as we will detect relationships
        // methods by testing that the first argument is type-hinted to
        // the same class as the mapped Entity.
        $entityClass = $this->getClass();

        foreach ($customMethods as $methodName) {
            $method = $class->getMethod($methodName);

            if ($method->getNumberOfParameters() > 0) {
                $params = $method->getParameters();

                if ($params[0]->getClass() && ($params[0]->getClass()->name == $entityClass || is_subclass_of($entityClass, $params[0]->getClass()->name))) {
                    $relationships[] = $methodName;
                }
            }
        }

        return $relationships;
    }
684480
private function getClassMethods(): array
    {
        if (null !== $this->reflectionMethods) {
            return $this->reflectionMethods;
        }

        $this->reflectionMethods = [];

        $class = $this->reflectionClass;

        do {
            $this->reflectionMethods = \array_merge(
                $this->reflectionMethods,
                $class->getMethods()
            );
        } while ($class = $class->getParentClass());

        return $this->reflectionMethods;
    }
376078
public function getCustomMethodTags($customName = false)
    {
        if (!$customName) {
            $customName = debug_backtrace()[1]['function'];
        }

        $tags = $this->getTags();
        $tags[] = $this->xmlFilePath . $customName;

        return $tags;
    }
1206844
public function getMethods()
    {
        if (!$this->__methods) {
            $methods = array();
            $object  = $this->getObject();

            if (!($object instanceof AnObject)) {
                $reflection	= new ReflectionClass($object);
                foreach ($reflection->getMethods() as $method) {
                    $methods[] = $method->name;
                }
            } else {
                $methods = $object->getMethods();
            }

            $this->__methods = array_merge(parent::getMethods(), $methods);
        }

        return $this->__methods;
    }
185569
private function extractMethods(\ReflectionClass $objectClass): array
    {
        return methodsOf($objectClass, \ReflectionMethod::IS_PUBLIC)
                ->filter(function(\ReflectionMethod $method)
                        {
                            if ($method->getNumberOfParameters() != 0
                                    || $method->isStatic()
                                    || $method->isConstructor()
                                    || $method->isDestructor()
                                    || 0 == strncmp($method->getName(), '__', 2)) {
                                return false;
                            }

                            return !annotationsOf($method)->contain('XmlIgnore');
                        }
                )->map(function(\ReflectionMethod $method)
                        {
                            return $this->createSerializerDelegate(
                                    annotationsOf($method),
                                    $method->getName()
                            );
                        }

                )->data();
    }
717091
private function parseMethodTypes($routes = array())
    {
        $parsed = array();

        foreach ($routes as $route) {
            if ($route[0] === "*") {
                $route[0] = "HEAD|GET|PUT|POST|UPDATE|DELETE|OPTIONS";
            }
            $parsed[] = $route;
        }

        return $parsed;
    }
732563
public function getMethodAnnotations($method)
    {
        $reflector = new ReflectionClass($this->className);
        $doc = $reflector->getMethod($method)->getDocComment();
        $annotations = [];
        foreach ($this->filteringList as $filter) {
            preg_match_all('#@' . $filter . '(.*?)\n#s', $doc, $annotation);
            if (!empty($annotation[1])) {
                $annotations[$filter] = $annotation[1];
            }
        }
        return $annotations;
    }
795428
public static function fromMethodFailure(array $allowedMethods)
    {
        $matchResult = new self();
        $matchResult->type = 'methodFailure';
        $matchResult->allowedMethods = $allowedMethods;
        return $matchResult;
    }
788848
public function getClassMethods()
    {
        if (empty($this->_methods)) {
            $methods = $this->_getReflection()->getMethods();
            foreach ($methods as $method) {
                $this->_methods[] = $method->getName();
            }
        }
        return $this->_methods;
    }
95936
public function getMethod()
    {
        if ($this->method === null) {
            $this->method = $this->originalMethod;
            $customMethod = $this->getHeaderLine('X-Http-Method-Override');

            if ($customMethod) {
                $this->method = $this->filterMethod($customMethod);
            } elseif ($this->originalMethod === 'POST') {
                $body = $this->getParsedBody();

                if (is_object($body) && property_exists($body, '_METHOD')) {
                    $this->method = $this->filterMethod($body->_METHOD);
                } elseif (is_array($body) && isset($body['_METHOD'])) {
                    $this->method = $this->filterMethod($body['_METHOD']);
                }

                if ($this->getBody()->eof()) {
                    $this->getBody()->rewind();
                }
            }
        }

        return $this->method;
    }
1300925
private static function getMethods($methods, $class): array
    {
        $methods[] = \array_fill_keys(\get_class_methods($class), 0);
        $parent = \get_parent_class($class);
        if ($parent) {
            \array_merge($methods, self::getMethods($methods, $parent));
        }
        return $methods[0];
    }
1298436
public static function parseActionMethods($con)
    {
        $refClass = new ReflectionClass($con);
        $methodMap = [];

        // build up parent class list
        $parentClasses = [];
        $parentClasses[] = $parentClassRef = $refClass;
        while ($parent = $parentClassRef->getParentClass()) {
            $parentClasses[] = $parent;
            $parentClassRef = $parent;
        }

        // iterate methods from parent class actions
        foreach (array_reverse($parentClasses) as $class) {
            foreach ($class->getMethods(ReflectionMethod::IS_PUBLIC) as $method) {

                // Ignore class methods that doesn't have Action in suffix
                if (!preg_match('/Action$/', $method->getName())) {
                    continue;
                }
                if (in_array($method->getName(), [ 'runAction', 'hasAction' ])) {
                    continue;
                }

                $meta = array('class' => $class->getName());
                $annotations = self::parseMethodAnnotation($method);

                // If it's empty, then fetch annotations from parent methods
                if (empty($annotations)) {
                    if (isset($methodMap[$method->getName()])) {
                        $annotations = $methodMap[$method->getName()][0];
                    }
                }
                // always update method Map
                $methodMap[$method->getName()] = array($annotations, $meta);
            }
        }
        // TODO: see if we can cache it.
        return $methodMap;
    }
1169417
private function parse(array $stmts, array &$methods)
    {
        foreach ($stmts as $stmt) {
            $this->extractNamespace($stmt);
            $this->extractClassName($stmt);
            $this->extractMethod($stmt, $methods);

            if (property_exists($stmt, 'stmts') && $stmt->stmts !== null) {
                $this->parse($stmt->stmts, $methods);
            }
        }
    }
1254160
public function parseMethods(\ReflectionClass $ref)
    {
        foreach($ref->getMethods(\ReflectionMethod::IS_PUBLIC) as $method)
        {
            $this->parseMethod($ref, $method);
        }
    }
572487
private function readMethodCallees($class, ReflectionMethod $method)
    {
        $callees = array();

        // read parent annotations
        try {
            $prototype = $method->getPrototype();
            // error occurs on every second PHP stable release - getPrototype() returns itself
            if ($prototype->getDeclaringClass()->getName() !== $method->getDeclaringClass()->getName()) {
                $callees = array_merge($callees, $this->readMethodCallees($class, $prototype));
            }
        } catch (ReflectionException $e) {
        }

        if ($docBlock = $method->getDocComment()) {
            $callees = array_merge($callees, $this->readDocBlockCallees($class, $method, $docBlock));
        }

        return $callees;
    }
548700
protected function getRelationshipFromMethod($method)
	{
		$relations = $this->$method();

		if ( ! $relations instanceof Relation)
		{
			throw new LogicException('Relationship method must return an object of type '
				. 'Illuminate\Database\Eloquent\Relations\Relation');
		}

		return $this->relations[$method] = $relations->getResults();
	}
847982
protected function getBridgedInterfaceReflection(array $classMethods): ?ReflectionClass
    {
        foreach ($classMethods as $classMethod) {
            if ($classMethod->getName() === '__construct') {
                $constructorComment = $classMethod->getNode()->getComment();

                if (!$constructorComment) {
                    return null;
                }

                $firstParameter = $classMethod->getNode()->getParameters()[0];

                if (!$firstParameter) {
                    return null;
                }

                $pattern = '#@param[\s]+(?<interfaceName>.*)[\s]+' . preg_quote($firstParameter->getName()) . '#is';

                if (preg_match($pattern, $constructorComment, $matches) === 0) {
                    return null;
                }

                //todo: Spryker\Zed\Ratepay\Dependency\Facade\RatepayToSalesAggregatorBridge - need to fix
                return new ReflectionClass($matches['interfaceName']);
            }
        }

        return null;
    }