VladSun wrote:
It was pretty obvious that we need
callable prototypes, but somehow it was declined (?!?).
PHP discusses everything publicly on their internals mailing list. Whenever you want to know what's going on, reading an archive of the emails is a great place to start.
AFAIK callable_types was supported in concept but had issues. Such as how it would be allowable to craft incredibly complex function signatures
function foo(int $a, int $b, callable(callable(callable(callable(int, int):int $zebranky, int):int $pik, int):int $fot, int):int $zot): int {
return $zot($a, $b);
}
And that default values in the signature would not be allowed
function foo(callable(int = 123) $fn) {
And that it could create problems with strict_types and parameter variance.
In the rest of the OOP world, your problem is solved by interfaces or strict typing.