Skip to content

Commit d2e85d9

Browse files
committed
Test and simplicifation for nullable intersection type
1 parent 63fea91 commit d2e85d9

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--TEST--
2+
Intersection type cannot be nullable
3+
--FILE--
4+
<?php
5+
6+
function foo(): ?Countable&Iterator {}
7+
8+
?>
9+
--EXPECTF--
10+
Parse error: syntax error, unexpected token "&", expecting "{" in %s on line %d

Zend/zend_compile.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6293,10 +6293,6 @@ static zend_type zend_compile_typename(
62936293
zend_ast_list *list = zend_ast_get_list(ast);
62946294
zend_type_list *type_list;
62956295

6296-
if (allow_null) {
6297-
zend_error_noreturn(E_COMPILE_ERROR, "Nullable type cannot be part of an intersection type");
6298-
}
6299-
63006296
/* Allocate the type list directly on the arena as it must be a type
63016297
* list of the same number of elements as the AST list has children */
63026298
type_list = zend_arena_alloc(&CG(arena), ZEND_TYPE_LIST_SIZE(list->children));

0 commit comments

Comments
 (0)