File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ New with anonymous class is not supported in constant expressions
3
+ --FILE--
4
+ <?php
5
+
6
+ const X = new class {};
7
+
8
+ ?>
9
+ --EXPECTF--
10
+ Fatal error: Cannot use anonymous class in constant expression in %s on line %d
Original file line number Diff line number Diff line change @@ -9436,6 +9436,10 @@ void zend_compile_const_expr_magic_const(zend_ast **ast_ptr) /* {{{ */
9436
9436
static void zend_compile_const_expr_new (zend_ast * * ast_ptr )
9437
9437
{
9438
9438
zend_ast * class_ast = (* ast_ptr )-> child [0 ];
9439
+ if (class_ast -> kind == ZEND_AST_CLASS ) {
9440
+ zend_error_noreturn (E_COMPILE_ERROR ,
9441
+ "Cannot use anonymous class in constant expression" );
9442
+ }
9439
9443
if (class_ast -> kind != ZEND_AST_ZVAL ) {
9440
9444
zend_error_noreturn (E_COMPILE_ERROR ,
9441
9445
"Cannot use dynamic class name in constant expression" );
You can’t perform that action at this time.
0 commit comments