Skip to content

Commit 126644b

Browse files
committed
Properly register unresolved classes
1 parent 2eaef93 commit 126644b

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
Covariant replacement of iterable type with unregistered intersection type in DNF type
3+
--FILE--
4+
<?php
5+
6+
class Test {
7+
function method1(): iterable|string {}
8+
function method2(): iterable|int {}
9+
}
10+
class Test2 extends Test {
11+
function method1(): (X&Traversable)|string {}
12+
function method2(): int|(X&MyIterator) {}
13+
}
14+
15+
?>
16+
===DONE===
17+
--EXPECTF--
18+
Fatal error: Could not check compatibility between Test2::method2(): (X&MyIterator)|int and Test::method2(): Traversable|array|int, because class X is not available in %s

Zend/zend_inheritance.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,10 @@ static zend_string *get_class_from_type(zend_class_entry *scope, zend_type singl
540540
static void register_unresolved_classes(zend_class_entry *scope, zend_type type) {
541541
zend_type *single_type;
542542
ZEND_TYPE_FOREACH(type, single_type) {
543+
if (ZEND_TYPE_HAS_LIST(*single_type)) {
544+
register_unresolved_classes(scope, *single_type);
545+
continue;
546+
}
543547
if (ZEND_TYPE_HAS_NAME(*single_type)) {
544548
zend_string *class_name = resolve_class_name(scope, ZEND_TYPE_NAME(*single_type));
545549
lookup_class_ex(scope, class_name, /* register_unresolved */ true);

0 commit comments

Comments
 (0)