Skip to content

Commit e720740

Browse files
committed
W.I.P. Require full compatibility check for inner intersection type
Only for the time being to resolve the Inheritance cache issue as in theory we do not need to resolve everything
1 parent c5dfe64 commit e720740

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

Zend/tests/type_declarations/dnf_types/variance/valid8.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ class Test2 extends Test {
1616

1717
?>
1818
===DONE===
19-
--EXPECT--
20-
===DONE===
19+
--EXPECTF--
20+
Fatal error: Could not check compatibility between Test2::method1(): (X&Traversable)|string and Test::method1(): Traversable|array|string, because class X is not available in %s

Zend/zend_inheritance.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,7 @@ static inheritance_status zend_is_intersection_subtype_of_class(
402402
ZEND_ASSERT(ZEND_TYPE_IS_INTERSECTION(fe_type));
403403
bool have_unresolved = false;
404404
zend_type *single_type;
405+
inheritance_status status = INHERITANCE_ERROR;
405406

406407
/* Traverse the list of child types and check that at least one is
407408
* a subtype of the parent type being checked */
@@ -412,7 +413,7 @@ static inheritance_status zend_is_intersection_subtype_of_class(
412413
fe_class_name =
413414
resolve_class_name(fe_scope, ZEND_TYPE_NAME(*single_type));
414415
if (zend_string_equals_ci(fe_class_name, proto_class_name)) {
415-
return INHERITANCE_SUCCESS;
416+
status = INHERITANCE_SUCCESS;
416417
}
417418

418419
if (!proto_ce) proto_ce = lookup_class(proto_scope, proto_class_name);
@@ -431,11 +432,11 @@ static inheritance_status zend_is_intersection_subtype_of_class(
431432
if (unlinked_instanceof(fe_ce, proto_ce)) {
432433
track_class_dependency(fe_ce, fe_class_name);
433434
track_class_dependency(proto_ce, proto_class_name);
434-
return INHERITANCE_SUCCESS;
435+
status = INHERITANCE_SUCCESS;
435436
}
436437
} ZEND_TYPE_FOREACH_END();
437438

438-
return have_unresolved ? INHERITANCE_UNRESOLVED : INHERITANCE_ERROR;
439+
return have_unresolved ? INHERITANCE_UNRESOLVED : status;
439440
}
440441

441442
/* Check whether a single class proto type is a subtype of a potentially complex fe_type. */

0 commit comments

Comments
 (0)