summaryrefslogtreecommitdiff
path: root/Zend/tests/function_arguments/call_with_trailing_comma_basic.phpt
blob: aec3008e92177ca8014d69aa077a7f2c7ac0cc26 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
--TEST--
Allow trailing commas in function and method calls
--FILE--
<?php
function foo(...$args) {
  echo __FUNCTION__ . "\n";
  var_dump($args);
}
foo(
  'function',
  'bar',
);

class Foo
{
  public function __construct(...$args) {
    echo __FUNCTION__ . "\n";
    var_dump($args);
  }

  public function bar(...$args) {
    echo __FUNCTION__ . "\n";
    var_dump($args);
  }

  public function __invoke(...$args) {
    echo __FUNCTION__ . "\n";
    var_dump($args);
  }
}

$foo = new Foo(
  'constructor',
  'bar',
);

$foo->bar(
  'method',
  'bar',
);

$foo(
  'invoke',
  'bar',
);

$bar = function(...$args) {
  echo __FUNCTION__ . "\n";
  var_dump($args);
};

$bar(
  'closure',
  'bar',
);

# Make sure to hit the "not really a function" language constructs
unset($foo, $bar,);
var_dump(isset($foo, $bar,));
?>
--EXPECT--
foo
array(2) {
  [0]=>
  string(8) "function"
  [1]=>
  string(3) "bar"
}
__construct
array(2) {
  [0]=>
  string(11) "constructor"
  [1]=>
  string(3) "bar"
}
bar
array(2) {
  [0]=>
  string(6) "method"
  [1]=>
  string(3) "bar"
}
__invoke
array(2) {
  [0]=>
  string(6) "invoke"
  [1]=>
  string(3) "bar"
}
{closure}
array(2) {
  [0]=>
  string(7) "closure"
  [1]=>
  string(3) "bar"
}
bool(false)