Skip to content

Commit 4ec78c1

Browse files
committed
allow to override static return types with self in final classes
1 parent 79e4f25 commit 4ec78c1

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Zend/zend_inheritance.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,13 @@ ZEND_API inheritance_status zend_perform_covariant_type_check(
684684
added_types &= ~MAY_BE_STATIC;
685685
}
686686

687+
if (proto_type_mask & MAY_BE_STATIC && fe_type_mask | MAY_BE_STATIC &&
688+
fe_scope->ce_flags & ZEND_ACC_FINAL &&
689+
zend_is_intersection_subtype_of_type(fe_scope, fe_type, proto_scope, proto_type) == INHERITANCE_SUCCESS) {
690+
/* Replacing type that accepts static with self in final classes is okay */
691+
return INHERITANCE_SUCCESS
692+
}
693+
687694
if (added_types == MAY_BE_NEVER) {
688695
/* never is the bottom type */
689696
return INHERITANCE_SUCCESS;

0 commit comments

Comments
 (0)