summaryrefslogtreecommitdiff
path: root/Zend/zend_objects_API.h
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_objects_API.h
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_objects_API.h')
-rw-r--r--Zend/zend_objects_API.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/Zend/zend_objects_API.h b/Zend/zend_objects_API.h
index 658c8407cf..2a569604fc 100644
--- a/Zend/zend_objects_API.h
+++ b/Zend/zend_objects_API.h
@@ -95,6 +95,24 @@ static zend_always_inline void *zend_object_alloc(size_t obj_size, zend_class_en
return obj;
}
+static inline zend_property_info *zend_get_property_info_for_slot(zend_object *obj, zval *slot)
+{
+ zend_property_info **table = obj->ce->properties_info_table;
+ intptr_t prop_num = slot - obj->properties_table;
+ ZEND_ASSERT(prop_num >= 0 && prop_num < obj->ce->default_properties_count);
+ return table[prop_num];
+}
+
+/* Helper for cases where we're only interested in property info of typed properties. */
+static inline zend_property_info *zend_get_typed_property_info_for_slot(zend_object *obj, zval *slot)
+{
+ zend_property_info *prop_info = zend_get_property_info_for_slot(obj, slot);
+ if (prop_info && prop_info->type) {
+ return prop_info;
+ }
+ return NULL;
+}
+
#endif /* ZEND_OBJECTS_H */