Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Properly register unresolved classes
  • Loading branch information
Girgias committed Jun 14, 2022
commit 1cea4db1640fd297793c8e55ccac47c4e70f4593
18 changes: 18 additions & 0 deletions Zend/tests/type_declarations/dnf_types/variance/valid9.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
--TEST--
Covariant replacement of iterable type with unregistered intersection type in DNF type
--FILE--
<?php

class Test {
function method1(): iterable|string {}
function method2(): iterable|int {}
}
class Test2 extends Test {
function method1(): (X&Traversable)|string {}
function method2(): int|(X&MyIterator) {}
}

?>
===DONE===
--EXPECTF--
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
4 changes: 4 additions & 0 deletions Zend/zend_inheritance.c
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,10 @@ static zend_string *get_class_from_type(zend_class_entry *scope, zend_type singl
static void register_unresolved_classes(zend_class_entry *scope, zend_type type) {
zend_type *single_type;
ZEND_TYPE_FOREACH(type, single_type) {
if (ZEND_TYPE_HAS_LIST(*single_type)) {
register_unresolved_classes(scope, *single_type);
continue;
}
if (ZEND_TYPE_HAS_NAME(*single_type)) {
zend_string *class_name = resolve_class_name(scope, ZEND_TYPE_NAME(*single_type));
lookup_class_ex(scope, class_name, /* register_unresolved */ true);
Expand Down