File tree Expand file tree Collapse file tree 2 files changed +9
-5
lines changed
tests/type_declarations/intersection_types/invalid_types Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -7,4 +7,4 @@ function foo(): iterable&Iterator {}
7
7
8
8
?>
9
9
--EXPECTF--
10
- Fatal error: Type iterable cannot be part of an intersection type in %s on line %d
10
+ Fatal error: Type Traversable|array cannot be part of an intersection type in %s on line %d
Original file line number Diff line number Diff line change @@ -6288,11 +6288,15 @@ static zend_type zend_compile_typename(
6288
6288
zend_ast * type_ast = list -> child [i ];
6289
6289
zend_type single_type = zend_compile_single_typename (type_ast );
6290
6290
6291
- /* An intersection of standard types cannot exist so invalidate it */
6292
- /* Check for iterable early */
6293
- if (ZEND_TYPE_IS_ITERABLE_FALLBACK (single_type )) {
6294
- zend_error_noreturn (E_COMPILE_ERROR , "Type iterable cannot be part of an intersection type" );
6291
+ /* An intersection of union types cannot exist so invalidate it
6292
+ * Currently only can happen with iterable getting canonicalized to Traversable|array */
6293
+ if (ZEND_TYPE_IS_UNION (single_type )) {
6294
+ zend_string * standard_type_str = zend_type_to_string (single_type );
6295
+ zend_error_noreturn (E_COMPILE_ERROR ,
6296
+ "Type %s cannot be part of an intersection type" , ZSTR_VAL (standard_type_str ));
6297
+ zend_string_release_ex (standard_type_str , false);
6295
6298
}
6299
+ /* An intersection of standard types cannot exist so invalidate it */
6296
6300
if (ZEND_TYPE_IS_ONLY_MASK (single_type )) {
6297
6301
zend_string * standard_type_str = zend_type_to_string (single_type );
6298
6302
zend_error_noreturn (E_COMPILE_ERROR ,
You can’t perform that action at this time.
0 commit comments