Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit dc3c4a8

Browse files
committedJan 25, 2015
parameter skipping patch - phase 1
1 parent cb6fb59 commit dc3c4a8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+1687
-1296
lines changed
 

‎Zend/tests/default_params01.phpt

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
--TEST--
2+
Default parameters - 1
3+
--FILE--
4+
<?php
5+
function test($a=1, $b=2, $c=3) {
6+
var_dump($a, $b, $c);
7+
var_dump(func_get_args());
8+
}
9+
echo "7\n";
10+
test(7);
11+
echo "default,4,5\n";
12+
test(default,4,5);
13+
echo "default,default,8\n";
14+
test(default,default,8);
15+
echo "3,default,5\n";
16+
test(3,default,5);
17+
echo "3,default,7,default,6\n";
18+
test(3,default,7,default,6);
19+
?>
20+
--EXPECTF--
21+
7
22+
int(7)
23+
int(2)
24+
int(3)
25+
array(1) {
26+
[0]=>
27+
int(7)
28+
}
29+
default,4,5
30+
int(1)
31+
int(4)
32+
int(5)
33+
array(3) {
34+
[0]=>
35+
int(1)
36+
[1]=>
37+
int(4)
38+
[2]=>
39+
int(5)
40+
}
41+
default,default,8
42+
int(1)
43+
int(2)
44+
int(8)
45+
array(3) {
46+
[0]=>
47+
int(1)
48+
[1]=>
49+
int(2)
50+
[2]=>
51+
int(8)
52+
}
53+
3,default,5
54+
int(3)
55+
int(2)
56+
int(5)
57+
array(3) {
58+
[0]=>
59+
int(3)
60+
[1]=>
61+
int(2)
62+
[2]=>
63+
int(5)
64+
}
65+
3,default,7,default,6
66+
67+
Fatal error: Defaults can be used only for declared optional parameters in %s line %d

‎Zend/tests/default_params02.phpt

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
--TEST--
2+
Default parameters - 2
3+
--FILE--
4+
<?php
5+
function foo($a, $b=1, $c=2, $d = 3) {
6+
var_dump($a, $b, $c, $d);
7+
var_dump(func_num_args());
8+
var_dump(func_get_args());
9+
}
10+
11+
foo(1,2,3);
12+
foo(1,default,3);
13+
foo(default,2,3);
14+
?>
15+
--EXPECTF--
16+
int(1)
17+
int(2)
18+
int(3)
19+
int(3)
20+
int(3)
21+
array(3) {
22+
[0]=>
23+
int(1)
24+
[1]=>
25+
int(2)
26+
[2]=>
27+
int(3)
28+
}
29+
int(1)
30+
int(1)
31+
int(3)
32+
int(3)
33+
int(3)
34+
array(3) {
35+
[0]=>
36+
int(1)
37+
[1]=>
38+
int(1)
39+
[2]=>
40+
int(3)
41+
}
42+
43+
Fatal error: Defaults can be used only for declared optional parameters in %s line %d

0 commit comments

Comments
 (0)
Please sign in to comment.