创建Facade实例
@static
@access protected
@param string    $class    类名或标识
@param array     $args     变量
@return object
180341
protected static function createFacade($class='', $args=[])
    {
        $class=$class ?: static::class;
        $facadeClass=static::getFacadeClass();
        if ($facadeClass) {
            $class=$facadeClass;
        } elseif (isset(self::$bind[$class])) {
            $class=self::$bind[$class];
        }
        return Container::getInstance()->make($class, $args);
    }
313891
private function __setCallback($type, $class, array $args)
    {
        if (!is_array($class)) {
            $this->{$type} = [
                [
                    'class' => $class,
                    'args' => $args
                ]
            ];

            return $this;
        } elseif (is_array($class) && count($class) == 2) {
            $className = $class[0];
            $methodName = $class[1];
        } else {
            if (is_array($class)) {
                $class = implode($class);
            }
            throw new \InvalidArgumentException("{$class} is missformated");
        }

        $this->{$type} = [
            [
                'class' => [$className, $methodName],
                'args' => $args
            ]
        ];

        return $this;
    }
93361
public function make($classname, ...$args)
    {
        $resource = $this->resolve($classname);
        return $resource->make(...$args);
    }
90440
public function createContext($class, array $arguments = array(), array $singleUseResolvers = array())
    {
        $reflection = new ReflectionClass($class);
        $resolvers = array_merge($singleUseResolvers, $this->argumentResolvers);
        $resolvedArguments = $this->resolveArguments($reflection, $arguments, $resolvers);
        $context = $this->createInstance($reflection, $resolvedArguments);
        $this->initializeInstance($context);

        return $context;
    }
659809
private function handle(string $class, array $args)
    {
        $latest = null;
        foreach ($this->catchers[$class] as $catcher) {
            $latest = $catcher(...$args);
        }
        return $latest;
    }
965376
public function factory($class, array $parameters = []): object
	{
		// Instantiate class

		if($class instanceof Closure)
		{
			$instance = $this->closureFactory($class, $parameters);
		}
		else
		{
			$instance = $this->reflectionFactory($class, $parameters);
		}

		// Inject container using setter if the class is container aware

		if($this->isContainerAware($instance))
		{
			$instance->setContainer($this);
		}

		// Return the instance

		return $instance;
	}
407587
protected static function makeInstance(
        $class, array $options = null
    ): Implementation {

        $options || $options = ['provider' => self::app()];

        return IOC::make($class, [$options, true]);
    }
904158
public function getClass(string $class){
        if(!class_exists($class)){
            throw new \InvalidArgumentException();
        }

        if(!array_key_exists($class, $this->classes)){
            $this->classes[$class]  = new \ReflectionClass($class);
        }

        return $this->classes[$class];
    }
1118012
static public function from($class)
        {
            if (is_object($class)) {
                $class = get_class($class);
            }

            if (empty(self::$prototypes[$class])) {
                self::$prototypes[$class] = new static($class);
            }

            return self::$prototypes[$class];
        }
1037272
protected static function createObject($class, ...$args)
    {
        if (!is_subclass_of($class, DataMapper::class) && !is_subclass_of($class, AbstractDatabaseMapperProxy::class)) {
            throw new \InvalidArgumentException(sprintf('Class: %s is not sub class of ' . DataMapper::class, $class));
        }

        return new $class(...$args);
    }
734528
public function instantiate(string $class, ...$args)
    {
        $refl = $this->reflection->reflectClass($class);

        $dependencyIds = $this->determineDependencies($refl, count($args));
        $dependencies = $args + $this->getDependencies($dependencyIds);

        return $refl->newInstanceArgs($dependencies);
    }
683862
public function setClass($class, $namespace = '', $argv = null)
    {
        if (2 < func_num_args()) {
            $argv = func_get_args();
            $argv = array_slice($argv, 2);
        }
        
        $methods = [];
        if (is_array($class)) {
            $methods = $class['methods'];
            $class = $class['class'];
        }
        
        $obj = $class;
        if ($this->container->has($class)) {
            $obj = $this->container->get($class);
        }
        
        $reflection = Reflection::reflectClass($obj, $argv, $namespace);
        
        foreach ($reflection->getMethods() as $method) {
            $docComment = $method->getDocComment();
            if (($docComment !== false && (new DocBlockReflection($docComment))->hasTag('invokable')) || in_array($method->getName(), $methods)) {
                $definition = $this->_buildSignature($method, $class);
                $this->addMethodServiceMap($definition);
            }
        }
        
        return $this;
    }
766419
public function bind($contract, $class, $args = [])
    {
        $closure = function($class, $args) {
            $reflect = new \ReflectionClass($class);
            return $reflect->newInstanceArgs($args);
        };

        $this->bindings[$contract] = [
            'type' => 'closure',
            'closure' => $closure,
            'class' => $class,
            'args' => $args
        ];

        if (!class_exists($contract, false)) {
            eval("class {$contract} extends \Hades\Container\Facade {} ");
        }
    }
592662
final protected static function getInstance($class, ...$params) {
        if (isset(self::$instances[$class]))
            return self::$instances[$class];

        // set a marker to detect recursive method invocations
        static $currentCreations;
        if (isset($currentCreations[$class])) throw new RuntimeException('Detected recursive call of '.__METHOD__.'('.$class.')');
        $currentCreations[$class] = true;

        // check validity of the passed class (omitting this check can cause an uncatchable fatal error)
        if (!is_a($class, __CLASS__, $allowString=true)) {
            if (!is_class($class)) throw new ClassNotFoundException('Class not found: '.$class );
            throw new InvalidArgumentException('Not a '.__CLASS__.' subclass: '.$class);
        }

        // instantiate the class with the passed parameters
        self::$instances[$class] = new $class(...$params);

        // reset the marker for detecting recursive method invocations
        unset($currentCreations[$class]);

        return self::$instances[$class];
    }
831043
protected function createModel($class, array $args)
    {
        return $this->getPrototype(
            $class,
            [],
            function (IPrototype $prototype)
            {
                $prototype->registerConstructorDependency(
                    'umi\hmvc\model\IModel',
                    function ($concreteClassName) {
                        return $this->createByClass($concreteClassName);
                    }
                );

                $prototypeInstance = $prototype->getPrototypeInstance();
                if ($prototypeInstance instanceof IModelAware) {
                    $prototypeInstance->setModelFactory($this);
                }
            }
        )->createInstance($args);
    }
772191
public static function constructClassInstance( $clazz, $args ) {
		// $args should be a non-associative array; show nice error if that's not the case
		if ( $args && array_keys( $args ) !== range( 0, count( $args ) - 1 ) ) {
			throw new InvalidArgumentException( __METHOD__ . ': $args cannot be an associative array' );
		}

		return new $clazz( ...$args );
	}
1307789
public function create($class, $args = [])
    {
        $class = (string) $class;

        if (empty($class)) {
            throw new InvalidArgumentException(
                'Cannot create a migration from an empty class name!'
            );
        }

        if (!is_array($args)) {
            throw new InvalidArgumentException(
                'Argument "params" must be an array of parameters.'
            );
        }

        if (!empty($args)) {
            $class = new \ReflectionClass($class);
            $instance = $class->newInstanceArgs($args);
        } else {
            $instance = new $class();
        }

        return $instance;
    }