extract informations about methods

@param   \ReflectionClass  $objectClass
@return  array
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();
    }
718887
public static function getActionMethodParameters($objectManager)
    {
        $reflectionService = $objectManager->get(ReflectionService::class);

        $result = [];

        $className = get_called_class();
        $methodNames = get_class_methods($className);
        foreach ($methodNames as $methodName) {
            if (strlen($methodName) > 6 && strpos($methodName, 'Action', strlen($methodName) - 6) !== false) {
                $result[$methodName] = $reflectionService->getMethodParameters($className, $methodName);
            }
        }

        return $result;
    }
1185101
public static function getClassAnnotations($object)
	{
		$classReflection = new \ReflectionClass($object);
		$docBlock = $classReflection->getDocComment();
		$lines = explode("\n", $docBlock);
		$annotations = array();
		foreach ($lines as $line)
		{
			if (preg_match('~^(((\s*\*)|/\*\*)\s*@)(?<annotationName>[^\s]+)\s+(?<annotationValue>.*)~', $line, $matches))
			{
				$annotations[$matches['annotationName']][] = $matches['annotationValue'];
			}
		}
		return $annotations;
	}
189509
private function getMethodInstances($class, $methodName = '__construct')
    {
        if (is_object($class)) {
            $reflectClass = new ReflectionClass(get_class($class));
        } else {
            $reflectClass = new ReflectionClass($class);
        }

        $instances = [];
        $hasDI = false;

        if ($reflectClass->hasMethod($methodName)) {
            $reflectMethod = $reflectClass->getMethod($methodName);

            $params = $reflectMethod->getParameters();

            if (count($params) > 0) {
                foreach ($params as $param) {
                    $paramClass = $param->getClass();
                    if ($paramClass) {
                        $paramClassName = $paramClass->getName();
                        array_push($instances, Container::getByClassName($paramClassName));
                        $hasDI = true;
                    } elseif ($hasDI) {
                        throw new NotFoundException('Dependency Injection cannot work with normal params');
                    }
                }
            }
        }

        if ($hasDI) {
            return $instances;
        }

        return false;
    }
160642
private function getAllUseStatementsMarkedAsAnnotation(\ReflectionClass $class): array
    {
        $tokens = \token_get_all(\file_get_contents($class->getFileName()));

        $uses = [];
        $buffer = '';
        $startUseParse = false;

        foreach ($tokens as $token) {
            if (\is_scalar($token)) {
                // Single element
                if ($token == ';' || $token = ',') {
                    if ($startUseParse) {
                        // Add "use" statement to collection
                        $uses[] = trim($buffer);
                        // Clear buffer
                        $buffer = ''; // Clear buffer

                        if ($token == ';') {
                            // Stop parse "use"
                            $startUseParse = false;
                        }
                    }
                }

                continue;
            }

            $type = $token[0];
            $value = $token[1];

            if (\in_array($type, [T_ABSTRACT, T_CLASS, T_INTERFACE, T_TRAIT])) {
                // Start class or interface or trait
                break;
            }

            if ($type == T_USE) {
                $startUseParse = true;
                continue;
            }

            if ($startUseParse) {
                $buffer .= $value;
            }
        }

        $useFiltering = function ($class, $searchChild = true) use (&$useFiltering) {
            if (!$class) {
                return false;
            }

            $parts = \explode(' as ', $class, 2);
            $class = $parts[0];

            try {
                $reflection = new \ReflectionClass($class);
            } catch (\ReflectionException $e) {
                if ($searchChild) {
                    foreach (\get_declared_classes() as $declaredClass) {
                        if (\strpos($declaredClass, $class) === 0) {
                            if (true === $useFiltering($declaredClass, false)) {
                                return true;
                            }
                        }
                    }
                }

                return false;
            }

            if ($reflection->getName() == Transactional::class) {
                return false;
            }

            return \strpos($reflection->getDocComment(), '@Annotation') !== false;
        };

        $uses = \array_filter($uses, $useFiltering);

        return $uses;
    }
26494
public static function getConstants($objectOrClass): array
    {
        try {
            $reflectionClass = self::getReflectionClass($objectOrClass);
            return $reflectionClass->getConstants();
        } catch (\Exception $e) {
            return [];
        }
    }
1195938
public function getMethods()
    {
        $aMethods = [];
        foreach($this->reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $xMethod)
        {
            $sMethodName = $xMethod->getShortName();
            // Don't take magic __call, __construct, __destruct methods
            if(strlen($sMethodName) > 2 && substr($sMethodName, 0, 2) == '__')
            {
                continue;
            }
            // Don't take excluded methods
            if(in_array($sMethodName, $this->aProtectedMethods))
            {
                continue;
            }
            $aMethods[] = $sMethodName;
        }
        return $aMethods;
    }
1300050
public function GetKeyMaps($objectclass)
	{
		// TODO: if a php memory error occurs within this method, uncomment this block to debug
		/*
		if (Phreezer::$cnt++ > 500)
		{
			throw new Exception("A sanity limit was exceeded when recursing KeyMaps for `$objectclass`.  Please check your Map for circular joins.");
		}
		//*/

		// this is a temporary ram cache
		$kms = $this->_mapCache->Get($objectclass."KeyMaps");
		if ($kms) return $kms;

		$this->IncludeModel($objectclass);
		if (!class_exists($objectclass."Map")) throw new Exception("Class '" . $objectclass."Map' is not defined.");
		$kms = call_user_func( array($objectclass."Map","GetKeyMaps") );

		$this->_mapCache->Set($objectclass."KeyMaps",$kms);
		return $kms;
	}
509027
public static function getClassMethods($context, $class) {
        $methods = array();

        foreach ($class->getMethods() as $method) {
            $meta = static::getMeta($method);
            $methods[$meta['name']] = static::scanDependency($context, preg_replace('/public static function (.+)\\(/', "function {$context['funcprefix']}\$1(", $meta['code']), $meta['code']);
        }

        return $methods;
    }
924991
protected function extractInterfaceDefinitions(\ReflectionClass $refClass)
    {
        $int = $refClass->getInterfaces();

        //get recursively all parent abstract classes to use as interfaces
        $currentClass = $refClass;
        while ($currentClass->getParentClass()) {
            if ($currentClass->getParentClass()->isAbstract()) {
                $int[] = $currentClass->getParentClass();
            }
            $currentClass = $currentClass->getParentClass();
        }

        //current class can be a object and interface at the same time,
        //When use different object types using discriminator map
        if ($this->reader->getClassAnnotation($refClass, Annotation\InterfaceType::class)) {
            $int[] = $refClass;
        }

        $definitions = [];
        foreach ($int as $intRef) {
            /** @var Annotation\InterfaceType $intAnnot */
            $intAnnot = $this->reader->getClassAnnotation(
                $intRef,
                Annotation\InterfaceType::class
            );

            if ($intAnnot) {
                $intDef = new InterfaceDefinition();
                $intDef->setName($intAnnot->name);
                $intDef->setClass($intRef->getName());

                if (!$intDef->getName() && preg_match('/\w+$/', $intRef->getName(), $matches)) {
                    $intDef->setName(preg_replace('/Interface$/', null, $matches[0]));
                }

                $intDef->setMetas($intAnnot->options);
                $intDef->setDescription($intAnnot->description);
                $intDef->setDiscriminatorMap($intAnnot->discriminatorMap);
                $intDef->setDiscriminatorProperty($intAnnot->discriminatorProperty);
                $intDef->setExclusionPolicy($intAnnot->exclusionPolicy);
                $this->resolveFields($intRef, $intDef);
                if (!$intDef->getName() && preg_match('/\w+$/', $intRef->getName(), $matches)) {
                    $intDef->setName(preg_replace('/Interface$/', null, $matches[0]));
                }

                $definitions[] = $intDef;
            }
        }

        return $definitions;
    }
1331708
protected function methodsToArray(ReflectionObject $reflection)
    {
        $methods = $reflection->getMethods(ReflectionMethod::IS_PUBLIC);

        $data = [];

        foreach ($methods as $method) {
            if ($method->class !== __CLASS__ && substr($method->name, 0, 2) !== '__') {
                $data[$method->name] = $this->{$method->name}();
            }
        }

        return $data;
    }
717287
public function extract($objectClass, $result)
    {
        $hydrator = $this->objectManager->getHydratorFor($objectClass);

        return $hydrator->extract($result);
    }
957748
public function getConditions(ReflectionClass $class, string $methodName): array
    {
        $annotations = [];
        $parentMethods = [];

        $this->getParentClassesMethods($class, $methodName, $parentMethods);
        $this->getInterfacesMethods($class, $methodName, $parentMethods);

        foreach ($parentMethods as $parentMethod) {
            $annotations[] = $this->annotationReader->getMethodAnnotations($parentMethod);
        }

        if (\count($annotations) > 0) {
            $annotations = \array_merge(...$annotations);
        }

        return $this->filterContractAnnotation($annotations);
    }
287750
public function parseClass(\ReflectionClass $class)
    {
        if (false === $filename = $class->getFilename()) {
            return array();
        }

        $content = $this->getFileContent($filename, $class->getStartLine());
        $namespace = str_replace('\\', '\\\\', $class->getNamespaceName());
        $content = preg_replace('/^.*?(\bnamespace\s+' . $namespace . '\s*[;{].*)$/s', '\\1', $content);
        $this->tokens = token_get_all('<?php ' . $content);
        $this->numTokens = count($this->tokens);
        $this->pointer = 0;

        $statements = $this->parseUseStatements($class->getNamespaceName());

        return $statements;
    }
661802
public function extract(\Reflector $reflectionClass)
    {
        if (!$reflectionClass instanceof \ReflectionClass) {
            throw new ExtractorException(\ReflectionClass::class, $reflectionClass);
        }

        return $this->reader->getClassAnnotations($reflectionClass);
    }
1321013
public function extractAuth($class, string $method = null) : array
    {
        if (!is_string($class) && !is_object($class)) {
            throw new \InvalidArgumentException(
                'Class must be string or object!'
            );
        }

        $className = (is_string($class)) ? $class : get_class($class);
        $sig = ($method) ? $className . '::' . $method : $className;

        // Class auths haven't been cached yet
        if (!$this->getCache()->has($className)) {
            $r = new \ReflectionClass($className);
            preg_match_all(self::REGEX, $r->getDocComment(), $matchC);
            $this->getCache()->set($className, $this->normalize((array)$matchC));
        }

        // Method auths haven't been cached yet
        if (!$this->getCache()->has($sig)) {
            $r = new \ReflectionMethod($className, $method);
            preg_match_all(self::REGEX, $r->getDocComment(), $matchC);
            $this->getCache()->set($sig, $this->normalize((array)$matchC));
        }

        return ($this->getCache()->get($sig) == [])
            ? $this->getCache()->get($className)
            : $this->getCache()->get($sig);
    }
608410
public function getEncryptionEnabledFields(\ReflectionClass $reflectionClass)
    {
        $encryptionEnabledFields = array();

        $classMetadata = $this->getEncryptionMetadataFor($reflectionClass->getName());

        if ($classMetadata->encryptionEnabled) {
            /** @var PropertyMetadata $propertyMetadata */
            foreach ($classMetadata->propertyMetadata as $propertyMetadata) {
                if ($propertyMetadata->encrypted) {
                    $reflectionProperty = $reflectionClass->getProperty($propertyMetadata->name);
                    $encryptionEnabledFields[$reflectionProperty->name] = $reflectionProperty;
                }
            }
        }

        return $encryptionEnabledFields;
    }