Create cache directly without config / injector

@param string $class
@param array $args
@return CacheInterface
194663
public function createCache($class, $args)
    {
        /** @var CacheInterface $cache */
        $reflection = new ReflectionClass($class);
        $cache = $reflection->newInstanceArgs($args);

        // Assign cache logger
        if ($this->logger && $cache instanceof LoggerAwareInterface) {
            $cache->setLogger($this->logger);
        }

        return $cache;
    }
636048
public function newInstance($className, array $args = array())
    {

        // load the reflection data for the passed class name
        $reflectionClass = $this->getReflectionClass($className);

        // query whether or not the class has a constructor
        if ($reflectionClass->hasMethod($methodName = '__construct') &&
            $reflectionClass->getMethod($methodName)->getParameters() &&
            sizeof($args) > 0
        ) {
            return $reflectionClass->newInstanceArgs($args);
        }

        // return the instance without calling the constructor
        return $reflectionClass->newInstance();
    }
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);
    }
282574
public static function create($class)
    {
        try {
            $reflection = new \ReflectionClass($class);
        } catch (\ReflectionException $e) {
            return false;
        }

        $constructor = $reflection->getConstructor();

        // If there are no parameters, just return a new object.
        if (null === $constructor) {
            return new $class;
        }

        $newInstanceArgs = self::getMethodArgs($constructor);

        // Create a callable for the dataStorage
        return $reflection->newInstanceArgs($newInstanceArgs);
    }
1343788
private function createInstance(string $class, array $parameters, string $context = null)
    {
        $reflection = new \ReflectionClass($class);

        //We have to construct class using external injector when we know exact context
        if (empty($parameters) && $this->hasInjector($reflection)) {
            $instance = $this->getInjector($reflection)->createInjection($reflection, $context);

            if (!$reflection->isInstance($instance)) {
                throw new InjectionException("Invalid injection response for '{$reflection->getName()}'");
            }

            return $instance;
        }

        if (!$reflection->isInstantiable()) {
            throw new ContainerException("Class '{$class}' can not be constructed");
        }

        if (!empty($constructor = $reflection->getConstructor())) {
            //Using constructor with resolved arguments
            $instance = $reflection->newInstanceArgs(
                $this->resolveArguments($constructor, $parameters)
            );
        } else {
            //No constructor specified
            $instance = $reflection->newInstance();
        }

        return $instance;
    }
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);
    }
1240655
protected static function checkInternalClass($instance, $class, array $args = [])
    {
        if (null !== $instance) {
            return;
        }

        $messages = [];
        foreach ($args as $name => $value) {
            $messages[] = sprintf('%s => %s', $name, $value);
        }

        throw new \RuntimeException(sprintf(
            'Unable to create internal class: %s, with params: %s',
            $class,
            implode(', ', $messages)
        ));
    }
662662
private function createInstance(string $class, array $parameters, string $context = null)
    {
        try {
            $reflection = new \ReflectionClass($class);
        } catch (\ReflectionException $e) {
            throw new ContainerException($e->getMessage(), $e->getCode(), $e);
        }

        //We have to construct class using external injector when we know exact context
        if (empty($parameters) && $this->hasInjector($reflection)) {
            $instance = $this->getInjector($reflection)->createInjection($reflection, $context);

            if (!$reflection->isInstance($instance)) {
                throw new InjectionException(sprintf(
                    "Invalid injection response for '%s'",
                    $reflection->getName()
                ));
            }

            return $instance;
        }

        if (!$reflection->isInstantiable()) {
            throw new ContainerException(sprintf("Class '%s' can not be constructed", $class));
        }

        if (!empty($constructor = $reflection->getConstructor())) {
            //Using constructor with resolved arguments
            $instance = $reflection->newInstanceArgs(
                $this->resolveArguments($constructor, $parameters)
            );
        } else {
            //No constructor specified
            $instance = $reflection->newInstance();
        }

        return $instance;
    }
551461
public function createObject($class, array $args = [], $shared = false, $protected = false)
    {
        $callback = function (Container $container) use ($class, $args) {
            return $container->newInstance($class, $args);
        };

        return $this->set($class, $callback, $shared, $protected)->get($class);
    }
1335516
protected function instantiator(string $class): InstantiatorInterface
    {
        if (isset($this->instantiators[$class])) {
            return $this->instantiators[$class];
        }

        //Potential optimization
        $instantiator = $this->getFactory()->make(
            $this->define($class, self::D_INSTANTIATOR),
            [
                'class'  => $class,
                'odm'    => $this,
                'schema' => $this->define($class, self::D_SCHEMA)
            ]
        );

        //Constructing instantiator and storing it in cache
        return $this->instantiators[$class] = $instantiator;
    }
1336879
protected function createInstance(string $name, ReflectionClass $class, array $arguments, array $config)
    {
        if (true === $config['lazy']) {
            return $this->getProxyInstance($name, $class, $arguments, $config);
        }

        return $this->getRealInstance($name, $class, $arguments, $config);
    }
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;
    }
806090
protected function callProxy($class, $method, array $args)
    {
        $new = $this->cloneInstance();

        $ref = new \ReflectionMethod($class, $method);
        $params = $ref->getParameters();
        array_shift($params);

        /** @var \ReflectionParameter $param */
        foreach (array_values($params) as $k => $param) {
            if (!array_key_exists($k, $args)) {
                if ($param->getName() === 'encoding' && !isset($args[$k])) {
                    $args[$k] = $this->encoding;
                    continue;
                }

                $args[$k] = $param->getDefaultValue();
            }
        }

        array_unshift($args, $new->string);

        $result = call_user_func_array([$class, $method], $args);

        if (is_string($result)) {
            $new->string = $result;

            return $new;
        }

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

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

        return IOC::make($class, [$options, true]);
    }
881408
public static function getInstance($class, array $args, array $conf, string $confHash) {
        $rfClass = new ReflectionClass($class);
        if (!$rfClass->implementsInterface(IComponent::class)) {
            throw new InvalidArgumentException("class $class is not an instance of x2ts\\IComponent");
        }
        if ($rfClass->hasMethod('getInstance')) {
            return $rfClass->getMethod('getInstance')
                ->invoke(null, $args, $conf, $confHash);
        }
        /** @var IComponent $component */
        $component = $rfClass->newInstanceArgs($args);
        $rfClass->getMethod('saveConf')->invoke($component, $conf, $confHash);
        if ($rfClass->hasMethod('init')) {
            $rfClass->getMethod('init')->invoke($component);
        }
        return $component;
    }
1303048
public function make($concrete, array $args = [])
    {
        // build only from strings
        if (!is_object($concrete) && !is_scalar($concrete) && !is_null($concrete)) {
            throw new Exceptions\InvalidArgumentException();
        }

        // get reflection and parameters
        $reflection = new \ReflectionClass($concrete);
        $constructor = $reflection->getConstructor();

        // Return new instance
        $arguments = $constructor ? $this->inject($constructor, $args) : [];
        return $reflection->newInstanceArgs($arguments);
    }
473076
public function make(string $class, array $args = [], bool $protected = false)
    {
        /** @var Container $container */
        $container = $this->getContainer();

        return $container->createSharedObject($class, $args, $protected);
    }