Skip to content

Commit ec1d5c8

Browse files
committed
Fix slightly union types Reflection test
This is still a bit weird
1 parent 07712b9 commit ec1d5c8

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
@@ -3072,6 +3072,7 @@ ZEND_METHOD(ReflectionUnionType, getTypes)
30723072
reflection_object *intern;
30733073
type_reference *param;
30743074
uint32_t type_mask;
3075+
bool has_iterable = false;
30753076

30763077
if (zend_parse_parameters_none() == FAILURE) {
30773078
RETURN_THROWS();
@@ -3082,6 +3083,9 @@ ZEND_METHOD(ReflectionUnionType, getTypes)
30823083
if (ZEND_TYPE_HAS_LIST(param->type)) {
30833084
zend_type *list_type;
30843085
ZEND_TYPE_LIST_FOREACH(ZEND_TYPE_LIST(param->type), list_type) {
3086+
if (UNEXPECTED(ZEND_TYPE_IS_ITERABLE_FALLBACK(*list_type))) {
3087+
has_iterable = true;
3088+
}
30853089
append_type(return_value, *list_type);
30863090
} ZEND_TYPE_LIST_FOREACH_END();
30873091
} else if (ZEND_TYPE_HAS_NAME(param->type)) {
@@ -3101,7 +3105,7 @@ ZEND_METHOD(ReflectionUnionType, getTypes)
31013105
if (type_mask & MAY_BE_OBJECT) {
31023106
append_type_mask(return_value, MAY_BE_OBJECT);
31033107
}
3104-
if (type_mask & MAY_BE_ARRAY) {
3108+
if ((type_mask & MAY_BE_ARRAY) && !has_iterable) {
31053109
append_type_mask(return_value, MAY_BE_ARRAY);
31063110
}
31073111
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
@@ -83,9 +83,6 @@ Allows null: false
8383
Name: iterable
8484
String: iterable
8585
Allows Null: false
86-
Name: array
87-
String: array
88-
Allows Null: false
8986
Name: bool
9087
String: bool
9188
Allows Null: false

0 commit comments

Comments
 (0)