Skip to content

Commit bc03dee

Browse files
committed
Fix magic constants in backed enum values
Fix GH-8777
1 parent d9e1871 commit bc03dee

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

Zend/tests/enum/magic-constants.phpt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
Backed enums can contain magic constants
3+
--FILE--
4+
<?php
5+
6+
enum Foo: string {
7+
case Bar = __FILE__;
8+
}
9+
10+
echo Foo::Bar->value, "\n";
11+
12+
?>
13+
--EXPECTF--
14+
%smagic-constants.php

Zend/zend_compile.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10474,6 +10474,9 @@ static void zend_eval_const_expr(zend_ast **ast_ptr) /* {{{ */
1047410474
case ZEND_AST_NAMED_ARG:
1047510475
zend_eval_const_expr(&ast->child[1]);
1047610476
return;
10477+
case ZEND_AST_CONST_ENUM_INIT:
10478+
zend_eval_const_expr(&ast->child[2]);
10479+
return;
1047710480
default:
1047810481
return;
1047910482
}

0 commit comments

Comments
 (0)