mirror of
https://github.com/php/php-src.git
synced 2026-04-03 06:02:23 +02:00
Optimize class constant declare compilation
This commit is contained in:
@@ -4535,6 +4535,11 @@ void zend_compile_class_const_decl(zend_ast *ast) /* {{{ */
|
||||
zend_class_entry *ce = CG(active_class_entry);
|
||||
uint32_t i;
|
||||
|
||||
if ((ce->ce_flags & ZEND_ACC_TRAIT) != 0) {
|
||||
zend_error_noreturn(E_COMPILE_ERROR, "Traits cannot have constants");
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < list->children; ++i) {
|
||||
zend_ast *const_ast = list->child[i];
|
||||
zend_ast *name_ast = const_ast->child[0];
|
||||
@@ -4542,11 +4547,6 @@ void zend_compile_class_const_decl(zend_ast *ast) /* {{{ */
|
||||
zend_string *name = zend_ast_get_str(name_ast);
|
||||
zval value_zv;
|
||||
|
||||
if ((ce->ce_flags & ZEND_ACC_TRAIT) != 0) {
|
||||
zend_error_noreturn(E_COMPILE_ERROR, "Traits cannot have constants");
|
||||
return;
|
||||
}
|
||||
|
||||
zend_const_expr_to_zval(&value_zv, value_ast);
|
||||
|
||||
name = zend_new_interned_string_safe(name);
|
||||
|
||||
Reference in New Issue
Block a user