Skip to content

Commit 605a695

Browse files
committed
Fix slightly union types Reflection test
This is still a bit weird
1 parent d953854 commit 605a695

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

ext/reflection/php_reflection.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3065,6 +3065,7 @@ ZEND_METHOD(ReflectionUnionType, getTypes)
30653065
reflection_object *intern;
30663066
type_reference *param;
30673067
uint32_t type_mask;
3068+
bool has_iterable = false;
30683069

30693070
if (zend_parse_parameters_none() == FAILURE) {
30703071
RETURN_THROWS();
@@ -3075,6 +3076,9 @@ ZEND_METHOD(ReflectionUnionType, getTypes)
30753076
if (ZEND_TYPE_HAS_LIST(param->type)) {
30763077
zend_type *list_type;
30773078
ZEND_TYPE_LIST_FOREACH(ZEND_TYPE_LIST(param->type), list_type) {
3079+
if (UNEXPECTED(ZEND_TYPE_IS_ITERABLE_FALLBACK(*list_type))) {
3080+
has_iterable = true;
3081+
}
30783082
append_type(return_value, *list_type);
30793083
} ZEND_TYPE_LIST_FOREACH_END();
30803084
} else if (ZEND_TYPE_HAS_NAME(param->type)) {
@@ -3094,7 +3098,7 @@ ZEND_METHOD(ReflectionUnionType, getTypes)
30943098
if (type_mask & MAY_BE_OBJECT) {
30953099
append_type_mask(return_value, MAY_BE_OBJECT);
30963100
}
3097-
if (type_mask & MAY_BE_ARRAY) {
3101+
if ((type_mask & MAY_BE_ARRAY) && !has_iterable) {
30983102
append_type_mask(return_value, MAY_BE_ARRAY);
30993103
}
31003104
if (type_mask & MAY_BE_STRING) {

ext/reflection/tests/union_types.phpt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,6 @@ Allows null: false
7272
Name: iterable
7373
String: iterable
7474
Allows Null: false
75-
Name: array
76-
String: array
77-
Allows Null: false
7875
Name: bool
7976
String: bool
8077
Allows Null: false

0 commit comments

Comments
 (0)