<?php
class Test {
public function callback() {}
}
class Test2 {
public function set(callable $callback) {}
}
$callback = 'Test::callback';
var_dump(is_callable($callback));
$a = new Test2();
$a->set($callback);
?>
bool(false)
Fatal error: Uncaught TypeError: Test2::set(): Argument #1 ($callback) must be of type callable, string given, called in /in/ilbYM on line 14 and defined in /in/ilbYM:6
Stack trace:
#0 /in/ilbYM(14): Test2->set('Test::callback')
#1 {main}
thrown in /in/ilbYM on line 6
Process exited with code 255.
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
bool(false)
Fatal error: Uncaught TypeError: Test2::set(): Argument #1 ($callback) must be of type callable, string given, called in /in/ilbYM on line 14 and defined in /in/ilbYM:6
Stack trace:
#0 /in/ilbYM(14): Test2->set('Test::callback')
#1 {main}
thrown in /in/ilbYM on line 6
Process exited with code 255.