Skip to content

Commit badc19d

Browse files
committed
Optimize class constant declare compilation
1 parent bc28ed6 commit badc19d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Zend/zend_compile.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4535,18 +4535,18 @@ void zend_compile_class_const_decl(zend_ast *ast) /* {{{ */
45354535
zend_class_entry *ce = CG(active_class_entry);
45364536
uint32_t i;
45374537

4538+
if ((ce->ce_flags & ZEND_ACC_TRAIT) != 0) {
4539+
zend_error_noreturn(E_COMPILE_ERROR, "Traits cannot have constants");
4540+
return;
4541+
}
4542+
45384543
for (i = 0; i < list->children; ++i) {
45394544
zend_ast *const_ast = list->child[i];
45404545
zend_ast *name_ast = const_ast->child[0];
45414546
zend_ast *value_ast = const_ast->child[1];
45424547
zend_string *name = zend_ast_get_str(name_ast);
45434548
zval value_zv;
45444549

4545-
if ((ce->ce_flags & ZEND_ACC_TRAIT) != 0) {
4546-
zend_error_noreturn(E_COMPILE_ERROR, "Traits cannot have constants");
4547-
return;
4548-
}
4549-
45504550
zend_const_expr_to_zval(&value_zv, value_ast);
45514551

45524552
name = zend_new_interned_string_safe(name);

0 commit comments

Comments
 (0)