Skip to content
Draft
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
51 changes: 14 additions & 37 deletions Zend/zend_API.c
Original file line number Diff line number Diff line change
Expand Up @@ -4415,7 +4415,7 @@ static zend_always_inline bool is_persistent_class(const zend_class_entry *ce) {

ZEND_API zend_property_info *zend_declare_typed_property(zend_class_entry *ce, zend_string *name, zval *property, int access_type, zend_string *doc_comment, zend_type type) /* {{{ */
{
zend_property_info *property_info, *property_info_ptr;
zend_property_info *property_info;

if (ZEND_TYPE_IS_SET(type)) {
ce->ce_flags |= ZEND_ACC_HAS_TYPE_HINTS;
Expand Down Expand Up @@ -4483,19 +4483,16 @@ ZEND_API zend_property_info *zend_declare_typed_property(zend_class_entry *ce, z
goto skip_property_storage;
}
}
#if ZEND_DEBUG
zend_property_info *existing_prop = zend_hash_find_ptr(&ce->properties_info, name);
if (existing_prop) {
fprintf(stderr, "Redeclared prop: %s::$%s\n", ZSTR_VAL(ce->name), ZSTR_VAL(name));
}
ZEND_ASSERT(!existing_prop);
#endif
if (access_type & ZEND_ACC_STATIC) {
if ((property_info_ptr = zend_hash_find_ptr(&ce->properties_info, name)) != NULL) {
ZEND_ASSERT(property_info_ptr->flags & ZEND_ACC_STATIC);
property_info->offset = property_info_ptr->offset;
zval_ptr_dtor(&ce->default_static_members_table[property_info->offset]);
if (property_info_ptr->doc_comment && property_info_ptr->ce == ce) {
zend_string_release(property_info_ptr->doc_comment);
}
zend_hash_del(&ce->properties_info, name);
} else {
property_info->offset = ce->default_static_members_count++;
ce->default_static_members_table = perealloc(ce->default_static_members_table, sizeof(zval) * ce->default_static_members_count, ce->type == ZEND_INTERNAL_CLASS);
}
property_info->offset = ce->default_static_members_count++;
ce->default_static_members_table = perealloc(ce->default_static_members_table, sizeof(zval) * ce->default_static_members_count, ce->type == ZEND_INTERNAL_CLASS);
ZVAL_COPY_VALUE(&ce->default_static_members_table[property_info->offset], property);
if (!ZEND_MAP_PTR(ce->static_members_table)) {
if (ce->type == ZEND_INTERNAL_CLASS &&
Expand All @@ -4504,31 +4501,11 @@ ZEND_API zend_property_info *zend_declare_typed_property(zend_class_entry *ce, z
}
}
} else {
zval *property_default_ptr;
if ((property_info_ptr = zend_hash_find_ptr(&ce->properties_info, name)) != NULL) {
ZEND_ASSERT(!(property_info_ptr->flags & ZEND_ACC_STATIC));
property_info->offset = property_info_ptr->offset;
zval_ptr_dtor(&ce->default_properties_table[OBJ_PROP_TO_NUM(property_info->offset)]);
if (property_info_ptr->doc_comment && property_info_ptr->ce == ce) {
zend_string_release_ex(property_info_ptr->doc_comment, 1);
}
zend_hash_del(&ce->properties_info, name);
property_info->offset = OBJ_PROP_TO_OFFSET(ce->default_properties_count);
ce->default_properties_count++;
ce->default_properties_table = perealloc(ce->default_properties_table, sizeof(zval) * ce->default_properties_count, ce->type == ZEND_INTERNAL_CLASS);

ZEND_ASSERT(ce->type == ZEND_INTERNAL_CLASS);
ZEND_ASSERT(ce->properties_info_table != NULL);
ce->properties_info_table[OBJ_PROP_TO_NUM(property_info->offset)] = property_info;
} else {
property_info->offset = OBJ_PROP_TO_OFFSET(ce->default_properties_count);
ce->default_properties_count++;
ce->default_properties_table = perealloc(ce->default_properties_table, sizeof(zval) * ce->default_properties_count, ce->type == ZEND_INTERNAL_CLASS);

/* For user classes this is handled during linking */
if (ce->type == ZEND_INTERNAL_CLASS) {
ce->properties_info_table = perealloc(ce->properties_info_table, sizeof(zend_property_info *) * ce->default_properties_count, 1);
ce->properties_info_table[ce->default_properties_count - 1] = property_info;
}
}
property_default_ptr = &ce->default_properties_table[OBJ_PROP_TO_NUM(property_info->offset)];
zval *property_default_ptr = &ce->default_properties_table[OBJ_PROP_TO_NUM(property_info->offset)];
ZVAL_COPY_VALUE(property_default_ptr, property);
Z_PROP_FLAG_P(property_default_ptr) = Z_ISUNDEF_P(property) ? IS_PROP_UNINIT : 0;
}
Expand Down
4 changes: 4 additions & 0 deletions Zend/zend_API.h
Original file line number Diff line number Diff line change
Expand Up @@ -2585,6 +2585,10 @@ static zend_always_inline bool zend_parse_arg_obj_or_str(
return zend_parse_arg_str(arg, destination_string, allow_null, arg_num);
}

/* Used in arginfo.h files, copied from zend_inheritance.h to avoid its inclusion. */
void zend_build_properties_info_table(zend_class_entry *ce);
ZEND_API void zend_do_inheritance_ex(zend_class_entry *ce, zend_class_entry *parent_ce, bool checked);

END_EXTERN_C()

#endif /* ZEND_API_H */
18 changes: 18 additions & 0 deletions Zend/zend_attributes_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Zend/zend_builtin_functions_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Zend/zend_closures_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Zend/zend_enum_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 48 additions & 12 deletions Zend/zend_exceptions_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion Zend/zend_fibers_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading