Skip to content

Commit e752457

Browse files
committed
Merge branch 'PHP-8.5'
* PHP-8.5: Fix missing new Foo(...) error in constant expressions
2 parents b889ec4 + 5a63f7a commit e752457

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

Zend/tests/gh20113.phpt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
--TEST--
2+
GH-20113: new Foo(...) error in constant expressions
3+
--FILE--
4+
<?php
5+
const C = new \stdClass(...);
6+
?>
7+
--EXPECTF--
8+
Fatal error: Cannot create Closure for new expression in %s on line %d

Zend/zend_compile.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11488,6 +11488,11 @@ static void zend_compile_const_expr_new(zend_ast **ast_ptr)
1148811488
{
1148911489
zend_ast *class_ast = (*ast_ptr)->child[0];
1149011490
zend_compile_const_expr_class_reference(class_ast);
11491+
11492+
zend_ast *args_ast = (*ast_ptr)->child[1];
11493+
if (args_ast->kind == ZEND_AST_CALLABLE_CONVERT) {
11494+
zend_error_noreturn(E_COMPILE_ERROR, "Cannot create Closure for new expression");
11495+
}
1149111496
}
1149211497

1149311498
static void zend_compile_const_expr_closure(zend_ast **ast_ptr)

0 commit comments

Comments
 (0)