3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types = 1); final class Deprecated { public function __construct( public readonly string $reason, public readonly string $date, ) { } /** * @return array<int, mixed> */ public function __serialize() : array { return [ $this->reason, $this->date, ]; } /** * @param array<int, mixed> $data */ public function __unserialize(array $data) : void { [ $this->reason, $this->date, ] = $data; } } var_dump(unserialize(serialize(new Deprecated('test', 'test'))));
Output for 8.1.1
object(Deprecated)#1 (2) { ["reason"]=> string(4) "test" ["date"]=> string(4) "test" }

preferences:
155.54 ms | 1398 KiB | 8 Q