1--TEST-- 2Allow trailing commas in function and method calls 3--FILE-- 4<?php 5function foo(...$args) { 6 echo __FUNCTION__ . "\n"; 7 var_dump($args); 8} 9foo( 10 'function', 11 'bar', 12); 13 14class Foo 15{ 16 public function __construct(...$args) { 17 echo __FUNCTION__ . "\n"; 18 var_dump($args); 19 } 20 21 public function bar(...$args) { 22 echo __FUNCTION__ . "\n"; 23 var_dump($args); 24 } 25 26 public function __invoke(...$args) { 27 echo __FUNCTION__ . "\n"; 28 var_dump($args); 29 } 30} 31 32$foo = new Foo( 33 'constructor', 34 'bar', 35); 36 37$foo->bar( 38 'method', 39 'bar', 40); 41 42$foo( 43 'invoke', 44 'bar', 45); 46 47$bar = function(...$args) { 48 echo __FUNCTION__ . "\n"; 49 var_dump($args); 50}; 51 52$bar( 53 'closure', 54 'bar', 55); 56 57# Make sure to hit the "not really a function" language constructs 58unset($foo, $bar,); 59var_dump(isset($foo, $bar,)); 60?> 61--EXPECTF-- 62foo 63array(2) { 64 [0]=> 65 string(8) "function" 66 [1]=> 67 string(3) "bar" 68} 69__construct 70array(2) { 71 [0]=> 72 string(11) "constructor" 73 [1]=> 74 string(3) "bar" 75} 76bar 77array(2) { 78 [0]=> 79 string(6) "method" 80 [1]=> 81 string(3) "bar" 82} 83__invoke 84array(2) { 85 [0]=> 86 string(6) "invoke" 87 [1]=> 88 string(3) "bar" 89} 90{closure:%s:%d} 91array(2) { 92 [0]=> 93 string(7) "closure" 94 [1]=> 95 string(3) "bar" 96} 97bool(false) 98