From e3926e607d3cbe41233e34557768c28fd658b8c4 Mon Sep 17 00:00:00 2001 From: Daniel Scherzer Date: Tue, 3 Sep 2024 11:00:22 -0700 Subject: [PATCH] `zend_get_constant_ex()` - remove commented out handling of class constants Was factored out into a dedicated method, `zend_get_class_constant_ex()`, back in 2021 (4dcde9cf186c5c421925870fbf21362959cef62d) but instead of removing the old logic it was just commented out. If it hasn't been needed since 2021, it should be safe to remove. --- Zend/zend_constants.c | 72 ------------------------------------------- 1 file changed, 72 deletions(-) diff --git a/Zend/zend_constants.c b/Zend/zend_constants.c index 9fa98e74e8ccb..d453b8bb73717 100644 --- a/Zend/zend_constants.c +++ b/Zend/zend_constants.c @@ -411,78 +411,6 @@ ZEND_API zval *zend_get_constant_ex(zend_string *cname, zend_class_entry *scope, zend_string_release_ex(class_name, 0); zend_string_efree(constant_name); return ret_constant; -/* - zend_class_entry *ce = NULL; - zend_class_constant *c = NULL; - zval *ret_constant = NULL; - - if (zend_string_equals_literal_ci(class_name, "self")) { - if (UNEXPECTED(!scope)) { - zend_throw_error(NULL, "Cannot access \"self\" when no class scope is active"); - goto failure; - } - ce = scope; - } else if (zend_string_equals_literal_ci(class_name, "parent")) { - if (UNEXPECTED(!scope)) { - zend_throw_error(NULL, "Cannot access \"parent\" when no class scope is active"); - goto failure; - } else if (UNEXPECTED(!scope->parent)) { - zend_throw_error(NULL, "Cannot access \"parent\" when current class scope has no parent"); - goto failure; - } else { - ce = scope->parent; - } - } else if (zend_string_equals_ci(class_name, ZSTR_KNOWN(ZEND_STR_STATIC))) { - ce = zend_get_called_scope(EG(current_execute_data)); - if (UNEXPECTED(!ce)) { - zend_throw_error(NULL, "Cannot access \"static\" when no class scope is active"); - goto failure; - } - } else { - ce = zend_fetch_class(class_name, flags); - } - if (ce) { - c = zend_hash_find_ptr(CE_CONSTANTS_TABLE(ce), constant_name); - if (c == NULL) { - if ((flags & ZEND_FETCH_CLASS_SILENT) == 0) { - zend_throw_error(NULL, "Undefined constant %s::%s", ZSTR_VAL(class_name), ZSTR_VAL(constant_name)); - goto failure; - } - ret_constant = NULL; - } else { - if (!zend_verify_const_access(c, scope)) { - if ((flags & ZEND_FETCH_CLASS_SILENT) == 0) { - zend_throw_error(NULL, "Cannot access %s constant %s::%s", zend_visibility_string(ZEND_CLASS_CONST_FLAGS(c)), ZSTR_VAL(class_name), ZSTR_VAL(constant_name)); - } - goto failure; - } - ret_constant = &c->value; - } - } - - if (ret_constant && Z_TYPE_P(ret_constant) == IS_CONSTANT_AST) { - zend_result ret; - - if (IS_CONSTANT_VISITED(ret_constant)) { - zend_throw_error(NULL, "Cannot declare self-referencing constant %s::%s", ZSTR_VAL(class_name), ZSTR_VAL(constant_name)); - ret_constant = NULL; - goto failure; - } - - MARK_CONSTANT_VISITED(ret_constant); - ret = zval_update_constant_ex(ret_constant, c->ce); - RESET_CONSTANT_VISITED(ret_constant); - - if (UNEXPECTED(ret != SUCCESS)) { - ret_constant = NULL; - goto failure; - } - } -failure: - zend_string_release_ex(class_name, 0); - zend_string_efree(constant_name); - return ret_constant; -*/ } /* non-class constant */