3v4l.org

run code in 500+ PHP versions simultaneously
<?php class Foo { public function __construct( public $callable = static function (): void {} { // <----- BRACES OVERFLOW 🙈 set($value) { if (!is_callable($value)) { throw new \InvalidArgumentException('This is not callable, bro.'); } $this->callable = $value; } } ) {} } $foo = new Foo(static function (): void { echo 'TEST'; }); ($foo->callable)(); $foo->callable = new \stdClass();
Output for 8.4.1
Fatal error: Constant expression contains invalid operations in /in/3inE8 on line 4
Process exited with code 255.
Output for 8.3.5 - 8.3.14
Parse error: syntax error, unexpected token "{", expecting ")" in /in/3inE8 on line 5
Process exited with code 255.

preferences:
40.64 ms | 497 KiB | 3 Q