Skip to content

Commit

Permalink
Fix callable variance check (GH-17613)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
iluuu1994 authored Jan 28, 2025
1 parent 98da67a commit ed1e47e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
19 changes: 19 additions & 0 deletions Zend/tests/type_declarations/callable/callable_004.phpt
Original file line number Diff line number Diff line change
@@ -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===
2 changes: 0 additions & 2 deletions Zend/zend_inheritance.c
Original file line number Diff line number Diff line change
Expand Up @@ -499,8 +499,6 @@ static inheritance_status zend_is_class_subtype_of_type(
} else if (fe_ce == zend_ce_closure) {
track_class_dependency(fe_ce, fe_class_name);
return INHERITANCE_SUCCESS;
} else {
return INHERITANCE_ERROR;
}
}

Expand Down

0 comments on commit ed1e47e

Please sign in to comment.