Skip to content

Commit c7c11a7

Browse files
committed
Zend/zend_object_handlers: make several pointers const
1 parent 1e7afb3 commit c7c11a7

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

Zend/zend_object_handlers.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ static void zend_std_call_issetter(zend_object *zobj, zend_string *prop_name, zv
224224
/* }}} */
225225

226226

227-
static zend_always_inline bool is_derived_class(zend_class_entry *child_class, zend_class_entry *parent_class) /* {{{ */
227+
static zend_always_inline bool is_derived_class(const zend_class_entry *child_class, const zend_class_entry *parent_class) /* {{{ */
228228
{
229229
child_class = child_class->parent;
230230
while (child_class) {
@@ -238,14 +238,14 @@ static zend_always_inline bool is_derived_class(zend_class_entry *child_class, z
238238
}
239239
/* }}} */
240240

241-
static zend_never_inline int is_protected_compatible_scope(zend_class_entry *ce, zend_class_entry *scope) /* {{{ */
241+
static zend_never_inline int is_protected_compatible_scope(const zend_class_entry *ce, const zend_class_entry *scope) /* {{{ */
242242
{
243243
return scope &&
244244
(is_derived_class(ce, scope) || is_derived_class(scope, ce));
245245
}
246246
/* }}} */
247247

248-
static zend_never_inline zend_property_info *zend_get_parent_private_property(zend_class_entry *scope, zend_class_entry *ce, zend_string *member) /* {{{ */
248+
static zend_never_inline zend_property_info *zend_get_parent_private_property(zend_class_entry *scope, const zend_class_entry *ce, zend_string *member) /* {{{ */
249249
{
250250
zval *zv;
251251
zend_property_info *prop_info;
@@ -264,7 +264,7 @@ static zend_never_inline zend_property_info *zend_get_parent_private_property(ze
264264
}
265265
/* }}} */
266266

267-
static ZEND_COLD zend_never_inline void zend_bad_property_access(zend_property_info *property_info, zend_class_entry *ce, zend_string *member) /* {{{ */
267+
static ZEND_COLD zend_never_inline void zend_bad_property_access(const zend_property_info *property_info, const zend_class_entry *ce, const zend_string *member) /* {{{ */
268268
{
269269
zend_throw_error(NULL, "Cannot access %s property %s::$%s", zend_visibility_string(property_info->flags), ZSTR_VAL(ce->name), ZSTR_VAL(member));
270270
}
@@ -277,13 +277,13 @@ static ZEND_COLD zend_never_inline void zend_bad_property_name(void) /* {{{ */
277277
/* }}} */
278278

279279
static ZEND_COLD zend_never_inline void zend_forbidden_dynamic_property(
280-
zend_class_entry *ce, zend_string *member) {
280+
const zend_class_entry *ce, const zend_string *member) {
281281
zend_throw_error(NULL, "Cannot create dynamic property %s::$%s",
282282
ZSTR_VAL(ce->name), ZSTR_VAL(member));
283283
}
284284

285285
static ZEND_COLD zend_never_inline bool zend_deprecated_dynamic_property(
286-
zend_object *obj, zend_string *member) {
286+
zend_object *obj, const zend_string *member) {
287287
GC_ADDREF(obj);
288288
zend_error(E_DEPRECATED, "Creation of dynamic property %s::$%s is deprecated",
289289
ZSTR_VAL(obj->ce->name), ZSTR_VAL(member));
@@ -301,7 +301,7 @@ static ZEND_COLD zend_never_inline bool zend_deprecated_dynamic_property(
301301
}
302302

303303
static ZEND_COLD zend_never_inline void zend_readonly_property_modification_scope_error(
304-
zend_class_entry *ce, zend_string *member, zend_class_entry *scope, const char *operation) {
304+
const zend_class_entry *ce, const zend_string *member, const zend_class_entry *scope, const char *operation) {
305305
zend_throw_error(NULL, "Cannot %s readonly property %s::$%s from %s%s",
306306
operation, ZSTR_VAL(ce->name), ZSTR_VAL(member),
307307
scope ? "scope " : "global scope", scope ? ZSTR_VAL(scope->name) : "");
@@ -313,7 +313,7 @@ static ZEND_COLD zend_never_inline void zend_readonly_property_unset_error(
313313
ZSTR_VAL(ce->name), ZSTR_VAL(member));
314314
}
315315

316-
static zend_always_inline uintptr_t zend_get_property_offset(zend_class_entry *ce, zend_string *member, int silent, void **cache_slot, zend_property_info **info_ptr) /* {{{ */
316+
static zend_always_inline uintptr_t zend_get_property_offset(zend_class_entry *ce, zend_string *member, int silent, void **cache_slot, const zend_property_info **info_ptr) /* {{{ */
317317
{
318318
zval *zv;
319319
zend_property_info *property_info;
@@ -412,14 +412,14 @@ static zend_always_inline uintptr_t zend_get_property_offset(zend_class_entry *c
412412

413413
static ZEND_COLD void zend_wrong_offset(zend_class_entry *ce, zend_string *member) /* {{{ */
414414
{
415-
zend_property_info *dummy;
415+
const zend_property_info *dummy;
416416

417417
/* Trigger the correct error */
418418
zend_get_property_offset(ce, member, 0, NULL, &dummy);
419419
}
420420
/* }}} */
421421

422-
ZEND_API zend_property_info *zend_get_property_info(zend_class_entry *ce, zend_string *member, int silent) /* {{{ */
422+
ZEND_API zend_property_info *zend_get_property_info(const zend_class_entry *ce, zend_string *member, int silent) /* {{{ */
423423
{
424424
zval *zv;
425425
zend_property_info *property_info;
@@ -594,7 +594,7 @@ ZEND_API zval *zend_std_read_property(zend_object *zobj, zend_string *name, int
594594
{
595595
zval *retval;
596596
uintptr_t property_offset;
597-
zend_property_info *prop_info = NULL;
597+
const zend_property_info *prop_info = NULL;
598598
uint32_t *guard = NULL;
599599
zend_string *tmp_name = NULL;
600600

@@ -767,7 +767,7 @@ static zend_always_inline bool property_uses_strict_types(void) {
767767
}
768768

769769
static bool verify_readonly_initialization_access(
770-
zend_property_info *prop_info, zend_class_entry *ce,
770+
const zend_property_info *prop_info, const zend_class_entry *ce,
771771
zend_string *name, const char *operation) {
772772
zend_class_entry *scope;
773773
if (UNEXPECTED(EG(fake_scope))) {
@@ -782,7 +782,7 @@ static bool verify_readonly_initialization_access(
782782
/* We may have redeclared a parent property. In that case the parent should still be
783783
* allowed to initialize it. */
784784
if (scope && is_derived_class(ce, scope)) {
785-
zend_property_info *prop_info = zend_hash_find_ptr(&scope->properties_info, name);
785+
const zend_property_info *prop_info = zend_hash_find_ptr(&scope->properties_info, name);
786786
if (prop_info) {
787787
/* This should be ensured by inheritance. */
788788
ZEND_ASSERT(prop_info->flags & ZEND_ACC_READONLY);
@@ -800,7 +800,7 @@ ZEND_API zval *zend_std_write_property(zend_object *zobj, zend_string *name, zva
800800
{
801801
zval *variable_ptr, tmp;
802802
uintptr_t property_offset;
803-
zend_property_info *prop_info = NULL;
803+
const zend_property_info *prop_info = NULL;
804804
ZEND_ASSERT(!Z_ISREF_P(value));
805805

806806
property_offset = zend_get_property_offset(zobj->ce, name, (zobj->ce->__set != NULL), cache_slot, &prop_info);
@@ -1037,7 +1037,7 @@ ZEND_API zval *zend_std_get_property_ptr_ptr(zend_object *zobj, zend_string *nam
10371037
{
10381038
zval *retval = NULL;
10391039
uintptr_t property_offset;
1040-
zend_property_info *prop_info = NULL;
1040+
const zend_property_info *prop_info = NULL;
10411041

10421042
#if DEBUG_OBJECT_HANDLERS
10431043
fprintf(stderr, "Ptr object #%d property: %s\n", zobj->handle, ZSTR_VAL(name));
@@ -1120,7 +1120,7 @@ ZEND_API zval *zend_std_get_property_ptr_ptr(zend_object *zobj, zend_string *nam
11201120
ZEND_API void zend_std_unset_property(zend_object *zobj, zend_string *name, void **cache_slot) /* {{{ */
11211121
{
11221122
uintptr_t property_offset;
1123-
zend_property_info *prop_info = NULL;
1123+
const zend_property_info *prop_info = NULL;
11241124

11251125
property_offset = zend_get_property_offset(zobj->ce, name, (zobj->ce->__unset != NULL), cache_slot, &prop_info);
11261126

@@ -1763,7 +1763,7 @@ ZEND_API int zend_std_has_property(zend_object *zobj, zend_string *name, int has
17631763
int result;
17641764
zval *value = NULL;
17651765
uintptr_t property_offset;
1766-
zend_property_info *prop_info = NULL;
1766+
const zend_property_info *prop_info = NULL;
17671767
zend_string *tmp_name = NULL;
17681768

17691769
property_offset = zend_get_property_offset(zobj->ce, name, 1, cache_slot, &prop_info);

Zend/zend_object_handlers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ ZEND_API zval *zend_std_get_static_property_with_info(zend_class_entry *ce, zend
205205
ZEND_API zval *zend_std_get_static_property(zend_class_entry *ce, zend_string *property_name, int type);
206206
ZEND_API ZEND_COLD bool zend_std_unset_static_property(zend_class_entry *ce, zend_string *property_name);
207207
ZEND_API zend_function *zend_std_get_constructor(zend_object *object);
208-
ZEND_API struct _zend_property_info *zend_get_property_info(zend_class_entry *ce, zend_string *member, int silent);
208+
ZEND_API struct _zend_property_info *zend_get_property_info(const zend_class_entry *ce, zend_string *member, int silent);
209209
ZEND_API HashTable *zend_std_get_properties(zend_object *object);
210210
ZEND_API HashTable *zend_std_get_gc(zend_object *object, zval **table, int *n);
211211
ZEND_API HashTable *zend_std_get_debug_info(zend_object *object, int *is_temp);

0 commit comments

Comments
 (0)