mirror of
https://github.com/php/php-src.git
synced 2024-09-21 09:57:23 +00:00
zend_get_constant_ex()
- remove commented out handling of class constants (#15728)
Was factored out into a dedicated method, `zend_get_class_constant_ex()`, back
in 2021 (4dcde9cf18
) 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.
This commit is contained in:
parent
217ea732fc
commit
d552fbd9f7
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user