lib/private/AppFramework/Utility/SimpleContainer.php
/**
	 * @param ReflectionClass $class the class to instantiate
	 * @return \stdClass the created class
	 */
@param ReflectionClass $class the class to instantiate
@return \stdClass the created class
@param ReflectionClass $class the class to instantiate @return \ stdClass the created class
private function buildClass(ReflectionClass $class) {
		$constructor = $class->getConstructor();
		if ($constructor === null) {
			return $class->newInstance();
		} else {
			$parameters = [];
			foreach ($constructor->getParameters() as $parameter) {
				$parameterClass = $parameter->getClass();
				if ($parameterClass === null) {
					$resolveName = $parameter->getName();
				} else {
					$resolveName = $parameterClass->name;
				}
				try {
					$parameters[] = $this->query($resolveName);
				} catch (\Exception $e) {
					if ($parameter->isDefaultValueAvailable()) {
						$parameters[] = $parameter->getDefaultValue();
					} else if ($parameterClass !== null) {
						$resolveName = $parameter->getName();
						$parameters[] = $this->query($resolveName);
					} else {
						throw $e;
					}
				}
			}
			return $class->newInstanceArgs($parameters);
		}
	}
private function buildClass ( ReflectionClass $ class ) { $ constructor = $ class -> getConstructor ( ) ; if ( $ constructor === null ) { return $ class -> newInstance ( ) ; } else { $ parameters = [ ] ; foreach ( $ constructor -> getParameters ( ) as $ parameter ) { $ parameterClass = $ parameter -> getClass ( ) ; if ( $ parameterClass === null ) { $ resolveName = $ parameter -> getName ( ) ; } else { $ resolveName = $ parameterClass -> name ; } try { $ parameters [ ] = $ this -> query ( $ resolveName ) ; } catch ( \ Exception $ e ) { if ( $ parameter -> isDefaultValueAvailable ( ) ) { $ parameters [ ] = $ parameter -> getDefaultValue ( ) ; } else if ( $ parameterClass !== null ) { $ resolveName = $ parameter -> getName ( ) ; $ parameters [ ] = $ this -> query ( $ resolveName ) ; } else { throw $ e ; } } } return $ class -> newInstanceArgs ( $ parameters ) ; } }
@param ReflectionClass $class the class to instantiate
 @return \stdClass the created class
@param ReflectionClass $class the class to instantiate @return \ stdClass the created class
// try to find out if it is a class or a simple parameter // Service not found, use the default value when available