private function getFunctionParameters(\ReflectionFunctionAbstract $function, array $parameters = []) : array
    {
        $result = [];

        foreach ($function->getParameters() as $parameter) {
            $name = $parameter->getName();

            if (array_key_exists($name, $parameters)) {
                $value = $parameters[$name];
            } else {
                $value = $this->resolver->getParameterValue($parameter);
            }

            if ($parameter->isVariadic()) {
                $result = array_merge($result, $value);
            } else {
                $result[] = $value;
            }
        }

        return $result;
    }