PHP 8.0.0, released on November 26, 2020, changes how call_user_func_array passes an array of arguments to a callback—the function it is asked to invoke. String keys in that array now identify parameter names instead of being ignored. For application teams upgrading PHP, this means an existing call can behave differently even if nobody rewrites it. The release's upgrade notes flag the change as backward-incompatible. [D1][S4][S3]
Named arguments let callers skip optional parameters and supply named values independently of the parameters' declared order. PHP's announcement presents those as benefits of the new feature. For existing call_user_func_array code, the migration check is whether a string key deliberately names a parameter or is merely a label that previously had no effect on the call. [S1][S4][S3]
The test shipped with PHP 8.0.0 makes the distinction concrete. It defines a callback with parameters a, b and c, each defaulting to its own lowercase letter. Passing positional value A followed by a named c value of C is expected to produce a=A, b=b and c=C: the middle parameter keeps its default. A separate case uses integer keys 1 and then 0, with values A and B. Its expected result is a=A and b=B, with c unchanged. Those integer keys do not select parameter numbers or sort the values into numeric-key order. [S3]
Other cases in the same release test specify errors. Sending a key named d to that a/b/c callback produces an unknown-named-parameter error; putting a positional value after a named c argument is also rejected. The callback's declaration matters, however. A variadic callback, which collects a variable number of arguments, is tested with both positional A and named c=C. Its expected collection retains the c key. An unfamiliar name is therefore not automatically an error for every callback. [S3]
For a migration review, inspect the code building the argument array alongside the callback's parameter declaration. Keep deliberate name-based binding; where keys were merely labels, make the intended positional sequence explicit before passing the array. Exercise those callback paths on the new runtime rather than relying on application startup alone. A test containing only zero-based integer keys will not exercise the string-key behavior that changed. [S4][S3]
Source documents
- PHP 8.0.0 Released! — 26 November 2020 archive entryhttps://www.php.net/archive/2020.php
- PHP 8.0 Release Announcement Addendumhttps://www.php.net/releases/8.0/en.php
- PHP 8.0.0 Zend test: call_user_func_array with named parametershttps://raw.githubusercontent.com/php/php-src/5dc92c2117cafc61daaaaa240fd46c3ac33872a4/Zend/tests/named_params/call_user_func_array.phpt
- PHP 8.0.0 UPGRADING — backward-incompatible changeshttps://raw.githubusercontent.com/php/php-src/5dc92c2117cafc61daaaaa240fd46c3ac33872a4/UPGRADING
