src/Message/Server/UploadedFilesFactory.php
private function arrayMergeRecursive($array1, $array2)
    {
        if (!is_array($array1) or !is_array($array2)) {
            return $array2;
        }

        foreach ($array2 as $sKey2 => $sValue2) {
            $array1[$sKey2] = $this->arrayMergeRecursive(@$array1[$sKey2], $sValue2);
        }
        return $array1;
    }
private function arrayMergeRecursive($array1, $array2)
    {
        if (!is_array($array1) or !is_array($array2)) {
            return $array2;
        }

        foreach ($array2 as $sKey2 => $sValue2) {
            $array1[$sKey2] = $this->arrayMergeRecursive(@$array1[$sKey2], $sValue2);
        }
        return $array1;
    }
Recursively merge provided arrays

@param array|string $array1
@param array|string $array2

@return array