3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace test; use \Closure; class MyClass { protected Closure $modifier; public function __construct(callable $modifier) { $this->modifier = Closure::fromCallable($modifier); } } class SomeOtherClass { public static function func() { return ['a' => 'b']; } } // this will work fine $a = new MyClass(['\test\SomeOtherClass', 'func']); var_dump($a); // this will cause error $b = new MyClass(['SomeOtherClass', 'func']);

preferences:
33.83 ms | 404 KiB | 5 Q