Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions Zend/zend_API.h
Original file line number Diff line number Diff line change
Expand Up @@ -445,10 +445,10 @@ ZEND_API zend_result zend_update_class_constant(zend_class_constant *c, const ze
ZEND_API zend_result zend_update_class_constants(zend_class_entry *class_type);
ZEND_API HashTable *zend_separate_class_constants_table(const zend_class_entry *class_type);

static zend_always_inline HashTable *zend_class_constants_table(zend_class_entry *ce) {
static zend_always_inline const HashTable *zend_class_constants_table(const zend_class_entry *ce) {
if ((ce->ce_flags & ZEND_ACC_HAS_AST_CONSTANTS) && ZEND_MAP_PTR(ce->mutable_data)) {
zend_class_mutable_data *mutable_data =
(zend_class_mutable_data*)ZEND_MAP_PTR_GET_IMM(ce->mutable_data);
const zend_class_mutable_data *mutable_data =
(const zend_class_mutable_data*)ZEND_MAP_PTR_GET_IMM(ce->mutable_data);
if (mutable_data && mutable_data->constants_table) {
return mutable_data->constants_table;
} else {
Expand All @@ -459,10 +459,10 @@ static zend_always_inline HashTable *zend_class_constants_table(zend_class_entry
}
}

static zend_always_inline zval *zend_class_default_properties_table(zend_class_entry *ce) {
static zend_always_inline zval *zend_class_default_properties_table(const zend_class_entry *ce) {
if ((ce->ce_flags & ZEND_ACC_HAS_AST_PROPERTIES) && ZEND_MAP_PTR(ce->mutable_data)) {
zend_class_mutable_data *mutable_data =
(zend_class_mutable_data*)ZEND_MAP_PTR_GET_IMM(ce->mutable_data);
const zend_class_mutable_data *mutable_data =
(const zend_class_mutable_data*)ZEND_MAP_PTR_GET_IMM(ce->mutable_data);
return mutable_data->default_properties_table;
} else {
return ce->default_properties_table;
Expand All @@ -479,10 +479,10 @@ static zend_always_inline void zend_class_set_backed_enum_table(zend_class_entry
}
}

static zend_always_inline HashTable *zend_class_backed_enum_table(zend_class_entry *ce)
static zend_always_inline HashTable *zend_class_backed_enum_table(const zend_class_entry *ce)
{
if (ZEND_MAP_PTR(ce->mutable_data) && ce->type == ZEND_USER_CLASS) {
zend_class_mutable_data *mutable_data = (zend_class_mutable_data*)ZEND_MAP_PTR_GET_IMM(ce->mutable_data);
const zend_class_mutable_data *mutable_data = (const zend_class_mutable_data*)ZEND_MAP_PTR_GET_IMM(ce->mutable_data);
return mutable_data->backed_enum_table;
} else {
return ce->backed_enum_table;
Expand Down
36 changes: 16 additions & 20 deletions Zend/zend_builtin_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ ZEND_FUNCTION(clone)

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

zend_class_entry *scope = zend_get_executed_scope();
const zend_class_entry *scope = zend_get_executed_scope();

zend_class_entry *ce = zobj->ce;
zend_function *clone = ce->clone;
const zend_class_entry *ce = zobj->ce;
const zend_function *clone = ce->clone;

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

ZEND_PARSE_PARAMETERS_NONE();

Expand Down Expand Up @@ -527,7 +527,7 @@ static bool validate_constant_array_argument(HashTable *ht, int argument_number)
}
/* }}} */

static void copy_constant_array(zval *dst, zval *src) /* {{{ */
static void copy_constant_array(zval *dst, const zval *src) /* {{{ */
{
zend_string *key;
zend_ulong idx;
Expand Down Expand Up @@ -647,11 +647,9 @@ ZEND_FUNCTION(get_class)
/* {{{ Retrieves the "Late Static Binding" class name */
ZEND_FUNCTION(get_called_class)
{
zend_class_entry *called_scope;

ZEND_PARSE_PARAMETERS_NONE();

called_scope = zend_get_called_scope(execute_data);
const zend_class_entry *called_scope = zend_get_called_scope(execute_data);
if (!called_scope) {
zend_throw_error(NULL, "get_called_class() must be called from within a class");
RETURN_THROWS();
Expand Down Expand Up @@ -691,8 +689,7 @@ static void is_a_impl(INTERNAL_FUNCTION_PARAMETERS, bool only_subclass) /* {{{ *
{
zval *obj;
zend_string *class_name;
zend_class_entry *instance_ce;
zend_class_entry *ce;
const zend_class_entry *instance_ce;
bool allow_string = only_subclass;
bool retval;

Expand Down Expand Up @@ -723,7 +720,7 @@ static void is_a_impl(INTERNAL_FUNCTION_PARAMETERS, bool only_subclass) /* {{{ *
if (!only_subclass && EXPECTED(zend_string_equals(instance_ce->name, class_name))) {
retval = 1;
} else {
ce = zend_lookup_class_ex(class_name, NULL, ZEND_FETCH_CLASS_NO_AUTOLOAD);
const zend_class_entry *ce = zend_lookup_class_ex(class_name, NULL, ZEND_FETCH_CLASS_NO_AUTOLOAD);
if (!ce) {
retval = 0;
} else {
Expand Down Expand Up @@ -754,7 +751,7 @@ ZEND_FUNCTION(is_a)
/* }}} */

/* {{{ add_class_vars */
static void add_class_vars(zend_class_entry *scope, zend_class_entry *ce, bool statics, zval *return_value)
static void add_class_vars(const zend_class_entry *scope, zend_class_entry *ce, bool statics, const zval *return_value)
{
zend_property_info *prop_info;
zval *prop, prop_copy;
Expand Down Expand Up @@ -805,7 +802,7 @@ static void add_class_vars(zend_class_entry *scope, zend_class_entry *ce, bool s
/* {{{ Returns an array of default properties of the class. */
ZEND_FUNCTION(get_class_vars)
{
zend_class_entry *ce = NULL, *scope;
zend_class_entry *ce = NULL;

if (zend_parse_parameters(ZEND_NUM_ARGS(), "C", &ce) == FAILURE) {
RETURN_THROWS();
Expand All @@ -818,7 +815,7 @@ ZEND_FUNCTION(get_class_vars)
}
}

scope = zend_get_executed_scope();
const zend_class_entry *scope = zend_get_executed_scope();
add_class_vars(scope, ce, false, return_value);
add_class_vars(scope, ce, true, return_value);
}
Expand Down Expand Up @@ -944,15 +941,14 @@ ZEND_FUNCTION(get_class_methods)
{
zval method_name;
zend_class_entry *ce = NULL;
zend_class_entry *scope;
zend_function *mptr;

ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_OBJ_OR_CLASS_NAME(ce)
ZEND_PARSE_PARAMETERS_END();

array_init(return_value);
scope = zend_get_executed_scope();
const zend_class_entry *scope = zend_get_executed_scope();

ZEND_HASH_MAP_FOREACH_PTR(&ce->function_table, mptr) {
if (zend_check_method_accessible(mptr, scope)) {
Expand Down Expand Up @@ -1027,7 +1023,7 @@ ZEND_FUNCTION(method_exists)
}
/* }}} */

static void _property_exists(zval *return_value, zval *object, zend_string *property)
static void _property_exists(zval *return_value, const zval *object, zend_string *property)
{
zend_class_entry *ce;
zend_property_info *property_info;
Expand Down Expand Up @@ -1091,7 +1087,7 @@ flf_clean:;
static zend_always_inline void _class_exists_impl(zval *return_value, zend_string *name, bool autoload, int flags, int skip_flags) /* {{{ */
{
zend_string *lcname;
zend_class_entry *ce;
const zend_class_entry *ce;

if (ZSTR_HAS_CE_CACHE(name)) {
ce = ZSTR_GET_CE_CACHE(name);
Expand Down Expand Up @@ -1616,7 +1612,7 @@ ZEND_FUNCTION(get_resources)
}
/* }}} */

static void add_zendext_info(zend_extension *ext, void *arg) /* {{{ */
static void add_zendext_info(const zend_extension *ext, void *arg) /* {{{ */
{
zval *name_array = (zval *)arg;
add_next_index_string(name_array, ext->name);
Expand Down Expand Up @@ -1719,7 +1715,7 @@ ZEND_FUNCTION(get_defined_constants)

static bool backtrace_is_arg_sensitive(const zend_execute_data *call, uint32_t offset)
{
zend_attribute *attribute = zend_get_parameter_attribute_str(
const zend_attribute *attribute = zend_get_parameter_attribute_str(
call->func->common.attributes,
"sensitiveparameter",
sizeof("sensitiveparameter") - 1,
Expand Down
10 changes: 5 additions & 5 deletions Zend/zend_constants.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ ZEND_API zend_constant *_zend_get_special_const(const char *name, size_t len) /*
}
/* }}} */

ZEND_API bool zend_verify_const_access(zend_class_constant *c, zend_class_entry *scope) /* {{{ */
ZEND_API bool zend_verify_const_access(const zend_class_constant *c, const zend_class_entry *scope) /* {{{ */
{
if (ZEND_CLASS_CONST_FLAGS(c) & ZEND_ACC_PUBLIC) {
return 1;
Expand Down Expand Up @@ -312,9 +312,9 @@ ZEND_API zval *zend_get_constant(zend_string *name)
return NULL;
}

ZEND_API zval *zend_get_class_constant_ex(zend_string *class_name, zend_string *constant_name, zend_class_entry *scope, uint32_t flags)
ZEND_API zval *zend_get_class_constant_ex(zend_string *class_name, zend_string *constant_name, const zend_class_entry *scope, uint32_t flags)
{
zend_class_entry *ce = NULL;
const zend_class_entry *ce = NULL;
zend_class_constant *c = NULL;
zval *ret_constant = NULL;

Expand Down Expand Up @@ -413,7 +413,7 @@ ZEND_API zval *zend_get_class_constant_ex(zend_string *class_name, zend_string *
return ret_constant;
}

ZEND_API zval *zend_get_constant_ex(zend_string *cname, zend_class_entry *scope, uint32_t flags)
ZEND_API zval *zend_get_constant_ex(zend_string *cname, const zend_class_entry *scope, uint32_t flags)
{
zend_constant *c;
const char *colon;
Expand Down Expand Up @@ -495,7 +495,7 @@ ZEND_API zval *zend_get_constant_ex(zend_string *cname, zend_class_entry *scope,
return &c->value;
}

static void* zend_hash_add_constant(HashTable *ht, zend_string *key, zend_constant *c)
static void* zend_hash_add_constant(HashTable *ht, zend_string *key, const zend_constant *c)
{
void *ret;
zend_constant *copy = pemalloc(sizeof(zend_constant), ZEND_CONSTANT_FLAGS(c) & CONST_PERSISTENT);
Expand Down
6 changes: 3 additions & 3 deletions Zend/zend_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ void clean_module_constants(int module_number);
void free_zend_constant(zval *zv);
void zend_startup_constants(void);
void zend_register_standard_constants(void);
ZEND_API bool zend_verify_const_access(zend_class_constant *c, zend_class_entry *ce);
ZEND_API bool zend_verify_const_access(const zend_class_constant *c, const zend_class_entry *ce);
ZEND_API zval *zend_get_constant(zend_string *name);
ZEND_API zend_constant *zend_get_constant_ptr(zend_string *name);
ZEND_API zval *zend_get_constant_str(const char *name, size_t name_len);
ZEND_API zval *zend_get_constant_ex(zend_string *name, zend_class_entry *scope, uint32_t flags);
ZEND_API zval *zend_get_class_constant_ex(zend_string *class_name, zend_string *constant_name, zend_class_entry *scope, uint32_t flags);
ZEND_API zval *zend_get_constant_ex(zend_string *name, const zend_class_entry *scope, uint32_t flags);
ZEND_API zval *zend_get_class_constant_ex(zend_string *class_name, zend_string *constant_name, const zend_class_entry *scope, uint32_t flags);
ZEND_API zend_constant *zend_register_bool_constant(const char *name, size_t name_len, bool bval, int flags, int module_number);
ZEND_API zend_constant *zend_register_null_constant(const char *name, size_t name_len, int flags, int module_number);
ZEND_API zend_constant *zend_register_long_constant(const char *name, size_t name_len, zend_long lval, int flags, int module_number);
Expand Down
2 changes: 1 addition & 1 deletion ext/reflection/php_reflection.c
Original file line number Diff line number Diff line change
Expand Up @@ -4820,7 +4820,7 @@ ZEND_METHOD(ReflectionClass, getConstant)
{
reflection_object *intern;
zend_class_entry *ce;
HashTable *constants_table;
const HashTable *constants_table;
zend_class_constant *c;
zend_string *name, *key;

Expand Down