phpphp-5.5

How can you downgrade PHP 7's parameter unpacking to v5.5?


I need to down port one of my most popular PHP packages from 7.0 to 5.5, and it's been years and years since I wrote PHP 5.5 code and I cannot figure out this bit:

$options = array_merge_recursive(
    $userOptions,
    ...$guzzleAuthOptions
);

Is it even possible? I vaguely remember writing this sort of stuff in PHP 5.5 or earlier, but it was quite uncommon for me to do so.

In case it helps, the full context of the code is https://github.com/phpexpertsinc/RESTSpeaker/blob/master/src/HTTPSpeaker.php#L56


Solution

  • Splat operator (three dots) was introduced in 5.6. You should not downgrade anything.

    At the same time, for 5.5 and below you may use call_user_func_array.