3v4l.org

run code in 300+ PHP versions simultaneously
<?php class SomeParent { public function __construct(private DateTime $d) { } } class SomeChild extends SomeParent { public function run() { return $this->d->format('Y-m-d'); } } $c = new SomeChild(new DateTime('now')); var_dump($c->run());
Output for 8.2.0, 8.3.5 - 8.3.29, 8.4.9 - 8.4.16, 8.5.0 - 8.5.1
Warning: Undefined property: SomeChild::$d in /in/onscb on line 14 Fatal error: Uncaught Error: Call to a member function format() on null in /in/onscb:14 Stack trace: #0 /in/onscb(19): SomeChild->run() #1 {main} thrown in /in/onscb on line 14
Process exited with code 255.

preferences:
68.07 ms | 406 KiB | 5 Q