3v4l.org

run code in 300+ PHP versions simultaneously
<?php enum Status: int { case New = 0; case Pending = 1; } abstract class HistoryRecord { public readonly Status $status; } class NewHistoryRecord extends HistoryRecord { public function __construct( public readonly Status $status = Status::New, ) {} } $nhr = new NewHistoryRecord(); var_dump($nhr);
Output for 8.1.0 - 8.1.34, 8.2.22 - 8.2.30, 8.3.5 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
object(NewHistoryRecord)#1 (1) { ["status"]=> enum(Status::New) }
Output for 8.0.1 - 8.0.19
Parse error: syntax error, unexpected identifier "Status" in /in/ZGgNc on line 3
Process exited with code 255.
Output for 7.4.0 - 7.4.29
Parse error: syntax error, unexpected 'Status' (T_STRING) in /in/ZGgNc on line 3
Process exited with code 255.

preferences:
62.8 ms | 955 KiB | 4 Q