<?php
class Foo {
public function bar(Bar $bar) {
$bar->baz([$this, 'baz']);
}
protected function baz() {
print 'Foobar!'.PHP_EOL;
}
}
class Bar {
public function baz(callable $baz) {
$baz();
}
}
$foo = new Foo;
$bar = new Bar;
$foo->bar($bar);
Fatal error: Uncaught TypeError: Bar::baz(): Argument #1 ($baz) must be of type callable, array given, called in /in/Gf0ul on line 4 and defined in /in/Gf0ul:13
Stack trace:
#0 /in/Gf0ul(4): Bar->baz(Array)
#1 /in/Gf0ul(21): Foo->bar(Object(Bar))
#2 {main}
thrown in /in/Gf0ul on line 13
Process exited with code 255.
Fatal error: Uncaught TypeError: Argument 1 passed to Bar::baz() must be callable, array given, called in /in/Gf0ul on line 4 and defined in /in/Gf0ul:13
Stack trace:
#0 /in/Gf0ul(4): Bar->baz(Array)
#1 /in/Gf0ul(21): Foo->bar(Object(Bar))
#2 {main}
thrown in /in/Gf0ul on line 13
Process exited with code 255.
Catchable fatal error: Argument 1 passed to Bar::baz() must be callable, array given, called in /in/Gf0ul on line 4 and defined in /in/Gf0ul on line 13
Process exited with code 255.