1--TEST--
2Lazy objects: resetAsLazy*() can reset initialized proxy
3--FILE--
4<?php
5
6class Obj {
7    public function __construct(
8        public string $name,
9    ) {}
10}
11
12$r = new ReflectionClass(Obj::class);
13
14$obj = new Obj('obj1');
15var_dump($obj);
16$r->resetAsLazyProxy($obj, function () {
17    return new Obj('obj2');
18});
19$r->initializeLazyObject($obj);
20var_dump($obj);
21$r->resetAsLazyProxy($obj, function () {
22    return new Obj('obj3');
23});
24var_dump($obj);
25$r->initializeLazyObject($obj);
26var_dump($obj);
27
28?>
29==DONE==
30--EXPECTF--
31object(Obj)#%d (1) {
32  ["name"]=>
33  string(4) "obj1"
34}
35lazy proxy object(Obj)#%d (1) {
36  ["instance"]=>
37  object(Obj)#%d (1) {
38    ["name"]=>
39    string(4) "obj2"
40  }
41}
42lazy proxy object(Obj)#%d (0) {
43  ["name"]=>
44  uninitialized(string)
45}
46lazy proxy object(Obj)#%d (1) {
47  ["instance"]=>
48  object(Obj)#%d (1) {
49    ["name"]=>
50    string(4) "obj3"
51  }
52}
53==DONE==
54