1--TEST-- 2Trampoline closure created from magic method accepts named arguments 3--FILE-- 4<?php 5 6class Test { 7 public function __call($name, $args) { 8 var_dump($name, $args); 9 } 10 public static function __callStatic($name, $args) { 11 var_dump($name, $args); 12 } 13} 14 15$test = new Test; 16 17$array = ["unpacked"]; 18 19echo "-- Non-static cases --\n"; 20$test->test(1, 2, a: 123); 21$test->test(...)(1, 2); 22$test->test(...)(1, 2, a: 123, b: $test); 23$test->test(...)(a: 123, b: $test); 24$test->test(...)(); 25$test->test(...)(...$array); 26 27echo "-- Static cases --\n"; 28Test::testStatic(1, 2, a: 123); 29Test::testStatic(...)(1, 2); 30Test::testStatic(...)(1, 2, a: 123, b: $test); 31Test::testStatic(...)(a: 123, b: $test); 32Test::testStatic(...)(); 33Test::testStatic(...)(...$array); 34 35echo "-- Reflection tests --\n"; 36$reflectionFunction = new ReflectionFunction(Test::fail(...)); 37var_dump($reflectionFunction->getParameters()); 38$argument = $reflectionFunction->getParameters()[0]; 39var_dump($argument->isVariadic()); 40$type = $argument->getType(); 41var_dump($type); 42var_dump($type->getName()); 43 44?> 45--EXPECT-- 46-- Non-static cases -- 47string(4) "test" 48array(3) { 49 [0]=> 50 int(1) 51 [1]=> 52 int(2) 53 ["a"]=> 54 int(123) 55} 56string(4) "test" 57array(2) { 58 [0]=> 59 int(1) 60 [1]=> 61 int(2) 62} 63string(4) "test" 64array(4) { 65 [0]=> 66 int(1) 67 [1]=> 68 int(2) 69 ["a"]=> 70 int(123) 71 ["b"]=> 72 object(Test)#1 (0) { 73 } 74} 75string(4) "test" 76array(2) { 77 ["a"]=> 78 int(123) 79 ["b"]=> 80 object(Test)#1 (0) { 81 } 82} 83string(4) "test" 84array(0) { 85} 86string(4) "test" 87array(1) { 88 [0]=> 89 string(8) "unpacked" 90} 91-- Static cases -- 92string(10) "testStatic" 93array(3) { 94 [0]=> 95 int(1) 96 [1]=> 97 int(2) 98 ["a"]=> 99 int(123) 100} 101string(10) "testStatic" 102array(2) { 103 [0]=> 104 int(1) 105 [1]=> 106 int(2) 107} 108string(10) "testStatic" 109array(4) { 110 [0]=> 111 int(1) 112 [1]=> 113 int(2) 114 ["a"]=> 115 int(123) 116 ["b"]=> 117 object(Test)#1 (0) { 118 } 119} 120string(10) "testStatic" 121array(2) { 122 ["a"]=> 123 int(123) 124 ["b"]=> 125 object(Test)#1 (0) { 126 } 127} 128string(10) "testStatic" 129array(0) { 130} 131string(10) "testStatic" 132array(1) { 133 [0]=> 134 string(8) "unpacked" 135} 136-- Reflection tests -- 137array(1) { 138 [0]=> 139 object(ReflectionParameter)#4 (1) { 140 ["name"]=> 141 string(9) "arguments" 142 } 143} 144bool(true) 145object(ReflectionNamedType)#5 (0) { 146} 147string(5) "mixed" 148