Fix callable variance check (GH-17613)

Caused by GH-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.
This commit is contained in:
Ilija Tovilo 2025-01-28 16:45:36 +01:00 committed by GitHub
parent 98da67aa9a
commit ed1e47e325
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 2 deletions

View file

@ -0,0 +1,19 @@
--TEST--
callable type#004
--FILE--
<?php
interface Foo {}
class P {
public function test(Foo|callable $foo) {}
}
class C extends P {
public function test(Foo|callable $foo) {}
}
?>
===DONE===
--EXPECT--
===DONE===

View file

@ -499,8 +499,6 @@ static inheritance_status zend_is_class_subtype_of_type(
} else if (fe_ce == zend_ce_closure) { } else if (fe_ce == zend_ce_closure) {
track_class_dependency(fe_ce, fe_class_name); track_class_dependency(fe_ce, fe_class_name);
return INHERITANCE_SUCCESS; return INHERITANCE_SUCCESS;
} else {
return INHERITANCE_ERROR;
} }
} }