Returns the methods definition

@param ReflectionClass $class
@param array $produces The class level @produces tags
@return array
@throws Exception
765903
public function parseMethods($class, $produces)
    {
        $ret = [];
        foreach ($class->getMethods() as $method) {

            $def = $this->parseMethod($method, $produces);

            if ($def) {
                $methodDoc = $this->fetchDocComment($method);
                $tags = self::parseDocCommentTags($methodDoc);

                if (!isset($tags[self::T_PATH])) {
                    continue;
                }

                if (!isset($ret[$tags[self::T_PATH]])) {
                    $ret[$tags[self::T_PATH]] = [];
                }
                $ret[$tags[self::T_PATH]][$tags[self::T_METHOD]] = $def;
            }
        }
        return $ret;
    }
674903
public static function getControllerMethods($class)
    {
        if (!class_exists($class)) {
            throw new TaskManagerException('class ' . $class . ' not found');
        }
        $class_methods = get_class_methods($class);
        if ($parent_class = get_parent_class($class)) {
            $parent_class_methods = get_class_methods($parent_class);
            return array_diff($class_methods, $parent_class_methods);
        }
        return $class_methods;
    }
823003
static function getMethodAnnotations($method, $class = NULL)
	{
		$method instanceof ReflectionMethod or $method = new ReflectionMethod($class, $method);

		return static::instance()->getMethodAnnotations($method);
	}
234519
private static function getMethodsTpl($ref, $class)
    {
        $tpl = '';
        foreach($ref->getMethods(\ReflectionMethod::IS_PUBLIC) as $method)
        {
            if($method->isStatic() || '__construct' === $method->name || $method->isFinal() || !static::hasAop($ref, $method))
            {
                continue;
            }
            $paramsTpls = static::getMethodParamTpls($method);
            $methodReturnType = static::getMethodReturnType($method);
            $returnsReference = $method->returnsReference() ? '&' : '';
            $tpl .= <<<TPL
    public function {$returnsReference}{$method->name}({$paramsTpls['define']}){$methodReturnType}
    {
        \$__args__ = func_get_args();
        {$paramsTpls['set_args']}
        \$__result__ = \$this->beanProxy->call(
            '{$method->name}',
            function({$paramsTpls['define']}){
                \$__args__ = func_get_args();
                {$paramsTpls['set_args']}
                return parent::{$method->name}(...\$__args__);
            },
            \$__args__
        );
        return \$__result__;
    }

TPL;
        }
        return $tpl;
    }
445348
public function getFilters(\ReflectionClass $reflectionClass)
    {
        if ($this->isProduction()) {
            $this->grid->getFilter()->getFields();
        }

        $properties = $reflectionClass->getProperties(\ReflectionProperty::IS_PRIVATE | \ReflectionProperty::IS_PROTECTED);
        /** @var \ReflectionProperty $property */
        foreach ($properties as $property) {
            $propertyAnnotations = $this->extractorFactory->extract($property, Extractor::PROPERTY_ANNOTATION);
            foreach ($propertyAnnotations as $annotation) {
                if ($annotation instanceof Filter) {
                    $fields[] = $property->getName();
                }
            }
        }

        return !empty($fields) ? $fields : $this->grid->getFilter()->getFields();
    }
201322
public function getClassAnnotation($class)
    {
        $reflClass = new \ReflectionClass($class);
        $mappedDocumentClass = static::ANNOTATION_CLASS_CLASS;

        foreach ($this->annotationReader->getClassAnnotations($reflClass) as $annotation) {
            if ($annotation instanceof $mappedDocumentClass) {
                return $annotation;
            }
        }

        return null;
    }
780566
protected function getMethodAnnotations(ReflectionClass $class, SimpleAnnotationReader $reader)
	{
		$annotations = [];

		foreach ($class->getMethods() as $method)
		{
			$results = $reader->getMethodAnnotations($method);

			if (count($results) > 0)
				$annotations[$method->name] = $results;
		}

		return $annotations;
	}
970106
private static function getInstance($class)
    {
        //get the backtrace
        $trace = debug_backtrace();
        $args = array();
        
        //the 2nd line is the caller method
        if (isset($trace[1]['args']) && count($trace[1]['args']) > 1) {
            //get the args
            $args = $trace[1]['args'];
            //shift out the class name
            array_shift($args);
            //then maybe it's the 3rd line?
        } else if (isset($trace[2]['args']) && count($trace[2]['args']) > 0) {
            //get the args
            $args = $trace[2]['args'];
        }
        
        //if there's no args or there's no construct to accept the args
        if (count($args) === 0 || !method_exists($class, '__construct')) {
            //just return the instantiation
            return new $class;
        }
        
        //at this point, we need to vitually call the class
        $reflect = new \ReflectionClass($class);
        
        try { //to return the instantiation
            return $reflect->newInstanceArgs($args);
        } catch (\ReflectionException $e) {
            //trigger error
            Exception::i()
                ->setMessage(self::ERROR_REFLECTION)
                ->addVariable($class)
                ->addVariable('new')
                ->trigger();
        }
    }
308617
protected function getClassProviders(\ReflectionClass $class) {
		$annotations = Omocha::getAnnotations($class);
		
		//get class providers
		$providers = $annotations->find('Provider', Filter::TYPE_STRING);
		
		if (!empty($providers)) {
			$classes = [];
			
			foreach ($providers as $provider) {
				$classes[] = $provider->getValue();
			}
			
			return $classes;
		}
		
		//if no providers are specified try getting them from parent class
		if ($annotations->has('ExtendInject')) {
			$extend = $annotations->get('ExtendInject')->getValue();
			
			if ($extend) {
				$parent = $class->getParentClass();
				return $parent instanceof \ReflectionClass ? $this->getClassProviders($parent) : [];
			}
		}
		
		return [];
	}
1284456
protected static function _generateClassMethods($class, $layer = null)
    {
        if (!class_exists($class)) {
            throw new MissingImplementationException("Unexisting class `{$class}`");
        }
        $result = static::_generateAbstractMethods($class);

        if ($layer === false) {
            return $result;
        }

        $reflection = Inspector::inspect($class);

        if (!$layer && !$reflection->isInternal()) {
            return $result;
        }

        $finals = $reflection->getMethods(ReflectionMethod::IS_FINAL);
        $methods = array_diff($reflection->getMethods(ReflectionMethod::IS_PUBLIC), $finals);
        foreach ($methods as $method) {
            $result[$method->getName()] = static::_generateMethod($method, true);
        }
        return $result;
    }
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;
    }
1237484
public function getBasicDefinition($class)
    {
        if (!class_exists($class)) {
            throw new \InvalidArgumentException("$class is not a valid class name");
        }

        $definition = new Definition($class, []);

        $traits = $this->classUsesDeep($class);
        foreach ($traits as $trait) {
            switch ($trait) {
                case 'Smartbox\Integration\FrameworkBundle\DependencyInjection\Traits\UsesEvaluator':
                    $definition->addMethodCall('setEvaluator', [new Reference('smartesb.util.evaluator')]);
                    break;

                case 'Smartbox\Integration\FrameworkBundle\DependencyInjection\Traits\UsesSerializer':
                    $definition->addMethodCall('setSerializer', [new Reference('jms_serializer')]);
                    break;

                case 'Smartbox\Integration\FrameworkBundle\DependencyInjection\Traits\UsesValidator':
                    $definition->addMethodCall('setValidator', [new Reference('validator')]);
                    break;

                case 'Smartbox\Integration\FrameworkBundle\DependencyInjection\Traits\UsesEventDispatcher':
                    $definition->addMethodCall('setEventDispatcher', [new Reference('event_dispatcher')]);
                    break;

                case 'Smartbox\Integration\FrameworkBundle\DependencyInjection\Traits\UsesEndpointFactory':
                    $definition->addMethodCall('setEndpointFactory', [new Reference('smartesb.endpoint_factory')]);
                    break;

                case 'Smartbox\Integration\FrameworkBundle\DependencyInjection\Traits\UsesEndpointRouter':
                    $definition->addMethodCall('setEndpointsRouter', [new Reference('smartesb.router.endpoints')]);
                    break;

                case 'Smartbox\Integration\FrameworkBundle\DependencyInjection\Traits\MessageFactoryAware':
                    $definition->addMethodCall('setMessageFactory', [new Reference('smartesb.message_factory')]);
                    break;

                case 'Smartbox\Integration\FrameworkBundle\DependencyInjection\Traits\UsesCacheService':
                    $definition->addMethodCall('setCacheService', [new Reference('smartcore.cache_service')]);
                    break;

                case 'Symfony\Component\DependencyInjection\ContainerAwareTrait':
                    $definition->addMethodCall('setContainer', [new Reference('service_container')]);
                    break;
            }
        }

        return $definition;
    }
106862
public function offsetGet($class)
	{
		if (!isset($this->factories[$class]) && !isset($this->instances[$class])) {
			throw new \InvalidArgumentException("$class has not been defined");
		}

		if (isset($this->instances[$class])) {
			return $this->instances[$class];
		}

		array_push($this->resolving, $class);
		$object = $this->invoke($this->factories[$class]);
		array_pop($this->resolving);

		return $object;
	}
1252274
private static function createMethods(\ReflectionClass $class): string
    {
        $code    = '';
        $methods = [];
        $params  = [];
        $voidMethods = [];
        foreach (self::methodsOf($class) as $method) {
            $return = true;
            $returnType = determineReturnTypeOf($method);
            if ($returnType === ': void') {
                $voidMethods[$method->getName()] = $method->getName();
                $return = false;
            }

            $param = paramsOf($method);
            /* @var $method \ReflectionMethod */
            $code .= sprintf(
                    "    %s function %s(%s)%s {\n"
                  . "        %s\$this->handleMethodCall('%s', func_get_args(), %s);\n"
                  . "    }\n",
                    ($method->isPublic() ? 'public' : 'protected'),
                    $method->getName(),
                    $param['string'],
                    $returnType,
                    $return ? 'return ' : '',
                    $method->getName(),
                    self::shouldReturnSelf($class, $method) ? 'true' : 'false'
            );
            $methods[] = "'" . $method->getName() . "' => '" . $method->getName() . "'";
            $params[$method->getName()] = $param['names'];
        }

        return $code . sprintf(
                "\n    private \$_allowedMethods = [%s];\n",
                join(', ', $methods)
        ) . sprintf(
                "\n    private \$_methodParams = %s;\n",
                var_export($params, true)
        ) . sprintf(
                "\n    private \$_voidMethods = %s;\n",
                var_export($voidMethods, true)
        );
    }
1074852
public static function invokeStaticMethod($class, $method, $args)
    {
        switch (count($args)) {
            case 0:
                return $class::$method();
            case 1:
                return $class::$method($args[0]);
            case 2:
                return $class::$method($args[0], $args[1]);
            case 3:
                return $class::$method($args[0], $args[1], $args[2]);
            case 4:
                return $class::$method($args[0], $args[1], $args[2], $args[3]);
            default:
                $rMethod = new \ReflectionMethod($class, $method);
                return $rMethod->invokeArgs(null, $args);
        }
    }
421203
private function fetchParametersForHandlerFactoryMethod(string $handlerClassName): array
    {
        if (! isset($this->tagHandlerParameterCache[$handlerClassName])) {
            $methodReflection = new \ReflectionMethod($handlerClassName, 'create');
            $this->tagHandlerParameterCache[$handlerClassName] = $methodReflection->getParameters();
        }

        return $this->tagHandlerParameterCache[$handlerClassName];
    }
141843
private function getMethodParameters(string $class, string $methodName) : array
    {
        $methodReflection = new ReflectionMethod($class, $methodName);
        $parametersName   = [];

        foreach ($methodReflection->getParameters() as $parameter) {
            $parametersName[] = $parameter->name;
        }

        return $parametersName;
    }