classes/Container.php
protected function resolveClassArg(ReflectionClass $class, ReflectionParameter $param, array $params)
	{
		$name = '$'.$param->getName();
		$class = $class->getName();

		// loop to prevent code repetition. executes once trying to find the
		// parameter name in the $params array, then once more trying to find
		// the class name (typehint) of the parameter.
		while ($name !== null) {
			if ($params && array_key_exists($name, $params)) {
				$class = $params[$name];
			}

			if ($class instanceof Factory\FactoryInterface) {
				return $class->invoke($this);
			}

			if (is_object($class)) {
				return $class;
			}

			$name = ($name != $class) ? $class : null;
		}

		try {
			return $this->resolve($class);
		} catch (ReflectionException $exception) {
			if ($param->isOptional()) {
				return null;
			}

			throw $exception;
		}
	}
protected function resolveClassArg(ReflectionClass $class, ReflectionParameter $param, array $params)
	{
		$name = '$'.$param->getName();
		$class = $class->getName();

		// loop to prevent code repetition. executes once trying to find the
		// parameter name in the $params array, then once more trying to find
		// the class name (typehint) of the parameter.
		while ($name !== null) {
			if ($params && array_key_exists($name, $params)) {
				$class = $params[$name];
			}

			if ($class instanceof Factory\FactoryInterface) {
				return $class->invoke($this);
			}

			if (is_object($class)) {
				return $class;
			}

			$name = ($name != $class) ? $class : null;
		}

		try {
			return $this->resolve($class);
		} catch (ReflectionException $exception) {
			if ($param->isOptional()) {
				return null;
			}

			throw $exception;
		}
	}
Resolve a class type-hinted argument for a funtion.

@param  ReflectionClass     $class
@param  ReflectionParameter $param
@param  array               $params

@return object|null