Skip to content

Commit 11123b8

Browse files
committed
partial application
1 parent 787db3a commit 11123b8

Some content is hidden

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

54 files changed

+2380
-439
lines changed

Zend/Optimizer/zend_call_graph.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ ZEND_API int zend_analyze_calls(zend_arena **arena, zend_script *script, uint32_
106106
case ZEND_DO_ICALL:
107107
case ZEND_DO_UCALL:
108108
case ZEND_DO_FCALL_BY_NAME:
109+
case ZEND_DO_FCALL_PARTIAL:
109110
func_info->flags |= ZEND_FUNC_HAS_CALLS;
110111
if (call_info) {
111112
call_info->caller_call_opline = opline;
@@ -122,6 +123,7 @@ ZEND_API int zend_analyze_calls(zend_arena **arena, zend_script *script, uint32_
122123
case ZEND_SEND_VAR_NO_REF:
123124
case ZEND_SEND_VAR_NO_REF_EX:
124125
case ZEND_SEND_USER:
126+
case ZEND_SEND_PLACEHOLDER:
125127
if (call_info) {
126128
if (opline->op2_type == IS_CONST) {
127129
call_info->named_args = 1;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
--TEST--
2+
Partial application compile errors: multiple ...
3+
--FILE--
4+
<?php
5+
foo(..., ...);
6+
?>
7+
--EXPECTF--
8+
Fatal error: Multiple argument place holder may only appear once in %s on line %d
9+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
--TEST--
2+
Partial application compile errors: only named arguments after ...
3+
--FILE--
4+
<?php
5+
foo(..., ?);
6+
?>
7+
--EXPECTF--
8+
Fatal error: Only named arguments may follow multiple place holder in %s on line %d
9+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
--TEST--
2+
Partial application compile errors: named arguments must come after place holder
3+
--FILE--
4+
<?php
5+
foo(n: 5, ?);
6+
?>
7+
--EXPECTF--
8+
Fatal error: Named arguments must come after all place holders in %s on line %d
9+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
--TEST--
2+
Partial application compile errors: named arguments must come after multi place holder
3+
--FILE--
4+
<?php
5+
foo(n: 5, ...);
6+
?>
7+
--EXPECTF--
8+
Fatal error: Named arguments must come after all place holders in %s on line %d
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
--TEST--
2+
Partial application compile errors: follow multiple with un-named arg
3+
--FILE--
4+
<?php
5+
foo(..., $a);
6+
?>
7+
--EXPECTF--
8+
Fatal error: Only named arguments may follow multiple place holder in %s on line %d
9+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
--TEST--
2+
Partial application compile errors: follow multiple with unpack
3+
--FILE--
4+
<?php
5+
foo(..., ...[$a]);
6+
?>
7+
--EXPECTF--
8+
Fatal error: Only named arguments may follow multiple place holder in %s on line %d
9+
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
--TEST--
2+
Partial application errors: place holder count errors
3+
--FILE--
4+
<?php
5+
function foo($a, $b, $c) {
6+
7+
}
8+
9+
try {
10+
foo(?);
11+
} catch (Error $ex) {
12+
printf("%s\n", $ex->getMessage());
13+
}
14+
15+
try {
16+
foo(?, ?, ?, ?);
17+
} catch (Error $ex) {
18+
printf("%s\n", $ex->getMessage());
19+
}
20+
21+
try {
22+
property_exists(?);
23+
} catch (Error $ex) {
24+
printf("%s\n", $ex->getMessage());
25+
}
26+
27+
try {
28+
usleep(?, ?);
29+
} catch (Error $ex) {
30+
printf("%s\n", $ex->getMessage());
31+
}
32+
?>
33+
--EXPECTF--
34+
not enough arguments and or place holders for foo, 1 given and at least 3 expected, declared in %s on line 2
35+
too many arguments and or place holders for foo, 4 given and a maximum of 3 expected, declared in %s on line 2
36+
not enough arguments and or place holders for property_exists, 1 given and at least 2 expected
37+
too many arguments and or place holders for usleep, 2 given and a maximum of 1 expected
38+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
Partial application errors: named parameter overwrites place holder
3+
--FILE--
4+
<?php
5+
function foo($a) {
6+
7+
}
8+
9+
try {
10+
foo(?, a: 1);
11+
} catch (Error $ex) {
12+
printf("%s\n", $ex->getMessage());
13+
}
14+
?>
15+
--EXPECT--
16+
Named parameter $a overwrites previous place holder
17+
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
--TEST--
2+
Partial application errors: missing parameters
3+
--FILE--
4+
<?php
5+
function foo($a, ...$b) {
6+
7+
}
8+
9+
$foo = foo(?);
10+
11+
try {
12+
$foo();
13+
} catch (Error $ex) {
14+
printf("%s\n", $ex->getMessage());
15+
}
16+
17+
$foo = foo(?, ?);
18+
19+
try {
20+
$foo(1);
21+
} catch (Error $ex) {
22+
printf("%s\n", $ex->getMessage());
23+
}
24+
25+
$usleep = usleep(...);
26+
27+
try {
28+
$usleep();
29+
} catch (Error $ex) {
30+
printf("%s\n", $ex->getMessage());
31+
}
32+
?>
33+
--EXPECTF--
34+
not enough arguments and or place holders for foo, 0 given and at least 1 expected, declared in %s on line 2
35+
not enough arguments and or place holders for foo, 1 given and at least 2 expected, declared in %s on line 2
36+
not enough arguments provided for usleep, 0 given and at least 1 expected
37+

0 commit comments

Comments
 (0)