1--TEST--
2Lazy objects: resetAsLazyProxy() can reset initialized proxies
3--FILE--
4<?php
5
6class A {
7    public function __construct(
8        public $a,
9        public $proxy,
10    ) {}
11    public function __destruct() {
12        var_dump(__METHOD__);
13        var_dump($this);
14    }
15}
16
17$reflector = new ReflectionClass(A::class);
18
19$proxy = $reflector->newLazyProxy(function ($proxy) {
20    return new A(1, $proxy);
21});
22
23print "Init\n";
24
25$reflector->initializeLazyObject($proxy);
26
27var_dump($proxy);
28
29print "Reset\n";
30
31$proxy = $reflector->resetAsLazyProxy($proxy, function () {
32    return new A(2);
33});
34
35?>
36--EXPECTF--
37Init
38lazy proxy object(A)#%d (1) {
39  ["instance"]=>
40  object(A)#%d (2) {
41    ["a"]=>
42    int(1)
43    ["proxy"]=>
44    *RECURSION*
45  }
46}
47Reset
48string(13) "A::__destruct"
49object(A)#%d (2) {
50  ["a"]=>
51  int(1)
52  ["proxy"]=>
53  object(A)#%d (0) {
54  }
55}
56