summaryrefslogtreecommitdiff
path: root/Zend/zend_opcode.c
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2019-01-07 12:28:51 +0100
committerNikita Popov <nikita.ppv@gmail.com>2019-01-11 15:49:06 +0100
commite219ec144ef6682b71e135fd18654ee1bb4676b4 (patch)
treee4a3ae2b619cdc9fe50ee8e1fa5adb99d804dddf /Zend/zend_opcode.c
parentfe8fdfa3bd588d80ce60f6b3848058239e0a760f (diff)
downloadphp-git-e219ec144ef6682b71e135fd18654ee1bb4676b4.tar.gz
Implement typed properties
RFC: https://wiki.php.net/rfc/typed_properties_v2 This is a squash of PR #3734, which is a squash of PR #3313. Co-authored-by: Bob Weinand <bobwei9@hotmail.com> Co-authored-by: Joe Watkins <krakjoe@php.net> Co-authored-by: Dmitry Stogov <dmitry@zend.com>
Diffstat (limited to 'Zend/zend_opcode.c')
-rw-r--r--Zend/zend_opcode.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/Zend/zend_opcode.c b/Zend/zend_opcode.c
index 6ec0e2d1c8..ec624a5adb 100644
--- a/Zend/zend_opcode.c
+++ b/Zend/zend_opcode.c
@@ -148,6 +148,15 @@ ZEND_API void zend_cleanup_internal_class_data(zend_class_entry *ce)
ZEND_MAP_PTR_SET(ce->static_members_table, NULL);
while (p != end) {
+ if (UNEXPECTED(Z_ISREF_P(p))) {
+ zend_property_info *prop_info;
+ ZEND_REF_FOREACH_TYPE_SOURCES(Z_REF_P(p), prop_info) {
+ if (prop_info->ce == ce && p - static_members == prop_info->offset) {
+ ZEND_REF_DEL_TYPE_SOURCE(Z_REF_P(p), prop_info);
+ break; /* stop iteration here, the array might be realloc()'ed */
+ }
+ } ZEND_REF_FOREACH_TYPE_SOURCES_END();
+ }
i_zval_ptr_dtor(p);
p++;
}
@@ -247,6 +256,15 @@ ZEND_API void destroy_zend_class(zval *zv)
zval *end = p + ce->default_static_members_count;
while (p != end) {
+ if (UNEXPECTED(Z_ISREF_P(p))) {
+ zend_property_info *prop_info;
+ ZEND_REF_FOREACH_TYPE_SOURCES(Z_REF_P(p), prop_info) {
+ if (prop_info->ce == ce && p - ce->default_static_members_table == prop_info->offset) {
+ ZEND_REF_DEL_TYPE_SOURCE(Z_REF_P(p), prop_info);
+ break; /* stop iteration here, the array might be realloc()'ed */
+ }
+ } ZEND_REF_FOREACH_TYPE_SOURCES_END();
+ }
i_zval_ptr_dtor(p);
p++;
}
@@ -258,6 +276,9 @@ ZEND_API void destroy_zend_class(zval *zv)
if (prop_info->doc_comment) {
zend_string_release_ex(prop_info->doc_comment, 0);
}
+ if (ZEND_TYPE_IS_NAME(prop_info->type)) {
+ zend_string_release(ZEND_TYPE_NAME(prop_info->type));
+ }
}
} ZEND_HASH_FOREACH_END();
zend_hash_destroy(&ce->properties_info);
@@ -353,6 +374,9 @@ ZEND_API void destroy_zend_class(zval *zv)
if (ce->num_interfaces > 0) {
free(ce->interfaces);
}
+ if (ce->properties_info_table) {
+ free(ce->properties_info_table);
+ }
free(ce);
break;
}