summaryrefslogtreecommitdiff
path: root/ext/reflection/php_reflection.c
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2020-01-16 17:04:11 +0100
committerNikita Popov <nikita.ppv@gmail.com>2020-01-17 09:37:54 +0100
commitbd1977282c14c1daa1718a82eb4b3bf79250ca16 (patch)
treef24251eb550ff4533ee0699114bdd34440dba3fe /ext/reflection/php_reflection.c
parentafdaa91170a1f7b0387cf577d957d4d6c015c136 (diff)
downloadphp-git-bd1977282c14c1daa1718a82eb4b3bf79250ca16.tar.gz
Use zend_type inside type lists
Instead of having a completely independent encoding for type list entries. This is going to use more memory, but I'm not particularly concerned about that, as type unions that contain multiple classes should be uncommon. On the other hand, this allows us to treat top-level types and types inside lists mostly the same. A new ZEND_TYPE_FOREACH macros allows to transparently treat list and non-list types the same way. I'm not using it everywhere it could be used for now, just the places that seemed most obvious. Of course, this will make any future type system changes much simpler, as it will not be necessary to duplicate all logic two times.
Diffstat (limited to 'ext/reflection/php_reflection.c')
-rw-r--r--ext/reflection/php_reflection.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index 73ab2b8969..b240d233f7 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -2938,15 +2938,9 @@ ZEND_METHOD(reflection_union_type, getTypes)
array_init(return_value);
if (ZEND_TYPE_HAS_LIST(param->type)) {
- void *entry;
- ZEND_TYPE_LIST_FOREACH(ZEND_TYPE_LIST(param->type), entry) {
- if (ZEND_TYPE_LIST_IS_NAME(entry)) {
- append_type(return_value,
- (zend_type) ZEND_TYPE_INIT_CLASS(ZEND_TYPE_LIST_GET_NAME(entry), 0, 0));
- } else {
- append_type(return_value,
- (zend_type) ZEND_TYPE_INIT_CE(ZEND_TYPE_LIST_GET_CE(entry), 0, 0));
- }
+ zend_type *list_type;
+ ZEND_TYPE_LIST_FOREACH(ZEND_TYPE_LIST(param->type), list_type) {
+ append_type(return_value, *list_type);
} ZEND_TYPE_LIST_FOREACH_END();
} else if (ZEND_TYPE_HAS_NAME(param->type)) {
append_type(return_value,