Skip to content

Commit 841757d

Browse files
committed
Register classes for intersection types
1 parent bfad213 commit 841757d

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

Zend/zend_inheritance.c

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -686,8 +686,26 @@ static inheritance_status zend_perform_covariant_type_check(
686686
}
687687

688688
/* Register all classes that may have to be resolved */
689-
if (ZEND_TYPE_IS_INTERSECTION(fe_type)) {
690-
// TODO Register intersection type classes
689+
if (UNEXPECTED(ZEND_TYPE_IS_INTERSECTION(fe_type))) {
690+
ZEND_TYPE_FOREACH(proto_type, single_type) {
691+
zend_string *proto_class_name;
692+
zend_class_entry *proto_ce = NULL;
693+
694+
if (ZEND_TYPE_HAS_NAME(*single_type)) {
695+
proto_class_name = resolve_class_name(proto_scope, ZEND_TYPE_NAME(*single_type));
696+
} else if (ZEND_TYPE_HAS_CE(*single_type)) {
697+
proto_ce = ZEND_TYPE_CE(*single_type);
698+
proto_class_name = proto_ce->name;
699+
} else {
700+
/* standard type */
701+
ZEND_ASSERT(0 && "This shouldn't happen yet");
702+
continue;
703+
}
704+
705+
zend_perform_intersection_covariant_class_type_check(proto_scope,
706+
proto_class_name, proto_ce, fe_scope, fe_type,
707+
/* register_unresolved */ true);
708+
} ZEND_TYPE_FOREACH_END();
691709
} else {
692710
ZEND_TYPE_FOREACH(fe_type, single_type) {
693711
zend_string *fe_class_name;

0 commit comments

Comments
 (0)