protected static function addReflectionArguments(Definition $factory, ReflectionFunctionAbstract $reflectionFunction = null)
	{
		if (!$reflectionFunction) {
			$callable = $factory->getCallable();

			if (is_array($callable)) {
				$reflectionFunction = new ReflectionMethod($callable[0], $callable[1]);
			} else {
				$reflectionFunction = new ReflectionFunction($callable);
			}
		}

		foreach ($reflectionFunction->getParameters() as $arg) {
			try {
				$name = $arg->getName();
				$required = ! $arg->isOptional();
				if ($argClass = $arg->getClass()) {
					$factory->addClassArgument($name, $argClass->getName(), $required);
				} else {
					$default = ($required ? null : $arg->getDefaultValue());
					$factory->addScalarArgument($name, null, $required, $default);
				}
			} catch (ReflectionException $re) {
				throw UnresolvableArgumentException::fromReflectionParam(
					$arg, $reflectionFunction, $re);
			}
		}
	}