3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test { public function __construct(callable $foo) { // $this->cb is callable here var_dump(is_callable($foo)); } private function method() {} } $cb = [Test::class, 'method']; $obj = new Test($cb); // $obj->cb is NOT callable here var_dump(is_callable($cb));
Output for 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
bool(true) bool(false)

preferences:
63.37 ms | 406 KiB | 5 Q