Skip to content

Commit d48c537

Browse files
MaxKellermannGirgias
authored andcommitted
Zend/zend_object_handlers: make several pointers const
1 parent 0caef56 commit d48c537

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
@@ -223,7 +223,7 @@ static void zend_std_call_issetter(zend_object *zobj, zend_string *prop_name, zv
223223
/* }}} */
224224

225225

226-
static zend_always_inline bool is_derived_class(zend_class_entry *child_class, zend_class_entry *parent_class) /* {{{ */
226+
static zend_always_inline bool is_derived_class(const zend_class_entry *child_class, const zend_class_entry *parent_class) /* {{{ */
227227
{
228228
child_class = child_class->parent;
229229
while (child_class) {
@@ -237,14 +237,14 @@ static zend_always_inline bool is_derived_class(zend_class_entry *child_class, z
237237
}
238238
/* }}} */
239239

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

247-
static zend_never_inline zend_property_info *zend_get_parent_private_property(zend_class_entry *scope, zend_class_entry *ce, zend_string *member) /* {{{ */
247+
static zend_never_inline zend_property_info *zend_get_parent_private_property(zend_class_entry *scope, const zend_class_entry *ce, zend_string *member) /* {{{ */
248248
{
249249
zval *zv;
250250
zend_property_info *prop_info;
@@ -263,7 +263,7 @@ static zend_never_inline zend_property_info *zend_get_parent_private_property(ze
263263
}
264264
/* }}} */
265265

266-
static ZEND_COLD zend_never_inline void zend_bad_property_access(zend_property_info *property_info, zend_class_entry *ce, zend_string *member) /* {{{ */
266+
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) /* {{{ */
267267
{
268268
zend_throw_error(NULL, "Cannot access %s property %s::$%s", zend_visibility_string(property_info->flags), ZSTR_VAL(ce->name), ZSTR_VAL(member));
269269
}
@@ -276,13 +276,13 @@ static ZEND_COLD zend_never_inline void zend_bad_property_name(void) /* {{{ */
276276
/* }}} */
277277

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

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

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

315-
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) /* {{{ */
315+
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) /* {{{ */
316316
{
317317
zval *zv;
318318
zend_property_info *property_info;
@@ -411,14 +411,14 @@ static zend_always_inline uintptr_t zend_get_property_offset(zend_class_entry *c
411411

412412
static ZEND_COLD void zend_wrong_offset(zend_class_entry *ce, zend_string *member) /* {{{ */
413413
{
414-
zend_property_info *dummy;
414+
const zend_property_info *dummy;
415415

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

421-
ZEND_API zend_property_info *zend_get_property_info(zend_class_entry *ce, zend_string *member, int silent) /* {{{ */
421+
ZEND_API zend_property_info *zend_get_property_info(const zend_class_entry *ce, zend_string *member, int silent) /* {{{ */
422422
{
423423
zval *zv;
424424
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));
@@ -1118,7 +1118,7 @@ ZEND_API zval *zend_std_get_property_ptr_ptr(zend_object *zobj, zend_string *nam
11181118
ZEND_API void zend_std_unset_property(zend_object *zobj, zend_string *name, void **cache_slot) /* {{{ */
11191119
{
11201120
uintptr_t property_offset;
1121-
zend_property_info *prop_info = NULL;
1121+
const zend_property_info *prop_info = NULL;
11221122

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

@@ -1750,7 +1750,7 @@ ZEND_API int zend_std_has_property(zend_object *zobj, zend_string *name, int has
17501750
int result;
17511751
zval *value = NULL;
17521752
uintptr_t property_offset;
1753-
zend_property_info *prop_info = NULL;
1753+
const zend_property_info *prop_info = NULL;
17541754
zend_string *tmp_name = NULL;
17551755

17561756
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)