1--TEST--
2Lazy objects: get_mangled_object_vars does not initialize object
3--FILE--
4<?php
5
6class C {
7    public int $a;
8    public function __construct() {
9        var_dump(__METHOD__);
10        $this->a = 1;
11    }
12}
13
14function test(string $name, object $obj) {
15    printf("# %s:\n", $name);
16
17    var_dump(get_mangled_object_vars($obj));
18
19    $obj->a = 2;
20    var_dump(get_mangled_object_vars($obj));
21}
22
23$reflector = new ReflectionClass(C::class);
24
25$obj = $reflector->newLazyGhost(function ($obj) {
26    var_dump("initializer");
27    $obj->__construct();
28});
29
30test('Ghost', $obj);
31
32$obj = $reflector->newLazyProxy(function ($obj) {
33    var_dump("initializer");
34    return new C();
35});
36
37test('Proxy', $obj);
38--EXPECTF--
39# Ghost:
40array(0) {
41}
42string(11) "initializer"
43string(14) "C::__construct"
44array(1) {
45  ["a"]=>
46  int(2)
47}
48# Proxy:
49array(0) {
50}
51string(11) "initializer"
52string(14) "C::__construct"
53array(1) {
54  ["a"]=>
55  int(2)
56}
57