Skip to content

Commit d1aebd2

Browse files
committed
zend_builtin_functions.c: add const qualifiers
1 parent f102735 commit d1aebd2

File tree

1 file changed

+17
-22
lines changed

1 file changed

+17
-22
lines changed

Zend/zend_builtin_functions.c

Lines changed: 17 additions & 22 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;
@@ -646,12 +646,9 @@ ZEND_FUNCTION(get_class)
646646

647647
/* {{{ Retrieves the "Late Static Binding" class name */
648648
ZEND_FUNCTION(get_called_class)
649-
{
650-
zend_class_entry *called_scope;
651-
652-
ZEND_PARSE_PARAMETERS_NONE();
649+
{ ZEND_PARSE_PARAMETERS_NONE();
653650

654-
called_scope = zend_get_called_scope(execute_data);
651+
const zend_class_entry *called_scope = zend_get_called_scope(execute_data);
655652
if (!called_scope) {
656653
zend_throw_error(NULL, "get_called_class() must be called from within a class");
657654
RETURN_THROWS();
@@ -691,8 +688,7 @@ static void is_a_impl(INTERNAL_FUNCTION_PARAMETERS, bool only_subclass) /* {{{ *
691688
{
692689
zval *obj;
693690
zend_string *class_name;
694-
zend_class_entry *instance_ce;
695-
zend_class_entry *ce;
691+
const zend_class_entry *instance_ce;
696692
bool allow_string = only_subclass;
697693
bool retval;
698694

@@ -723,7 +719,7 @@ static void is_a_impl(INTERNAL_FUNCTION_PARAMETERS, bool only_subclass) /* {{{ *
723719
if (!only_subclass && EXPECTED(zend_string_equals(instance_ce->name, class_name))) {
724720
retval = 1;
725721
} else {
726-
ce = zend_lookup_class_ex(class_name, NULL, ZEND_FETCH_CLASS_NO_AUTOLOAD);
722+
const zend_class_entry *ce = zend_lookup_class_ex(class_name, NULL, ZEND_FETCH_CLASS_NO_AUTOLOAD);
727723
if (!ce) {
728724
retval = 0;
729725
} else {
@@ -754,7 +750,7 @@ ZEND_FUNCTION(is_a)
754750
/* }}} */
755751

756752
/* {{{ add_class_vars */
757-
static void add_class_vars(zend_class_entry *scope, zend_class_entry *ce, bool statics, zval *return_value)
753+
static void add_class_vars(const zend_class_entry *scope, zend_class_entry *ce, bool statics, const zval *return_value)
758754
{
759755
zend_property_info *prop_info;
760756
zval *prop, prop_copy;
@@ -805,7 +801,7 @@ static void add_class_vars(zend_class_entry *scope, zend_class_entry *ce, bool s
805801
/* {{{ Returns an array of default properties of the class. */
806802
ZEND_FUNCTION(get_class_vars)
807803
{
808-
zend_class_entry *ce = NULL, *scope;
804+
zend_class_entry *ce = NULL;
809805

810806
if (zend_parse_parameters(ZEND_NUM_ARGS(), "C", &ce) == FAILURE) {
811807
RETURN_THROWS();
@@ -818,7 +814,7 @@ ZEND_FUNCTION(get_class_vars)
818814
}
819815
}
820816

821-
scope = zend_get_executed_scope();
817+
const zend_class_entry *scope = zend_get_executed_scope();
822818
add_class_vars(scope, ce, false, return_value);
823819
add_class_vars(scope, ce, true, return_value);
824820
}
@@ -944,15 +940,14 @@ ZEND_FUNCTION(get_class_methods)
944940
{
945941
zval method_name;
946942
zend_class_entry *ce = NULL;
947-
zend_class_entry *scope;
948943
zend_function *mptr;
949944

950945
ZEND_PARSE_PARAMETERS_START(1, 1)
951946
Z_PARAM_OBJ_OR_CLASS_NAME(ce)
952947
ZEND_PARSE_PARAMETERS_END();
953948

954949
array_init(return_value);
955-
scope = zend_get_executed_scope();
950+
const zend_class_entry *scope = zend_get_executed_scope();
956951

957952
ZEND_HASH_MAP_FOREACH_PTR(&ce->function_table, mptr) {
958953
if (zend_check_method_accessible(mptr, scope)) {
@@ -1027,7 +1022,7 @@ ZEND_FUNCTION(method_exists)
10271022
}
10281023
/* }}} */
10291024

1030-
static void _property_exists(zval *return_value, zval *object, zend_string *property)
1025+
static void _property_exists(zval *return_value, const zval *object, zend_string *property)
10311026
{
10321027
zend_class_entry *ce;
10331028
zend_property_info *property_info;
@@ -1091,7 +1086,7 @@ flf_clean:;
10911086
static zend_always_inline void _class_exists_impl(zval *return_value, zend_string *name, bool autoload, int flags, int skip_flags) /* {{{ */
10921087
{
10931088
zend_string *lcname;
1094-
zend_class_entry *ce;
1089+
const zend_class_entry *ce;
10951090

10961091
if (ZSTR_HAS_CE_CACHE(name)) {
10971092
ce = ZSTR_GET_CE_CACHE(name);
@@ -1616,7 +1611,7 @@ ZEND_FUNCTION(get_resources)
16161611
}
16171612
/* }}} */
16181613

1619-
static void add_zendext_info(zend_extension *ext, void *arg) /* {{{ */
1614+
static void add_zendext_info(const zend_extension *ext, void *arg) /* {{{ */
16201615
{
16211616
zval *name_array = (zval *)arg;
16221617
add_next_index_string(name_array, ext->name);
@@ -1719,7 +1714,7 @@ ZEND_FUNCTION(get_defined_constants)
17191714

17201715
static bool backtrace_is_arg_sensitive(const zend_execute_data *call, uint32_t offset)
17211716
{
1722-
zend_attribute *attribute = zend_get_parameter_attribute_str(
1717+
const zend_attribute *attribute = zend_get_parameter_attribute_str(
17231718
call->func->common.attributes,
17241719
"sensitiveparameter",
17251720
sizeof("sensitiveparameter") - 1,

0 commit comments

Comments
 (0)