public static function replaceExisting(array $array1, array $array2, bool $recursive = false): array
    {
        foreach ($array1 as $key => $value) {
            if (array_key_exists($key, $array2)) {
                $value2 = $array2[$key];
                if ($recursive && is_array($value)) {
                    $value2 = self::replaceExisting($value, $value2, $recursive);
                }
                $array1[$key] = $value2;
            }
        }

        return $array1;
    }