Skip to content

Commit 6672395

Browse files
committed
Fix slightly union types Reflection test
This is still a bit weird
1 parent 76dcec7 commit 6672395

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
@@ -3071,6 +3071,7 @@ ZEND_METHOD(ReflectionUnionType, getTypes)
30713071
reflection_object *intern;
30723072
type_reference *param;
30733073
uint32_t type_mask;
3074+
bool has_iterable = false;
30743075

30753076
if (zend_parse_parameters_none() == FAILURE) {
30763077
RETURN_THROWS();
@@ -3081,6 +3082,9 @@ ZEND_METHOD(ReflectionUnionType, getTypes)
30813082
if (ZEND_TYPE_HAS_LIST(param->type)) {
30823083
zend_type *list_type;
30833084
ZEND_TYPE_LIST_FOREACH(ZEND_TYPE_LIST(param->type), list_type) {
3085+
if (UNEXPECTED(ZEND_TYPE_IS_ITERABLE_FALLBACK(*list_type))) {
3086+
has_iterable = true;
3087+
}
30843088
append_type(return_value, *list_type);
30853089
} ZEND_TYPE_LIST_FOREACH_END();
30863090
} else if (ZEND_TYPE_HAS_NAME(param->type)) {
@@ -3100,7 +3104,7 @@ ZEND_METHOD(ReflectionUnionType, getTypes)
31003104
if (type_mask & MAY_BE_OBJECT) {
31013105
append_type_mask(return_value, MAY_BE_OBJECT);
31023106
}
3103-
if (type_mask & MAY_BE_ARRAY) {
3107+
if ((type_mask & MAY_BE_ARRAY) && !has_iterable) {
31043108
append_type_mask(return_value, MAY_BE_ARRAY);
31053109
}
31063110
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)