1--TEST--
2Lazy objects: JIT: ASSIGN_OBJ_OP with dynamic prop
3--FILE--
4<?php
5
6#[AllowDynamicProperties]
7class C {
8    public int $b = 1;
9
10    public function __construct() {
11        var_dump(__METHOD__);
12        $this->a = 1;
13        $this->b = 3;
14    }
15}
16
17function test(string $name, object $obj) {
18    printf("# %s:\n", $name);
19
20    var_dump($obj);
21    $obj->a += 1;
22    var_dump($obj);
23}
24
25$reflector = new ReflectionClass(C::class);
26
27$obj = $reflector->newLazyGhost(function ($obj) {
28    var_dump("initializer");
29    $obj->__construct();
30});
31
32test('Ghost', $obj);
33
34$obj = $reflector->newLazyProxy(function ($obj) {
35    var_dump("initializer");
36    return new C();
37});
38
39test('Proxy', $obj);
40
41--EXPECTF--
42# Ghost:
43lazy ghost object(C)#%d (0) {
44  ["b"]=>
45  uninitialized(int)
46}
47string(11) "initializer"
48string(14) "C::__construct"
49object(C)#%d (2) {
50  ["b"]=>
51  int(1)
52  ["a"]=>
53  int(2)
54}
55# Proxy:
56lazy proxy object(C)#%d (0) {
57  ["b"]=>
58  uninitialized(int)
59}
60string(11) "initializer"
61string(14) "C::__construct"
62lazy proxy object(C)#%d (1) {
63  ["instance"]=>
64  object(C)#%d (2) {
65    ["b"]=>
66    int(3)
67    ["a"]=>
68    int(2)
69  }
70}
71