public static function factory($class, $method = null)
    {
        if (is_object($class))
            $class = get_class($class);
        $class = (string)$class;
        if (!isset(self::$methods[$class])) {
            $classReflection = new \ReflectionClass($class);
            $methods = $classReflection->getMethods();
            self::$methods[$class] = array();
            foreach ($methods as $methodReflection) {
                if ($methodReflection->class != $class) {
                    self::$methods[$class][$methodReflection->name] = self::factory($methodReflection->class, $methodReflection->name);
                } else {
                    self::$methods[$class][$methodReflection->name] = new self($class, $methodReflection->name);
                    self::$methods[$class][$methodReflection->name]->setAccessible(true);
                }
            }
        }
        if (isset($method)) {
            if (!isset(self::$methods[$class][$method])) {
                self::$methods[$class][$method] = new self($class, $method);
                self::$methods[$class][$method]->setAccessible(true);
            }
            return self::$methods[$class][$method];
        } else
            return array_values(self::$methods[$class]);
    }
public static function factory($class, $method = null)
    {
        if (is_object($class))
            $class = get_class($class);
        $class = (string)$class;
        if (!isset(self::$methods[$class])) {
            $classReflection = new \ReflectionClass($class);
            $methods = $classReflection->getMethods();
            self::$methods[$class] = array();
            foreach ($methods as $methodReflection) {
                if ($methodReflection->class != $class) {
                    self::$methods[$class][$methodReflection->name] = self::factory($methodReflection->class, $methodReflection->name);
                } else {
                    self::$methods[$class][$methodReflection->name] = new self($class, $methodReflection->name);
                    self::$methods[$class][$methodReflection->name]->setAccessible(true);
                }
            }
        }
        if (isset($method)) {
            if (!isset(self::$methods[$class][$method])) {
                self::$methods[$class][$method] = new self($class, $method);
                self::$methods[$class][$method]->setAccessible(true);
            }
            return self::$methods[$class][$method];
        } else
            return array_values(self::$methods[$class]);
    }
public static function factory ( $ class , $ method = null ) { if ( is_object ( $ class ) ) $ class = get_class ( $ class ) ; $ class = ( string ) $ class ; if ( ! isset ( self :: $ methods [ $ class ] ) ) { $ classReflection = new \ ReflectionClass ( $ class ) ; $ methods = $ classReflection -> getMethods ( ) ; self :: $ methods [ $ class ] = array ( ) ; foreach ( $ methods as $ methodReflection ) { if ( $ methodReflection -> class != $ class ) { self :: $ methods [ $ class ] [ $ methodReflection -> name ] = self :: factory ( $ methodReflection -> class , $ methodReflection -> name ) ; } else { self :: $ methods [ $ class ] [ $ methodReflection -> name ] = new self ( $ class , $ methodReflection -> name ) ; self :: $ methods [ $ class ] [ $ methodReflection -> name ] -> setAccessible ( true ) ; } } } if ( isset ( $ method ) ) { if ( ! isset ( self :: $ methods [ $ class ] [ $ method ] ) ) { self :: $ methods [ $ class ] [ $ method ] = new self ( $ class , $ method ) ; self :: $ methods [ $ class ] [ $ method ] -> setAccessible ( true ) ; } return self :: $ methods [ $ class ] [ $ method ] ; } else return array_values ( self :: $ methods [ $ class ] ) ; }
Constructs a new ReflectionMethod object from method and class name.
If object already exists in cache it will taken from there instead of creating
new object

@param string|object $class
@param string $property
@return ReflectionMethod
Constructs a new ReflectionMethod object from method and class name . If object already exists in cache it will taken from there instead of creating new object