实例对象制作器
@param $namespace
@param array $args
@return object|\ReflectionMethod
@throws \ReflectionException
323271
public static function make($namespace,$args=[]) {
        $reflect = new \ReflectionClass($namespace);
        $constructor = $reflect->getConstructor();
        if (!$constructor || $constructor->getNumberOfParameters() == 0) {
            $constructor = $reflect->newInstance();
        }
        else {
            $constructor = $reflect->newInstanceArgs($args);
        }
        return $constructor;
    }
835015
public function singletonFactory($namespace, array $args = [], $name = null)
    {
        if (is_null($name)) {
            $name = $namespace;
        }

        if (!isset($this->singletons[$name])) {
            $this->singletons[$name] = $this->factory($namespace, $args);
        }

        $this->callEvent(
            'register_before_return_singleton',
            [$this->singletons[$name], $args, $name]
        );

        return $this->singletons[$name];
    }
779288
public static function object($alias,$namespace=null,$args=[]) {
        if (isset(self::$pool[$alias])) {
            return self::$pool[$alias];
        }

        //object('dao','\app\Name',[]);3
        //object('dao','\app\Name');2

        //object('\app\Name',[]); 2
        //object('\app\Name');  1

        if($namespace == null) {
            $namespace = $alias;
        }
        elseif(is_array($namespace)) {
            $args = $namespace;
            $namespace = $alias;
        }

        $constructor = static::make($namespace,$args);
        /*
        $reflect = new \ReflectionClass($namespace);
        $constructor = $reflect->getConstructor();
        if (!$constructor || $constructor->getNumberOfParameters() == 0) {
            $constructor = $reflect->newInstance();
        }
        else {
            $constructor = $reflect->newInstanceArgs($args);
        }
        */
        //固化
        if(in_array($alias,Config::$o->pool)) {
            self::$solidify[$alias] = $constructor;
        }
        return self::$pool[$alias] = $constructor;
    }
355616
public function invokeMethod($object, $name, array $args = [])
    {
        $method = new ReflectionMethod($object, $name);
        $method->setAccessible(true);

        if (empty($args)) {
            return $method->invoke($object);
        }

        return $method->invokeArgs($object, $args);
    }
647981
public static function getNamespacePath($namespace)
    {
        if('\\' !== substr($namespace, -1, 1))
        {
            $namespace .= '\\';
        }
        $loader = App::getLoader();
        if(null === $loader)
        {
            // Composer 加载器未赋值，则只能取Main类命名空间下的目录
            foreach(Helper::getMains() as $main)
            {
                $mainNamespace = $main->getNamespace();
                if('\\' !== substr($mainNamespace, -1, 1))
                {
                    $mainNamespace .= '\\';
                }
                $len = strlen($mainNamespace);
                if($mainNamespace === substr($namespace, 0, $len))
                {
                    $namespaceSubPath = substr($namespace, $len);
                    $refClass = new \ReflectionClass($main);
                    $path = dirname($refClass->getFileName());
                    $result = File::path($path, str_replace('\\', DIRECTORY_SEPARATOR, $namespaceSubPath));
                    break;
                }
            }
        }
        else
        {
            // 依靠 Composer PSR-4 配置的目录进行定位目录
            $prefixDirsPsr4 = $loader->getPrefixesPsr4();
            foreach($prefixDirsPsr4 as $keyNamespace => $paths)
            {
                $len = strlen($keyNamespace);
                if(substr($namespace, 0, $len) === $keyNamespace)
                {
                    if(isset($paths[1]))
                    {
                        return null;
                    }
                    $result = File::path($paths[0], str_replace('\\', DIRECTORY_SEPARATOR, substr($namespace, $len)));
                    break;
                }
            }
        }
        if(isset($result))
        {
            $realPath = realpath($result);
            if(false === $realPath)
            {
                return $result;
            }
            else
            {
                return $realPath;
            }
        }
        return null;
    }
585774
private function getByNamespace($namespace)
    {
        $this->checkForNonEmptyNamespace($namespace);

        if (!isset($this->configurations[$namespace])) {
            $this->configurations[$namespace]
                = $this->retrieveConfigurationFromTypoScriptSetup($namespace);
        }

        return $this->configurations[$namespace];
    }
1000441
public function registerNamespace($namespace, $paths)
    {
        if (false === isset($this->_namespaces[$namespace])) {
            $this->_namespaces[$namespace] = array();
        }

        $this->_namespaces[$namespace] = array_merge($this->_namespaces[$namespace], (array) $paths);

        return $this;
    }
931714
public function invokeStaticMethod($class, $name, array $args = [])
    {
        $method = new ReflectionMethod($class, $name);
        $method->setAccessible(true);

        if (empty($args)) {
            return $method->invoke(null);
        }

        return $method->invokeArgs(null, $args);
    }
680693
public function resolver($definition, array $args = [])
    {
        if ($definition instanceof Closure) {
            $resolvedDefinition = call_user_func_array($definition, $args);
        } elseif (is_object($definition)) {
            $resolvedDefinition = $definition;
        } elseif (is_string($definition)) {
            if (class_exists($definition)) {
                $reflectionObj = new ReflectionClass($definition);
                $resolvedDefinition = $reflectionObj->newInstanceArgs($args);
            } else {
                throw new Exception(sprintf('Class "%s" does not exist.', $definition));
            }
        } elseif (is_array($definition)) {
            $resolvedDefinition = self::fromArray($definition);
        } else {
            throw new Exception(sprintf('Definition type "%s" does not support.', gettype($definition)));
        }

        return $resolvedDefinition;
    }
900272
static function getClass($namespace = '',$config = [],$new = false){
	
		if($namespace == ''){
			return self::$instance;
		}
		
		if($new === false && isset(self::$instance[$namespace])){
			return self::$instance[$namespace];
		}
		
		$ns = self::getName($namespace);
		
		self::$instance[$namespace] = new $ns->namespace($config);
		
		return self::$instance[$namespace] ;
	}
423172
public function evaluateEntityNamespace(string $namespace)
    {
        /**
         * Trying to generate new entity given that the class is the entity
         * namespace.
         */
        if (class_exists($namespace)) {
            return $namespace;
        }

        /**
         * Trying to generate new entity given that the namespace is defined in
         * as a Container parameter.
         */
        $container = $this->container;
        if (
            $container->hasParameter($namespace) &&
            class_exists($container->getParameter($namespace))
        ) {
            $namespaceParameter = $container->getParameter($namespace);

            return $namespaceParameter;
        }

        $resolvedNamespace = explode(':', $namespace, 2);
        $bundles = $this->kernel->getBundles();

        /**
         * Trying to get entity using Doctrine short format.
         *
         * MyBundle:MyEntity
         *
         * To accept this format, entities must be at Entity/ folder in the
         * bundle root dir
         *
         * /MyBundle/Entity/MyEntity
         *
         * If entity definition is wrong, throw exception
         * If bundle not exists or is not actived, throw Exception
         */
        if (
        !(
            isset($resolvedNamespace[0]) &&
            isset($bundles[$resolvedNamespace[0]]) &&
            $bundles[$resolvedNamespace[0]] instanceof Bundle &&
            isset($resolvedNamespace[1])
        )
        ) {
            throw new ClassNotFoundException(
                $namespace,
                new ErrorException()
            );
        }

        /**
         * @var Bundle $bundle
         */
        $bundle = $bundles[$resolvedNamespace[0]];
        $bundleNamespace = $bundle->getNamespace();
        $namespace = $bundleNamespace . '\\Entity\\' . $resolvedNamespace[1];

        if (!class_exists($namespace)) {
            throw new ClassNotFoundException(
                $namespace,
                new ErrorException()
            );
        }

        /**
         * Otherwise, assume that class is namespace of class.
         */

        return $namespace;
    }
91979
public function make(string $namespace, array $arguments = [])
    {
        $class = $this->getClassNameFromNamespace($namespace);
        /*
         * If instance of the class already created and stored into
         * stack then simply return from here
         */
        if ($this->has($class)) {
            return $this->get($class);
        }
        $reflectionClass = $this->reflection->setClass($namespace)->getReflectionClass();
        $this->throwExceptionIfNotInstantiable($namespace, $reflectionClass);

        $constructor = null;
        $constructorArgsCount = 0;
        list($constructor, $constructorArgsCount) = $this->getConstructorArgs($reflectionClass, $constructorArgsCount);

        // if class does not have explicitly defined constructor or constructor
        // does not have parameters get the new instance
        if (!isset($constructor) && is_null($constructor) || $constructorArgsCount < 1) {
            return $this[$class] = $reflectionClass->newInstance();
        }

        $dependencies = $constructor->getParameters();
        $constructorArgs = $this->createMethodArgument($dependencies, $arguments);

        return $this[$class] = $reflectionClass->newInstanceArgs($constructorArgs);
    }
167948
private static function createObject($className, array $args = null)
    {
        try {
            if (!$args) {
                return new $className;
            } else {
                $c = new \ReflectionClass($className);
                return $c->newInstanceArgs($args);
            }
        } catch (\Exception $e) {
            throw new RuntimeException($e->getMessage(), $e->getCode(), $e);
        }
    }
460820
public function createInstance(array $args = array())
    {
        $generatedClass = $this->getClassName($this->class);

        if (!class_exists($generatedClass, false)) {
            eval($this->generateClass());
        }

        $ref = new \ReflectionClass($generatedClass);

        return $ref->newInstanceArgs($args);
    }
252826
public function getNamespace()
    {
        if (!isset($this->namespace)) {
            $reflectionClass = new \ReflectionClass($this->name);
            $this->namespace = $reflectionClass->getNamespaceName();
        }
        return $this->namespace;
    }
589819
public function getField( array $args = [] )
	{
		if( empty( $args )) {
			$args = $this->args;
		}

		$className = sprintf( 'GeminiLabs\Castor\Forms\Fields\%s', ucfirst( $args['type'] ));

		if( !class_exists( $className )) {
			throw new ReflectionException( "Class does not exist: {$className}" );
		}

		return (new $className( $args ));
	}
366395
static public function create(string $namespace, string $mosaic = null)
    {
        if (empty($mosaic)) {
            // `namespace` should contain `FQN`
            $fullyQualifiedName = $namespace;
            $splitRegexp = "/([^:]+):([^:]+)/";

            // split with format: `namespace:mosaic`
            $namespace = preg_replace($splitRegexp, "$1", $fullyQualifiedName);
            $mosaic    = preg_replace($splitRegexp, "$2", $fullyQualifiedName);
        }

        if (empty($namespace) || empty($mosaic)) {
            throw new RuntimeException("Missing namespace or mosaic name for \\NEM\\Models\\Mosaic instance.");
        }

        return new static([
            "namespaceId" => $namespace,
            "name" => $mosaic
        ]);
    }