Skip to content

Commit b3a12db

Browse files
committed
fixup! Support first-class callables in const-expressions
1 parent e12d463 commit b3a12db

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
Allow defining FCC in const expressions with case-insensitive names.
3+
--FILE--
4+
<?php
5+
6+
const Closure = StrRev(...);
7+
8+
var_dump(Closure);
9+
var_dump((Closure)("abc"));
10+
11+
?>
12+
--EXPECTF--
13+
object(Closure)#%d (2) {
14+
["function"]=>
15+
string(%d) "%s"
16+
["parameter"]=>
17+
array(1) {
18+
["$string"]=>
19+
string(10) "<required>"
20+
}
21+
}
22+
string(3) "cba"

Zend/zend_ast.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -999,7 +999,9 @@ ZEND_API zend_result ZEND_FASTCALL zend_ast_evaluate_inner(
999999
ZEND_ASSERT(ast->child[1]->kind == ZEND_AST_CALLABLE_CONVERT);
10001000

10011001
zend_string *function_name = zend_ast_get_str(ast->child[0]);
1002-
fptr = zend_fetch_function(function_name);
1002+
zend_string *function_name_lc = zend_string_tolower(function_name);
1003+
fptr = zend_fetch_function(function_name_lc);
1004+
zend_string_release(function_name_lc);
10031005
if (!fptr) {
10041006
zend_throw_error(NULL, "Call to undefined function %s()", ZSTR_VAL(function_name));
10051007
return FAILURE;

0 commit comments

Comments
 (0)