1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

De-duplicate readonly property modification error message (#14972)

This commit is contained in:
Ilija Tovilo
2024-07-16 16:29:40 +02:00
committed by GitHub
parent 551038bb16
commit a26ec58fa1
5 changed files with 12 additions and 6 deletions

View File

@@ -889,10 +889,15 @@ ZEND_COLD void zend_match_unhandled_error(const zval *value)
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_readonly_property_modification_error(
const zend_property_info *info) {
zend_throw_error(NULL, "Cannot modify readonly property %s::$%s",
zend_readonly_property_modification_error_ex(
ZSTR_VAL(info->ce->name), zend_get_unmangled_property_name(info->name));
}
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_readonly_property_modification_error_ex(
const char *class_name, const char *prop_name) {
zend_throw_error(NULL, "Cannot modify readonly property %s::$%s", class_name, prop_name);
}
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_readonly_property_indirect_modification_error(const zend_property_info *info)
{
zend_throw_error(NULL, "Cannot indirectly modify readonly property %s::$%s",

View File

@@ -83,6 +83,7 @@ ZEND_API ZEND_COLD zval* ZEND_FASTCALL zend_undefined_index_write(HashTable *ht,
ZEND_API ZEND_COLD void zend_wrong_string_offset_error(void);
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_readonly_property_modification_error(const zend_property_info *info);
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_readonly_property_modification_error_ex(const char *class_name, const char *prop_name);
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_readonly_property_indirect_modification_error(const zend_property_info *info);
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_invalid_class_constant_type_error(uint8_t type);

View File

@@ -5946,7 +5946,7 @@ static zval *date_period_read_property(zend_object *object, zend_string *name, i
{
if (type != BP_VAR_IS && type != BP_VAR_R) {
if (date_period_is_internal_property(name)) {
zend_throw_error(NULL, "Cannot modify readonly property DatePeriod::$%s", ZSTR_VAL(name));
zend_readonly_property_modification_error_ex("DatePeriod", ZSTR_VAL(name));
return &EG(uninitialized_zval);
}
}
@@ -5958,7 +5958,7 @@ static zval *date_period_read_property(zend_object *object, zend_string *name, i
static zval *date_period_write_property(zend_object *object, zend_string *name, zval *value, void **cache_slot)
{
if (date_period_is_internal_property(name)) {
zend_throw_error(NULL, "Cannot modify readonly property DatePeriod::$%s", ZSTR_VAL(name));
zend_readonly_property_modification_error_ex("DatePeriod", ZSTR_VAL(name));
return value;
}
@@ -5968,7 +5968,7 @@ static zval *date_period_write_property(zend_object *object, zend_string *name,
static zval *date_period_get_property_ptr_ptr(zend_object *object, zend_string *name, int type, void **cache_slot)
{
if (date_period_is_internal_property(name)) {
zend_throw_error(NULL, "Cannot modify readonly property DatePeriod::$%s", ZSTR_VAL(name));
zend_readonly_property_modification_error_ex("DatePeriod", ZSTR_VAL(name));
return &EG(error_zval);
}

View File

@@ -392,7 +392,7 @@ zval *dom_write_property(zend_object *object, zend_string *name, zval *value, vo
if (hnd) {
if (!hnd->write_func) {
zend_throw_error(NULL, "Cannot modify readonly property %s::$%s", ZSTR_VAL(object->ce->name), ZSTR_VAL(name));
zend_readonly_property_modification_error_ex(ZSTR_VAL(object->ce->name), ZSTR_VAL(name));
return &EG(error_zval);
}

View File

@@ -150,7 +150,7 @@ zval *xmlreader_write_property(zend_object *object, zend_string *name, zval *val
xmlreader_prop_handler *hnd = zend_hash_find_ptr(&xmlreader_prop_handlers, name);
if (hnd != NULL) {
zend_throw_error(NULL, "Cannot modify readonly property %s::$%s", ZSTR_VAL(object->ce->name), ZSTR_VAL(name));
zend_readonly_property_modification_error_ex(ZSTR_VAL(object->ce->name), ZSTR_VAL(name));
} else {
value = zend_std_write_property(object, name, value, cache_slot);
}