1--TEST--
2Behavior of call_user_func_array() with named parameters
3--FILE--
4<?php
5
6namespace {
7    $test = function($a = 'a', $b = 'b', $c = 'c') {
8        echo "a = $a, b = $b, c = $c\n";
9    };
10    $test_variadic = function(...$args) {
11        var_dump($args);
12    };
13
14    call_user_func_array($test, ['A', 'B']);
15    call_user_func_array($test, [1 => 'A', 0 => 'B']);
16    call_user_func_array($test, ['A', 'c' => 'C']);
17    call_user_func_array($test_variadic, ['A', 'c' => 'C']);
18    try {
19        call_user_func_array($test, ['d' => 'D']);
20    } catch (\Error $e) {
21        echo $e->getMessage(), "\n";
22    }
23    try {
24        call_user_func_array($test, ['c' => 'C', 'A']);
25    } catch (\Error $e) {
26        echo $e->getMessage(), "\n";
27    }
28    echo "\n";
29}
30
31namespace Foo {
32    call_user_func_array($test, ['A', 'B']);
33    call_user_func_array($test, [1 => 'A', 0 => 'B']);
34    call_user_func_array($test, ['A', 'c' => 'C']);
35    call_user_func_array($test_variadic, ['A', 'c' => 'C']);
36    try {
37        call_user_func_array($test, ['d' => 'D']);
38    } catch (\Error $e) {
39        echo $e->getMessage(), "\n";
40    }
41    try {
42        call_user_func_array($test, ['c' => 'C', 'A']);
43    } catch (\Error $e) {
44        echo $e->getMessage(), "\n";
45    }
46}
47
48?>
49--EXPECT--
50a = A, b = B, c = c
51a = A, b = B, c = c
52a = A, b = b, c = C
53array(2) {
54  [0]=>
55  string(1) "A"
56  ["c"]=>
57  string(1) "C"
58}
59Unknown named parameter $d
60Cannot use positional argument after named argument
61
62a = A, b = B, c = c
63a = A, b = B, c = c
64a = A, b = b, c = C
65array(2) {
66  [0]=>
67  string(1) "A"
68  ["c"]=>
69  string(1) "C"
70}
71Unknown named parameter $d
72Cannot use positional argument after named argument
73