Skip to content

Commit 13eed26

Browse files
committed
Merge commit 'refs/pull/1137/head' of git://github.com/php/php-src
* git://github.com/php/php-src: Optimize class constant declare compilation
2 parents 68d4575 + badc19d commit 13eed26

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
@@ -4524,18 +4524,18 @@ void zend_compile_class_const_decl(zend_ast *ast) /* {{{ */
45244524
zend_class_entry *ce = CG(active_class_entry);
45254525
uint32_t i;
45264526

4527+
if ((ce->ce_flags & ZEND_ACC_TRAIT) != 0) {
4528+
zend_error_noreturn(E_COMPILE_ERROR, "Traits cannot have constants");
4529+
return;
4530+
}
4531+
45274532
for (i = 0; i < list->children; ++i) {
45284533
zend_ast *const_ast = list->child[i];
45294534
zend_ast *name_ast = const_ast->child[0];
45304535
zend_ast *value_ast = const_ast->child[1];
45314536
zend_string *name = zend_ast_get_str(name_ast);
45324537
zval value_zv;
45334538

4534-
if ((ce->ce_flags & ZEND_ACC_TRAIT) != 0) {
4535-
zend_error_noreturn(E_COMPILE_ERROR, "Traits cannot have constants");
4536-
return;
4537-
}
4538-
45394539
zend_const_expr_to_zval(&value_zv, value_ast);
45404540

45414541
name = zend_new_interned_string_safe(name);

0 commit comments

Comments
 (0)