Returns a new instance of the given class

@param string $className
@param array  $constructorArguments
@param string $implementationClassName
@return object
556020
private function createWithArguments(
        string $className,
        array $constructorArguments,
        &$implementationClassName = null
    ) {
        if (interface_exists($className)) {
            $className = $implementationClassName = $this->getClassForInterface($className);
        }
        if (!class_exists($className)) {
            throw ClassDoesNotExistException::exceptionWithClassName($className);
        }
        if ($constructorArguments) {
            $reflector = new ReflectionClass($className);

            return $reflector->newInstanceArgs($constructorArguments);
        }

        return new $className();
    }
260877
protected function getReflectionMethod($className, $methodName = '__construct') {
		if (isset($this->reflectionMethods[$className])
			&& array_key_exists($methodName, $this->reflectionMethods[$className])
		) {
			return $this->reflectionMethods[$className][$methodName];
		}

		try {
			$reflectionClass = $this->getReflectionClass($className);
			if ($methodName === '__construct') {
				$reflectionMethod = $reflectionClass->getConstructor();
			} else {
				$reflectionMethod = $reflectionClass->getMethod($methodName);
			}
			$this->reflectionMethods[$className][$methodName] = $reflectionMethod;
		} catch (ReflectionException $e) {
			throw new NotFoundException("Method $className::$methodName is not found");
		}

		return $reflectionMethod;
	}
778129
public function newClass($className)
    {
        if ($this->container->has($className)) {
            return $this->container[$className];
        }

        $dependentStruct = new DependentStruct($this->container, $className);
        $this->container[$className] = $dependentStruct;
        return $dependentStruct;
    }
86902
public function isInstanceOf($className)
    {
        $this->doCheck(function ($value) use ($className) {
            $this->throwExceptionIfFalse(
                $value instanceof $className,
                'Failed assertion that %s is an instance of %s', $value, $className
            );
        });

        return $this;
    }
1005001
public function newInstance($className, array $args = array())
    {
        return $this->getApplication()->search(ProviderInterface::IDENTIFIER)->newInstance($className, $args);
    }
580792
public static function getInstance($config, $classname = 'IDS_Log_Database')
    {
        if ($config instanceof IDS_Init) {
            $wrapper = $config->config['Logging']['wrapper'];
        } elseif (is_array($config)) {
            $wrapper = $config['wrapper'];
        }

        if (!isset(self::$instances[$wrapper])) {
            self::$instances[$wrapper] = new $classname($config);
        }

        return self::$instances[$wrapper];
    }
814054
public function createClass($classname)
    {
        // Check for possible overwrite.
        if (isset($this->rewrite[$classname]) === true) {
            $classname = $this->rewrite[$classname];
        }

        return new $classname($this);
    }
1251249
public static function fromClass($className)
    {
        return new self(
            \Pheasant::instance()->schema($className),
            \Pheasant::instance()->finderFor($className)
        );
    }
541286
protected static function getObject($className)
    {
        if (!isset(self::$instances[$className])) {
            self::$instances[$className] = self::createObject($className);
        }

        return self::$instances[$className];
    }
282235
public function create(string $className, string $typeName): Type
    {
        $description = $this->getDescription($className);

        $fieldsGetter = function () use ($className): array {
            $factory = new InputFieldsConfigurationFactory($this->types, $this->entityManager);
            $configuration = $factory->create($className);

            return $configuration;
        };

        return new InputObjectType([
            'name' => $typeName,
            'description' => $description,
            'fields' => $fieldsGetter,
        ]);
    }
301454
public static DocumentBuilderFactory newInstance(String factoryClassName,
            ClassLoader classLoader) {
        if (factoryClassName == null) {
            throw new FactoryConfigurationError("factoryClassName == null");
        }
        if (classLoader == null) {
            classLoader = Thread.currentThread().getContextClassLoader();
        }
        try {
            Class<?> type = classLoader != null
                    ? classLoader.loadClass(factoryClassName)
                    : Class.forName(factoryClassName);
            return (DocumentBuilderFactory) type.newInstance();
        } catch (ClassNotFoundException e) {
            throw new FactoryConfigurationError(e);
        } catch (InstantiationException e) {
            throw new FactoryConfigurationError(e);
        } catch (IllegalAccessException e) {
            throw new FactoryConfigurationError(e);
        }
    }
900696
private static function createInstance($classname, array $arguments = array())
    {
        $reflection_obj = new ReflectionClass($classname);
        if ($reflection_obj->getMethod('__construct')->isPublic()) {
            self::$_instances[ $classname ] = call_user_func_array(array($reflection_obj, 'newInstance'), $arguments);
            if (
                method_exists(self::$_instances[ $classname ], 'init') &&
                is_callable(array(self::$_instances[ $classname ], 'init'))
            ) {
                self::$_instances[ $classname ]->init();
            }
        } else {
            self::$_instances[ $classname ] = new $classname;
            if (
                method_exists(self::$_instances[ $classname ], 'init') &&
                is_callable(array(self::$_instances[ $classname ], 'init'))
            ) {
                call_user_func_array(array(self::$_instances[ $classname ], 'init'), $arguments);
            }
        }
    }
1218170
public static function getInstance(...$constructorParams)
    {
        $class = get_called_class();
        if (isset(static::$instanceOfClass[$class])) {
            return static::$instanceOfClass[$class];
        }
        static::$instanceOfClass[$class] = $nstnc = new static(...$constructorParams);
        return $nstnc;
    }
331343
public function cloneInstance($className): self
	{
		// Determine the class to load
		$instanceName = strtolower($className);

		if (!isset($this->{$instanceName}))
		{
			throw new FactoryException("Could not clone instance of '".$instanceName."'. Instance was not found.", 1);
		}

		// Clone the instance
		$this->{$instanceName} = clone $this->{$instanceName};

		// Return itself
		return $this;
	}
516371
protected function createClass(string $className)
    {
        if (!class_exists($className)) {
            throw new class("The class $className does not exists") extends Exception implements
                NotFoundExceptionInterface {
            };
        }

        $reflection = new ReflectionClass($className);

        if ($reflection->hasMethod('__construct')) {
            return $reflection->newInstanceArgs($this->arguments);
        }

        return $reflection->newInstance();
    }
829146
public function initiateObject($className, $additionalParameters = array(), $shared = false)
    {
        if (isset($this->sharedInstances[$className])) {
            return $this->sharedInstances[$className];
        }
        
        $reflection = new ReflectionClass($className);
        
        if ($reflection->hasMethod('__construct')) {
            $constructor = $reflection->getConstructor();
            $parameters = $this->prepareParameters($constructor, $additionalParameters);
            
            $instance = $reflection->newInstanceArgs($parameters);
        } else {
            $instance = new $className();
        }
        
        if ($shared) {
            $this->sharedInstances[$className] = $instance;
        }
        
        return $instance;
    }
915929
public function create(string $className, string $typeName): Type
    {
        $type = new InputObjectType([
            'name' => $typeName,
            'fields' => function () use ($className): array {
                $fields = [
                    [
                        'name' => 'type',
                        'type' => $this->types->get('JoinType'),
                        'defaultValue' => 'innerJoin',
                    ],
                    $this->filterGroupConditionTypeFactory->getField($className),
                ];

                // Only create join type, if there is anything to join on
                if ($this->filterGroupJoinTypeFactory->canCreate($className)) {
                    $fields[] = $this->filterGroupJoinTypeFactory->getField($className);
                }

                return $fields;
            },
        ]);

        return $type;
    }