Skip to content

Commit c23b5c0

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

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
@@ -10473,6 +10473,9 @@ static void zend_eval_const_expr(zend_ast **ast_ptr) /* {{{ */
1047310473
case ZEND_AST_NAMED_ARG:
1047410474
zend_eval_const_expr(&ast->child[1]);
1047510475
return;
10476+
case ZEND_AST_CONST_ENUM_INIT:
10477+
zend_eval_const_expr(&ast->child[2]);
10478+
return;
1047610479
default:
1047710480
return;
1047810481
}

0 commit comments

Comments
 (0)