public static function callback($handler)
    {
        if ($handler instanceof Closure) {
            return $handler;
        }
        if (is_object($handler[0])) {
            return $handler;
        }

        // If the first argument is a class name string,
        // then create the controller object.
        if (is_string($handler[0])) {

            // If users define the constructor arguments in options array.
            $constructArgs = [];
            $rc = new ReflectionClass($handler[0]);
            if (isset($options['constructor_args'])) {
                $con = $handler[0] = $rc->newInstanceArgs($constructArgs);
            } else {
                $con = $handler[0] = $rc->newInstance();
            }

            return $handler;
        }

        throw new LogicException('Unsupported handler type');
    }
public static function callback($handler)
    {
        if ($handler instanceof Closure) {
            return $handler;
        }
        if (is_object($handler[0])) {
            return $handler;
        }

        // If the first argument is a class name string,
        // then create the controller object.
        if (is_string($handler[0])) {

            // If users define the constructor arguments in options array.
            $constructArgs = [];
            $rc = new ReflectionClass($handler[0]);
            if (isset($options['constructor_args'])) {
                $con = $handler[0] = $rc->newInstanceArgs($constructArgs);
            } else {
                $con = $handler[0] = $rc->newInstance();
            }

            return $handler;
        }

        throw new LogicException('Unsupported handler type');
    }
public static function callback ( $ handler ) { if ( $ handler instanceof Closure ) { return $ handler ; } if ( is_object ( $ handler [ 0 ] ) ) { return $ handler ; } // If the first argument is a class name string, // then create the controller object. if ( is_string ( $ handler [ 0 ] ) ) { // If users define the constructor arguments in options array. $ constructArgs = [ ] ; $ rc = new ReflectionClass ( $ handler [ 0 ] ) ; if ( isset ( $ options [ 'constructor_args' ] ) ) { $ con = $ handler [ 0 ] = $ rc -> newInstanceArgs ( $ constructArgs ) ; } else { $ con = $ handler [ 0 ] = $ rc -> newInstance ( ) ; } return $ handler ; } throw new LogicException ( 'Unsupported handler type' ) ; }
When creating the controller instance, we don't care about the environment.

The returned object should be a PHPSGI app, so that we can always
execute "call" on the returned object.

@return Closure|PHPSGI\App|Controller
When creating the controller instance we don t care about the environment .