Skip to content

Commit d34c840

Browse files
authored
zend_builtin_functions.c: add const qualifiers (#21487)
1 parent be1ae8e commit d34c840

File tree

1 file changed

+16
-20
lines changed

1 file changed

+16
-20
lines changed

Zend/zend_builtin_functions.c

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ ZEND_FUNCTION(clone)
8484

8585
/* clone() also exists as the ZEND_CLONE OPcode and both implementations must be kept in sync. */
8686

87-
zend_class_entry *scope = zend_get_executed_scope();
87+
const zend_class_entry *scope = zend_get_executed_scope();
8888

89-
zend_class_entry *ce = zobj->ce;
90-
zend_function *clone = ce->clone;
89+
const zend_class_entry *ce = zobj->ce;
90+
const zend_function *clone = ce->clone;
9191

9292
if (UNEXPECTED(zobj->handlers->clone_obj == NULL)) {
9393
zend_throw_error(NULL, "Trying to clone an uncloneable object of class %s", ZSTR_VAL(ce->name));
@@ -239,7 +239,7 @@ ZEND_FUNCTION(gc_status)
239239
/* {{{ Get the number of arguments that were passed to the function */
240240
ZEND_FUNCTION(func_num_args)
241241
{
242-
zend_execute_data *ex = EX(prev_execute_data);
242+
const zend_execute_data *ex = EX(prev_execute_data);
243243

244244
ZEND_PARSE_PARAMETERS_NONE();
245245

@@ -527,7 +527,7 @@ static bool validate_constant_array_argument(HashTable *ht, int argument_number)
527527
}
528528
/* }}} */
529529

530-
static void copy_constant_array(zval *dst, zval *src) /* {{{ */
530+
static void copy_constant_array(zval *dst, const zval *src) /* {{{ */
531531
{
532532
zend_string *key;
533533
zend_ulong idx;
@@ -647,11 +647,9 @@ ZEND_FUNCTION(get_class)
647647
/* {{{ Retrieves the "Late Static Binding" class name */
648648
ZEND_FUNCTION(get_called_class)
649649
{
650-
zend_class_entry *called_scope;
651-
652650
ZEND_PARSE_PARAMETERS_NONE();
653651

654-
called_scope = zend_get_called_scope(execute_data);
652+
const zend_class_entry *called_scope = zend_get_called_scope(execute_data);
655653
if (!called_scope) {
656654
zend_throw_error(NULL, "get_called_class() must be called from within a class");
657655
RETURN_THROWS();
@@ -691,8 +689,7 @@ static void is_a_impl(INTERNAL_FUNCTION_PARAMETERS, bool only_subclass) /* {{{ *
691689
{
692690
zval *obj;
693691
zend_string *class_name;
694-
zend_class_entry *instance_ce;
695-
zend_class_entry *ce;
692+
const zend_class_entry *instance_ce;
696693
bool allow_string = only_subclass;
697694
bool retval;
698695

@@ -723,7 +720,7 @@ static void is_a_impl(INTERNAL_FUNCTION_PARAMETERS, bool only_subclass) /* {{{ *
723720
if (!only_subclass && EXPECTED(zend_string_equals(instance_ce->name, class_name))) {
724721
retval = 1;
725722
} else {
726-
ce = zend_lookup_class_ex(class_name, NULL, ZEND_FETCH_CLASS_NO_AUTOLOAD);
723+
const zend_class_entry *ce = zend_lookup_class_ex(class_name, NULL, ZEND_FETCH_CLASS_NO_AUTOLOAD);
727724
if (!ce) {
728725
retval = 0;
729726
} else {
@@ -754,7 +751,7 @@ ZEND_FUNCTION(is_a)
754751
/* }}} */
755752

756753
/* {{{ add_class_vars */
757-
static void add_class_vars(zend_class_entry *scope, zend_class_entry *ce, bool statics, zval *return_value)
754+
static void add_class_vars(const zend_class_entry *scope, zend_class_entry *ce, bool statics, const zval *return_value)
758755
{
759756
zend_property_info *prop_info;
760757
zval *prop, prop_copy;
@@ -805,7 +802,7 @@ static void add_class_vars(zend_class_entry *scope, zend_class_entry *ce, bool s
805802
/* {{{ Returns an array of default properties of the class. */
806803
ZEND_FUNCTION(get_class_vars)
807804
{
808-
zend_class_entry *ce = NULL, *scope;
805+
zend_class_entry *ce = NULL;
809806

810807
if (zend_parse_parameters(ZEND_NUM_ARGS(), "C", &ce) == FAILURE) {
811808
RETURN_THROWS();
@@ -818,7 +815,7 @@ ZEND_FUNCTION(get_class_vars)
818815
}
819816
}
820817

821-
scope = zend_get_executed_scope();
818+
const zend_class_entry *scope = zend_get_executed_scope();
822819
add_class_vars(scope, ce, false, return_value);
823820
add_class_vars(scope, ce, true, return_value);
824821
}
@@ -944,15 +941,14 @@ ZEND_FUNCTION(get_class_methods)
944941
{
945942
zval method_name;
946943
zend_class_entry *ce = NULL;
947-
zend_class_entry *scope;
948944
zend_function *mptr;
949945

950946
ZEND_PARSE_PARAMETERS_START(1, 1)
951947
Z_PARAM_OBJ_OR_CLASS_NAME(ce)
952948
ZEND_PARSE_PARAMETERS_END();
953949

954950
array_init(return_value);
955-
scope = zend_get_executed_scope();
951+
const zend_class_entry *scope = zend_get_executed_scope();
956952

957953
ZEND_HASH_MAP_FOREACH_PTR(&ce->function_table, mptr) {
958954
if (zend_check_method_accessible(mptr, scope)) {
@@ -1027,7 +1023,7 @@ ZEND_FUNCTION(method_exists)
10271023
}
10281024
/* }}} */
10291025

1030-
static void _property_exists(zval *return_value, zval *object, zend_string *property)
1026+
static void _property_exists(zval *return_value, const zval *object, zend_string *property)
10311027
{
10321028
zend_class_entry *ce;
10331029
zend_property_info *property_info;
@@ -1091,7 +1087,7 @@ flf_clean:;
10911087
static zend_always_inline void _class_exists_impl(zval *return_value, zend_string *name, bool autoload, int flags, int skip_flags) /* {{{ */
10921088
{
10931089
zend_string *lcname;
1094-
zend_class_entry *ce;
1090+
const zend_class_entry *ce;
10951091

10961092
if (ZSTR_HAS_CE_CACHE(name)) {
10971093
ce = ZSTR_GET_CE_CACHE(name);
@@ -1616,7 +1612,7 @@ ZEND_FUNCTION(get_resources)
16161612
}
16171613
/* }}} */
16181614

1619-
static void add_zendext_info(zend_extension *ext, void *arg) /* {{{ */
1615+
static void add_zendext_info(const zend_extension *ext, void *arg) /* {{{ */
16201616
{
16211617
zval *name_array = (zval *)arg;
16221618
add_next_index_string(name_array, ext->name);
@@ -1719,7 +1715,7 @@ ZEND_FUNCTION(get_defined_constants)
17191715

17201716
static bool backtrace_is_arg_sensitive(const zend_execute_data *call, uint32_t offset)
17211717
{
1722-
zend_attribute *attribute = zend_get_parameter_attribute_str(
1718+
const zend_attribute *attribute = zend_get_parameter_attribute_str(
17231719
call->func->common.attributes,
17241720
"sensitiveparameter",
17251721
sizeof("sensitiveparameter") - 1,

0 commit comments

Comments
 (0)