3v4l.org

run code in 500+ PHP versions simultaneously
<?php declare(strict_types=1); class ParentClass { public function __set(string $name, mixed $value) { echo "__set($name) was called\n"; } } class ChildClass extends ParentClass { public $foo { set => parent::$foo::set(); } } $parent = new ParentClass; $parent->foo = "bar"; $child = new ChildClass; $child->foo = "baz";
Output for 8.4.3
__set(foo) was called Fatal error: Uncaught Error: Undefined property ParentClass::$foo in /in/Q2OAj:13 Stack trace: #0 /in/Q2OAj(21): ChildClass->$foo::set('baz') #1 {main} thrown in /in/Q2OAj on line 13
Process exited with code 255.
Output for 8.3.5
Parse error: syntax error, unexpected token "{", expecting "," or ";" in /in/Q2OAj on line 12
Process exited with code 255.

preferences:
47.77 ms | 484 KiB | 3 Q