Skip to content

Commit d52d68b

Browse files
committed
Fix callable variance check
Caused by phpGH-15492. While the parent might contain callable, it may also contain other types. zend_is_class_subtype_of_type() may be checking a member that is not callable itself. Fall back to the normal class subtype check. Discovered by a failing Laravel test in nightly.
1 parent 98da67a commit d52d68b

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--TEST--
2+
callable type#003
3+
--FILE--
4+
<?php
5+
6+
interface Foo {}
7+
8+
class P {
9+
public function test(Foo|callable $foo) {}
10+
}
11+
12+
class C extends P {
13+
public function test(Foo|callable $foo) {}
14+
}
15+
16+
?>
17+
===DONE===
18+
--EXPECT--
19+
===DONE===

Zend/zend_inheritance.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,8 +499,6 @@ static inheritance_status zend_is_class_subtype_of_type(
499499
} else if (fe_ce == zend_ce_closure) {
500500
track_class_dependency(fe_ce, fe_class_name);
501501
return INHERITANCE_SUCCESS;
502-
} else {
503-
return INHERITANCE_ERROR;
504502
}
505503
}
506504

0 commit comments

Comments
 (0)