protected function buildMethodArgumentsArrayCode(string $className = null, string $methodName = null, bool $useArgumentsArray = false): string
    {
        if ($className === null || $methodName === null) {
            return '';
        }

        $argumentsArrayCode = "\n                \$methodArguments = [];\n";

        $methodParameters = $this->reflectionService->getMethodParameters($className, $methodName);
        if (count($methodParameters) > 0) {
            $argumentsArrayCode .= "\n";
            $argumentIndex = 0;
            foreach ($methodParameters as $methodParameterName => $methodParameterInfo) {
                if ($useArgumentsArray) {
                    $argumentsArrayCode .= "                if (array_key_exists(" . $argumentIndex . ", \$arguments)) \$methodArguments['" . $methodParameterName . "'] = \$arguments[" . $argumentIndex . "];\n";
                } else {
                    $argumentsArrayCode .= "                \$methodArguments['" . $methodParameterName . "'] = ";
                    $argumentsArrayCode .= $methodParameterInfo['byReference'] ? '&' : '';
                    $argumentsArrayCode .= '$' . $methodParameterName . ";\n";
                }
                $argumentIndex ++;
            }
            $argumentsArrayCode .= "            ";
        }
        return $argumentsArrayCode;
    }