It was pretty obvious that we need callable prototypes, but somehow it was declined (?!?).
So, eventually our team members agreed on that callables won't be used ever and "callable" interfaces will be created and required instead. Later, as PHP evolved, the anonymous classes where introduced which made our code much more readable.
Code: Select all
interface ITimerCallback {
public function onTick(ITimer $timer);
}
interface ITimer {
public function tick(ITimerCallback $handler);
}
...
$this->tick(new class implements ITimerCallback {
public function onTick(ITimer $timer) {
echo $timer->getTime();
}
});