Skip to content

Commit f61ae00

Browse files
authored
Zend: constify various parameters in zend_object_handlers and zend_lazy_objects (#19019)
1 parent 840dc19 commit f61ae00

File tree

4 files changed

+25
-25
lines changed

4 files changed

+25
-25
lines changed

Zend/zend_lazy_objects.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ void zend_lazy_objects_destroy(zend_lazy_objects_store *store)
9393
zend_hash_destroy(&store->infos);
9494
}
9595

96-
static void zend_lazy_object_set_info(zend_object *obj, zend_lazy_object_info *info)
96+
static void zend_lazy_object_set_info(const zend_object *obj, zend_lazy_object_info *info)
9797
{
9898
ZEND_ASSERT(zend_object_is_lazy(obj));
9999

@@ -102,7 +102,7 @@ static void zend_lazy_object_set_info(zend_object *obj, zend_lazy_object_info *i
102102
(void)zv;
103103
}
104104

105-
static zend_lazy_object_info* zend_lazy_object_get_info(zend_object *obj)
105+
static zend_lazy_object_info* zend_lazy_object_get_info(const zend_object *obj)
106106
{
107107
ZEND_ASSERT(zend_object_is_lazy(obj));
108108

@@ -112,7 +112,7 @@ static zend_lazy_object_info* zend_lazy_object_get_info(zend_object *obj)
112112
return info;
113113
}
114114

115-
static bool zend_lazy_object_has_stale_info(zend_object *obj)
115+
static bool zend_lazy_object_has_stale_info(const zend_object *obj)
116116
{
117117
return zend_hash_index_find_ptr(&EG(lazy_objects_store).infos, obj->handle);
118118
}
@@ -154,18 +154,18 @@ zend_object* zend_lazy_object_get_instance(zend_object *obj)
154154
return obj;
155155
}
156156

157-
zend_lazy_object_flags_t zend_lazy_object_get_flags(zend_object *obj)
157+
zend_lazy_object_flags_t zend_lazy_object_get_flags(const zend_object *obj)
158158
{
159159
return zend_lazy_object_get_info(obj)->flags;
160160
}
161161

162-
void zend_lazy_object_del_info(zend_object *obj)
162+
void zend_lazy_object_del_info(const zend_object *obj)
163163
{
164164
zend_result res = zend_hash_index_del(&EG(lazy_objects_store).infos, obj->handle);
165165
ZEND_ASSERT(res == SUCCESS);
166166
}
167167

168-
bool zend_lazy_object_decr_lazy_props(zend_object *obj)
168+
bool zend_lazy_object_decr_lazy_props(const zend_object *obj)
169169
{
170170
ZEND_ASSERT(zend_object_is_lazy(obj));
171171
ZEND_ASSERT(!zend_lazy_object_initialized(obj));
@@ -183,7 +183,7 @@ bool zend_lazy_object_decr_lazy_props(zend_object *obj)
183183
* Making objects lazy
184184
*/
185185

186-
ZEND_API bool zend_class_can_be_lazy(zend_class_entry *ce)
186+
ZEND_API bool zend_class_can_be_lazy(const zend_class_entry *ce)
187187
{
188188
/* Internal classes are not supported */
189189
if (UNEXPECTED(ce->type == ZEND_INTERNAL_CLASS && ce != zend_standard_class_def)) {
@@ -444,7 +444,7 @@ static void zend_lazy_object_revert_init(zend_object *obj, zval *properties_tabl
444444
OBJ_EXTRA_FLAGS(obj) |= IS_OBJ_LAZY_UNINITIALIZED;
445445
}
446446

447-
static bool zend_lazy_object_compatible(zend_object *real_object, zend_object *lazy_object)
447+
static bool zend_lazy_object_compatible(const zend_object *real_object, const zend_object *lazy_object)
448448
{
449449
if (EXPECTED(real_object->ce == lazy_object->ce)) {
450450
return true;

Zend/zend_lazy_objects.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ typedef struct _zend_property_info zend_property_info;
5757
typedef struct _zend_fcall_info zend_fcall_info;
5858
typedef struct _zend_fcall_info_cache zend_fcall_info_cache;
5959

60-
ZEND_API bool zend_class_can_be_lazy(zend_class_entry *ce);
60+
ZEND_API bool zend_class_can_be_lazy(const zend_class_entry *ce);
6161
ZEND_API zend_object *zend_object_make_lazy(zend_object *obj,
6262
zend_class_entry *class_type, zval *initializer_zv,
6363
zend_fcall_info_cache *initializer_fcc, zend_lazy_object_flags_t flags);
@@ -68,39 +68,39 @@ void zend_lazy_objects_init(zend_lazy_objects_store *store);
6868
void zend_lazy_objects_destroy(zend_lazy_objects_store *store);
6969
zval* zend_lazy_object_get_initializer_zv(zend_object *obj);
7070
zend_object *zend_lazy_object_get_instance(zend_object *obj);
71-
zend_lazy_object_flags_t zend_lazy_object_get_flags(zend_object *obj);
72-
void zend_lazy_object_del_info(zend_object *obj);
71+
zend_lazy_object_flags_t zend_lazy_object_get_flags(const zend_object *obj);
72+
void zend_lazy_object_del_info(const zend_object *obj);
7373
ZEND_API HashTable *zend_lazy_object_get_properties(zend_object *object);
7474
zend_object *zend_lazy_object_clone(zend_object *old_obj);
7575
HashTable *zend_lazy_object_debug_info(zend_object *object, int *is_temp);
7676
HashTable *zend_lazy_object_get_gc(zend_object *zobj, zval **table, int *n);
77-
bool zend_lazy_object_decr_lazy_props(zend_object *obj);
77+
bool zend_lazy_object_decr_lazy_props(const zend_object *obj);
7878
void zend_lazy_object_realize(zend_object *obj);
7979
ZEND_API zend_property_info *zend_lazy_object_get_property_info_for_slot(zend_object *obj, zval *slot);
8080

81-
static zend_always_inline bool zend_object_is_lazy(zend_object *obj)
81+
static zend_always_inline bool zend_object_is_lazy(const zend_object *obj)
8282
{
8383
return (OBJ_EXTRA_FLAGS(obj) & (IS_OBJ_LAZY_UNINITIALIZED | IS_OBJ_LAZY_PROXY));
8484
}
8585

86-
static zend_always_inline bool zend_object_is_lazy_proxy(zend_object *obj)
86+
static zend_always_inline bool zend_object_is_lazy_proxy(const zend_object *obj)
8787
{
8888
return (OBJ_EXTRA_FLAGS(obj) & IS_OBJ_LAZY_PROXY);
8989
}
9090

91-
static zend_always_inline bool zend_lazy_object_initialized(zend_object *obj)
91+
static zend_always_inline bool zend_lazy_object_initialized(const zend_object *obj)
9292
{
9393
return !(OBJ_EXTRA_FLAGS(obj) & IS_OBJ_LAZY_UNINITIALIZED);
9494
}
9595

9696
/* True if accessing a lazy prop on obj mandates a call to
9797
* zend_lazy_object_init() */
98-
static zend_always_inline bool zend_lazy_object_must_init(zend_object *obj)
98+
static zend_always_inline bool zend_lazy_object_must_init(const zend_object *obj)
9999
{
100100
return zend_object_is_lazy(obj);
101101
}
102102

103-
static inline bool zend_lazy_object_initialize_on_serialize(zend_object *obj)
103+
static inline bool zend_lazy_object_initialize_on_serialize(const zend_object *obj)
104104
{
105105
return !(zend_lazy_object_get_flags(obj) & ZEND_LAZY_OBJECT_SKIP_INITIALIZATION_ON_SERIALIZE);
106106
}

Zend/zend_object_handlers.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ static zend_never_inline int is_protected_compatible_scope(const zend_class_entr
289289
}
290290
/* }}} */
291291

292-
static zend_never_inline zend_property_info *zend_get_parent_private_property(zend_class_entry *scope, const zend_class_entry *ce, zend_string *member) /* {{{ */
292+
static zend_never_inline zend_property_info *zend_get_parent_private_property(const zend_class_entry *scope, const zend_class_entry *ce, zend_string *member) /* {{{ */
293293
{
294294
zval *zv;
295295
zend_property_info *prop_info;
@@ -1823,7 +1823,7 @@ static zend_always_inline zend_function *zend_get_user_call_function(zend_class_
18231823
}
18241824
/* }}} */
18251825

1826-
ZEND_API ZEND_COLD zend_never_inline void zend_bad_method_call(zend_function *fbc, zend_string *method_name, zend_class_entry *scope) /* {{{ */
1826+
ZEND_API ZEND_COLD zend_never_inline void zend_bad_method_call(const zend_function *fbc, const zend_string *method_name, const zend_class_entry *scope) /* {{{ */
18271827
{
18281828
zend_throw_error(NULL, "Call to %s method %s::%s() from %s%s",
18291829
zend_visibility_string(fbc->common.fn_flags), ZEND_FN_SCOPE_NAME(fbc), ZSTR_VAL(method_name),
@@ -1833,7 +1833,7 @@ ZEND_API ZEND_COLD zend_never_inline void zend_bad_method_call(zend_function *fb
18331833
}
18341834
/* }}} */
18351835

1836-
ZEND_API ZEND_COLD zend_never_inline void zend_abstract_method_call(zend_function *fbc) /* {{{ */
1836+
ZEND_API ZEND_COLD zend_never_inline void zend_abstract_method_call(const zend_function *fbc) /* {{{ */
18371837
{
18381838
zend_throw_error(NULL, "Cannot call abstract method %s::%s()",
18391839
ZSTR_VAL(fbc->common.scope->name), ZSTR_VAL(fbc->common.function_name));
@@ -2090,14 +2090,14 @@ ZEND_API zval *zend_std_get_static_property(zend_class_entry *ce, zend_string *p
20902090
return zend_std_get_static_property_with_info(ce, property_name, type, &prop_info);
20912091
}
20922092

2093-
ZEND_API ZEND_COLD bool zend_std_unset_static_property(zend_class_entry *ce, zend_string *property_name) /* {{{ */
2093+
ZEND_API ZEND_COLD bool zend_std_unset_static_property(const zend_class_entry *ce, const zend_string *property_name) /* {{{ */
20942094
{
20952095
zend_throw_error(NULL, "Attempt to unset static property %s::$%s", ZSTR_VAL(ce->name), ZSTR_VAL(property_name));
20962096
return 0;
20972097
}
20982098
/* }}} */
20992099

2100-
static ZEND_COLD zend_never_inline void zend_bad_constructor_call(zend_function *constructor, zend_class_entry *scope) /* {{{ */
2100+
static ZEND_COLD zend_never_inline void zend_bad_constructor_call(const zend_function *constructor, const zend_class_entry *scope) /* {{{ */
21012101
{
21022102
if (scope) {
21032103
zend_throw_error(NULL, "Call to %s %s::%s() from scope %s",

Zend/zend_object_handlers.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ ZEND_API void zend_class_init_statics(zend_class_entry *ce);
249249
ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, zend_string *function_name_strval, const zval *key);
250250
ZEND_API zval *zend_std_get_static_property_with_info(zend_class_entry *ce, zend_string *property_name, int type, struct _zend_property_info **prop_info);
251251
ZEND_API zval *zend_std_get_static_property(zend_class_entry *ce, zend_string *property_name, int type);
252-
ZEND_API ZEND_COLD bool zend_std_unset_static_property(zend_class_entry *ce, zend_string *property_name);
252+
ZEND_API ZEND_COLD bool zend_std_unset_static_property(const zend_class_entry *ce, const zend_string *property_name);
253253
ZEND_API zend_function *zend_std_get_constructor(zend_object *object);
254254
ZEND_API struct _zend_property_info *zend_get_property_info(const zend_class_entry *ce, zend_string *member, int silent);
255255
ZEND_API HashTable *zend_std_get_properties(zend_object *object);
@@ -272,8 +272,8 @@ ZEND_API int zend_std_compare_objects(zval *o1, zval *o2);
272272
ZEND_API zend_result zend_std_get_closure(zend_object *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr, bool check_only);
273273
/* Use zend_std_get_properties_ex() */
274274
ZEND_API HashTable *rebuild_object_properties_internal(zend_object *zobj);
275-
ZEND_API ZEND_COLD zend_never_inline void zend_bad_method_call(zend_function *fbc, zend_string *method_name, zend_class_entry *scope);
276-
ZEND_API ZEND_COLD zend_never_inline void zend_abstract_method_call(zend_function *fbc);
275+
ZEND_API ZEND_COLD zend_never_inline void zend_bad_method_call(const zend_function *fbc, const zend_string *method_name, const zend_class_entry *scope);
276+
ZEND_API ZEND_COLD zend_never_inline void zend_abstract_method_call(const zend_function *fbc);
277277

278278
static zend_always_inline HashTable *zend_std_get_properties_ex(zend_object *object)
279279
{

0 commit comments

Comments
 (0)