protected function prepareParameters(ReflectionMethod $constructor, $additionalParameters)
    {
        $parameters = array();
        foreach ($constructor->getParameters() as $parameter) {
            $parameterValue = null;
        
            if (isset($additionalParameters[$parameter->name])) {
                $parameterValue = $additionalParameters[$parameter->name];
            } else if ($parameter->getClass() !== null) {
                $parameterValue = $this->getInstance($parameter->getClass());
            }
        
            if ($parameterValue === null) {
                throw new Exception('Cannot find correct value for parameter "' . $parameter->name . '" in class "' . $constructor->class . '".');
            }
        
            $parameters[] = $parameterValue;
        }
        
        return $parameters;
    }