1--TEST--
2Serialization of readonly properties
3--FILE--
4<?php
5
6class Test {
7    public function __construct(
8        public readonly int $prop = 1,
9    ) {}
10}
11
12var_dump($s = serialize(new Test));
13var_dump(unserialize($s));
14
15// Readonly properties receive no special handling.
16// What happens during unserialization stays in unserialization.
17var_dump(unserialize("O:4:\"Test\":1:{s:4:\"prop\";i:2;}"));
18var_dump(unserialize("O:4:\"Test\":2:{s:4:\"prop\";i:2;s:4:\"prop\";i:3;}"));
19
20?>
21--EXPECT--
22string(30) "O:4:"Test":1:{s:4:"prop";i:1;}"
23object(Test)#1 (1) {
24  ["prop"]=>
25  int(1)
26}
27object(Test)#1 (1) {
28  ["prop"]=>
29  int(2)
30}
31object(Test)#1 (1) {
32  ["prop"]=>
33  int(3)
34}
35