Skip to content

Commit 71edc05

Browse files
DanielEScherzernielsdosiluuu1994
authored
php_reflection.c: make a bunch of pointers const (php#15927)
* php_reflection.c: make a bunch of pointers `const` * _function_closure_string: use %u for unsigned Co-authored-by: Niels Dossche <7771979+nielsdos@users.noreply.github.com> * _extension_class_string: make indent pointer `const` Co-authored-by: Ilija Tovilo <ilija.tovilo@me.com> --------- Co-authored-by: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Co-authored-by: Ilija Tovilo <ilija.tovilo@me.com>
1 parent 65b4f22 commit 71edc05

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

ext/reflection/php_reflection.c

+24-24
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,11 @@ static inline reflection_object *reflection_object_from_obj(zend_object *obj) {
188188

189189
static zend_object_handlers reflection_object_handlers;
190190

191-
static zend_always_inline uint32_t prop_get_flags(property_reference *ref) {
191+
static zend_always_inline uint32_t prop_get_flags(const property_reference *ref) {
192192
return ref->prop ? ref->prop->flags : ZEND_ACC_PUBLIC;
193193
}
194194

195-
static inline bool is_closure_invoke(zend_class_entry *ce, zend_string *lcname) {
195+
static inline bool is_closure_invoke(const zend_class_entry *ce, const zend_string *lcname) {
196196
return ce == zend_ce_closure
197197
&& zend_string_equals_literal(lcname, ZEND_INVOKE_FUNC_NAME);
198198
}
@@ -302,16 +302,16 @@ static zval *reflection_instantiate(zend_class_entry *pce, zval *object) /* {{{
302302
}
303303
/* }}} */
304304

305-
static void _const_string(smart_str *str, char *name, zval *value, char *indent);
306-
static void _function_string(smart_str *str, zend_function *fptr, zend_class_entry *scope, char* indent);
307-
static void _property_string(smart_str *str, zend_property_info *prop, const char *prop_name, char* indent);
308-
static void _class_const_string(smart_str *str, zend_string *name, zend_class_constant *c, char* indent);
309-
static void _class_string(smart_str *str, zend_class_entry *ce, zval *obj, char *indent);
310-
static void _extension_string(smart_str *str, zend_module_entry *module, char *indent);
311-
static void _zend_extension_string(smart_str *str, zend_extension *extension, char *indent);
305+
static void _const_string(smart_str *str, const char *name, zval *value, const char *indent);
306+
static void _function_string(smart_str *str, zend_function *fptr, zend_class_entry *scope, const char* indent);
307+
static void _property_string(smart_str *str, zend_property_info *prop, const char *prop_name, const char* indent);
308+
static void _class_const_string(smart_str *str, const zend_string *name, zend_class_constant *c, const char* indent);
309+
static void _class_string(smart_str *str, zend_class_entry *ce, zval *obj, const char *indent);
310+
static void _extension_string(smart_str *str, const zend_module_entry *module, const char *indent);
311+
static void _zend_extension_string(smart_str *str, const zend_extension *extension, const char *indent);
312312

313313
/* {{{ _class_string */
314-
static void _class_string(smart_str *str, zend_class_entry *ce, zval *obj, char *indent)
314+
static void _class_string(smart_str *str, zend_class_entry *ce, zval *obj, const char *indent)
315315
{
316316
int count, count_static_props = 0, count_static_funcs = 0, count_shadow_props = 0;
317317
zend_string *sub_indent = strpprintf(0, "%s ", indent);
@@ -543,7 +543,7 @@ static void _class_string(smart_str *str, zend_class_entry *ce, zval *obj, char
543543
/* }}} */
544544

545545
/* {{{ _const_string */
546-
static void _const_string(smart_str *str, char *name, zval *value, char *indent)
546+
static void _const_string(smart_str *str, const char *name, zval *value, const char *indent)
547547
{
548548
const char *type = zend_zval_type_name(value);
549549
uint32_t flags = Z_CONSTANT_FLAGS_P(value);
@@ -592,7 +592,7 @@ static void _const_string(smart_str *str, char *name, zval *value, char *indent)
592592
/* }}} */
593593

594594
/* {{{ _class_const_string */
595-
static void _class_const_string(smart_str *str, zend_string *name, zend_class_constant *c, char *indent)
595+
static void _class_const_string(smart_str *str, const zend_string *name, zend_class_constant *c, const char *indent)
596596
{
597597
if (Z_TYPE(c->value) == IS_CONSTANT_AST && zend_update_class_constant(c, name, c->ce) == FAILURE) {
598598
return;
@@ -626,10 +626,10 @@ static void _class_const_string(smart_str *str, zend_string *name, zend_class_co
626626
}
627627
/* }}} */
628628

629-
static zend_op *get_recv_op(zend_op_array *op_array, uint32_t offset)
629+
static zend_op *get_recv_op(const zend_op_array *op_array, uint32_t offset)
630630
{
631631
zend_op *op = op_array->opcodes;
632-
zend_op *end = op + op_array->last;
632+
const zend_op *end = op + op_array->last;
633633

634634
++offset;
635635
while (op < end) {
@@ -772,11 +772,11 @@ static void _function_parameter_string(smart_str *str, zend_function *fptr, char
772772
/* }}} */
773773

774774
/* {{{ _function_closure_string */
775-
static void _function_closure_string(smart_str *str, zend_function *fptr, char* indent)
775+
static void _function_closure_string(smart_str *str, const zend_function *fptr, const char* indent)
776776
{
777777
uint32_t i, count;
778-
zend_string *key;
779-
HashTable *static_variables;
778+
const zend_string *key;
779+
const HashTable *static_variables;
780780

781781
if (fptr->type != ZEND_USER_FUNCTION || !fptr->op_array.static_variables) {
782782
return;
@@ -790,7 +790,7 @@ static void _function_closure_string(smart_str *str, zend_function *fptr, char*
790790
}
791791

792792
smart_str_append_printf(str, "\n");
793-
smart_str_append_printf(str, "%s- Bound Variables [%d] {\n", indent, zend_hash_num_elements(static_variables));
793+
smart_str_append_printf(str, "%s- Bound Variables [%u] {\n", indent, count);
794794
i = 0;
795795
ZEND_HASH_MAP_FOREACH_STR_KEY(static_variables, key) {
796796
smart_str_append_printf(str, "%s Variable #%d [ $%s ]\n", indent, i++, ZSTR_VAL(key));
@@ -800,7 +800,7 @@ static void _function_closure_string(smart_str *str, zend_function *fptr, char*
800800
/* }}} */
801801

802802
/* {{{ _function_string */
803-
static void _function_string(smart_str *str, zend_function *fptr, zend_class_entry *scope, char* indent)
803+
static void _function_string(smart_str *str, zend_function *fptr, zend_class_entry *scope, const char* indent)
804804
{
805805
smart_str param_indent = {0};
806806
zend_function *overwrites;
@@ -923,7 +923,7 @@ static zval *property_get_default(zend_property_info *prop_info) {
923923
}
924924

925925
/* {{{ _property_string */
926-
static void _property_string(smart_str *str, zend_property_info *prop, const char *prop_name, char* indent)
926+
static void _property_string(smart_str *str, zend_property_info *prop, const char *prop_name, const char* indent)
927927
{
928928
if (prop && prop->doc_comment) {
929929
smart_str_append_printf(str, "%s%s\n", indent, ZSTR_VAL(prop->doc_comment));
@@ -986,7 +986,7 @@ static void _property_string(smart_str *str, zend_property_info *prop, const cha
986986
}
987987
/* }}} */
988988

989-
static void _extension_ini_string(zend_ini_entry *ini_entry, smart_str *str, char *indent, int number) /* {{{ */
989+
static void _extension_ini_string(const zend_ini_entry *ini_entry, smart_str *str, const char *indent, int number) /* {{{ */
990990
{
991991
char *comma = "";
992992

@@ -1018,7 +1018,7 @@ static void _extension_ini_string(zend_ini_entry *ini_entry, smart_str *str, cha
10181018
}
10191019
/* }}} */
10201020

1021-
static void _extension_class_string(zend_class_entry *ce, zend_string *key, smart_str *str, char *indent, zend_module_entry *module, int *num_classes) /* {{{ */
1021+
static void _extension_class_string(zend_class_entry *ce, zend_string *key, smart_str *str, const char *indent, const zend_module_entry *module, int *num_classes) /* {{{ */
10221022
{
10231023
if (ce->type == ZEND_INTERNAL_CLASS && ce->info.internal.module && !strcasecmp(ce->info.internal.module->name, module->name)) {
10241024
/* dump class if it is not an alias */
@@ -1031,7 +1031,7 @@ static void _extension_class_string(zend_class_entry *ce, zend_string *key, smar
10311031
}
10321032
/* }}} */
10331033

1034-
static void _extension_string(smart_str *str, zend_module_entry *module, char *indent) /* {{{ */
1034+
static void _extension_string(smart_str *str, const zend_module_entry *module, const char *indent) /* {{{ */
10351035
{
10361036
smart_str_append_printf(str, "%sExtension [ ", indent);
10371037
if (module->type == MODULE_PERSISTENT) {
@@ -1270,7 +1270,7 @@ static void reflect_attributes(INTERNAL_FUNCTION_PARAMETERS, HashTable *attribut
12701270
}
12711271
/* }}} */
12721272

1273-
static void _zend_extension_string(smart_str *str, zend_extension *extension, char *indent) /* {{{ */
1273+
static void _zend_extension_string(smart_str *str, const zend_extension *extension, const char *indent) /* {{{ */
12741274
{
12751275
smart_str_append_printf(str, "%sZend Extension [ %s ", indent, extension->name);
12761276

0 commit comments

Comments
 (0)