Skip to content

Commit 2ea822d

Browse files
committed
Register classes for intersection types
1 parent 81e68c1 commit 2ea822d

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
@@ -650,8 +650,26 @@ static inheritance_status zend_perform_covariant_type_check(
650650
}
651651

652652
/* Register all classes that may have to be resolved */
653-
if (ZEND_TYPE_IS_INTERSECTION(fe_type)) {
654-
// TODO Register intersection type classes
653+
if (UNEXPECTED(ZEND_TYPE_IS_INTERSECTION(fe_type))) {
654+
ZEND_TYPE_FOREACH(proto_type, single_type) {
655+
zend_string *proto_class_name;
656+
zend_class_entry *proto_ce = NULL;
657+
658+
if (ZEND_TYPE_HAS_NAME(*single_type)) {
659+
proto_class_name = resolve_class_name(proto_scope, ZEND_TYPE_NAME(*single_type));
660+
} else if (ZEND_TYPE_HAS_CE(*single_type)) {
661+
proto_ce = ZEND_TYPE_CE(*single_type);
662+
proto_class_name = proto_ce->name;
663+
} else {
664+
/* standard type */
665+
ZEND_ASSERT(0 && "This shouldn't happen yet");
666+
continue;
667+
}
668+
669+
zend_perform_intersection_covariant_class_type_check(proto_scope,
670+
proto_class_name, proto_ce, fe_scope, fe_type,
671+
/* register_unresolved */ true);
672+
} ZEND_TYPE_FOREACH_END();
655673
} else {
656674
ZEND_TYPE_FOREACH(fe_type, single_type) {
657675
zend_string *fe_class_name;

0 commit comments

Comments
 (0)