src/foundation/dependency-injection/Container.php
public static function newInstance($class) {
		$className = str_replace(':', '\\', $class);
		$reflectedClass = new ReflectionClass($className);

		if ($reflectedClass->isInstantiable()) {
			$constructor = $reflectedClass->getConstructor();

			if ($constructor) {
				$parameters = $constructor->getParameters();
				$constructorParameters = array();

				foreach ($parameters as $parameter) {
					if ($parameter->getClass()) {
						$constructorParameters[] = self::newInstance($parameter->getClass()->getName());
					} else {
						$constructorParameters[] = $parameter->getDefaultValue();
					}
				}

				return $reflectedClass->newInstanceArgs($constructorParameters);
			} else {
				return $reflectedClass->newInstance();
			}

		} else {
			throw new Exception($class." is not instantiable Class");
		}
	}
public static function newInstance($class) {
		$className = str_replace(':', '\\', $class);
		$reflectedClass = new ReflectionClass($className);

		if ($reflectedClass->isInstantiable()) {
			$constructor = $reflectedClass->getConstructor();

			if ($constructor) {
				$parameters = $constructor->getParameters();
				$constructorParameters = array();

				foreach ($parameters as $parameter) {
					if ($parameter->getClass()) {
						$constructorParameters[] = self::newInstance($parameter->getClass()->getName());
					} else {
						$constructorParameters[] = $parameter->getDefaultValue();
					}
				}

				return $reflectedClass->newInstanceArgs($constructorParameters);
			} else {
				return $reflectedClass->newInstance();
			}

		} else {
			throw new Exception($class." is not instantiable Class");
		}
	}
public static function newInstance ( $ class ) { $ className = str_replace ( ':' , '\\' , $ class ) ; $ reflectedClass = new ReflectionClass ( $ className ) ; if ( $ reflectedClass -> isInstantiable ( ) ) { $ constructor = $ reflectedClass -> getConstructor ( ) ; if ( $ constructor ) { $ parameters = $ constructor -> getParameters ( ) ; $ constructorParameters = array ( ) ; foreach ( $ parameters as $ parameter ) { if ( $ parameter -> getClass ( ) ) { $ constructorParameters [ ] = self :: newInstance ( $ parameter -> getClass ( ) -> getName ( ) ) ; } else { $ constructorParameters [ ] = $ parameter -> getDefaultValue ( ) ; } } return $ reflectedClass -> newInstanceArgs ( $ constructorParameters ) ; } else { return $ reflectedClass -> newInstance ( ) ; } } else { throw new Exception ( $ class . " is not instantiable Class" ) ; } }
An instance factory method

@param string $class Full class name with used : as namespace separator

@return mixed
An instance factory method