xref: /PHP-7.1/Zend/tests/003.phpt (revision 7af945e2)
1--TEST--
2func_get_args() tests
3--FILE--
4<?php
5
6function test1() {
7	var_dump(func_get_args());
8}
9
10function test2($a) {
11	var_dump(func_get_args());
12}
13
14function test3($a, $b) {
15	var_dump(func_get_args());
16}
17
18test1();
19test1(10);
20test2(1);
21try {
22	test2();
23} catch (Throwable $e) {
24	echo "Exception: " . $e->getMessage() . "\n";
25}
26test3(1,2);
27
28call_user_func("test1");
29try {
30	call_user_func("test3", 1);
31} catch (Throwable $e) {
32	echo "Exception: " . $e->getMessage() . "\n";
33}
34call_user_func("test3", 1, 2);
35
36class test {
37	static function test1($a) {
38		var_dump(func_get_args());
39	}
40}
41
42test::test1(1);
43var_dump(func_get_args());
44
45echo "Done\n";
46?>
47--EXPECTF--
48array(0) {
49}
50array(1) {
51  [0]=>
52  int(10)
53}
54array(1) {
55  [0]=>
56  int(1)
57}
58Exception: Too few arguments to function test2(), 0 passed in %s003.php on line %d and exactly 1 expected
59array(2) {
60  [0]=>
61  int(1)
62  [1]=>
63  int(2)
64}
65array(0) {
66}
67Exception: Too few arguments to function test3(), 1 passed in %s003.php on line %d and exactly 2 expected
68array(2) {
69  [0]=>
70  int(1)
71  [1]=>
72  int(2)
73}
74array(1) {
75  [0]=>
76  int(1)
77}
78
79Warning: func_get_args():  Called from the global scope - no function context in %s on line %d
80bool(false)
81Done
82