<?php
class Example
{
public function match(callable $cb)
{
echo $cb();
}
}
class Callee
{
public function yo()
{
return "If I show up, I'm allowed to do this!";
}
}
$ex = new Example();
$callee = new Callee();
$cases = [
[],
[$callee, 'yo'],
];
$ex->match($cases[0]);
$ex->match($cases[1]);
Fatal error: Uncaught TypeError: Example::match(): Argument #1 ($cb) must be of type callable, array given, called in /in/44CkT on line 25 and defined in /in/44CkT:5
Stack trace:
#0 /in/44CkT(25): Example->match(Array)
#1 {main}
thrown in /in/44CkT on line 5
Process exited with code 255.
Fatal error: Uncaught TypeError: Argument 1 passed to Example::match() must be callable, array given, called in /in/44CkT on line 25 and defined in /in/44CkT:5
Stack trace:
#0 /in/44CkT(25): Example->match(Array)
#1 {main}
thrown in /in/44CkT on line 5
Process exited with code 255.
Catchable fatal error: Argument 1 passed to Example::match() must be callable, array given, called in /in/44CkT on line 25 and defined in /in/44CkT on line 5
Process exited with code 255.