1--TEST--
2Lazy objects: var_dump may not initialize object with __debugInfo() method
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    public function __debugInfo() {
13        return ['hello'];
14    }
15}
16
17function test(string $name, object $obj) {
18    $reflector = new ReflectionClass(C::class);
19
20    printf("# %s\n", $name);
21
22    var_dump($obj);
23    printf("Initialized:\n");
24    var_dump(!$reflector->isUninitializedLazyObject($obj));
25}
26
27$reflector = new ReflectionClass(C::class);
28
29$obj = $reflector->newLazyGhost(function ($obj) {
30    var_dump("initializer");
31    $obj->__construct();
32});
33
34test('Ghost', $obj);
35
36$obj = $reflector->newLazyProxy(function ($obj) {
37    var_dump("initializer");
38    return new C();
39});
40
41test('Proxy', $obj);
42
43--EXPECTF--
44# Ghost
45lazy ghost object(C)#%d (1) {
46  [0]=>
47  string(5) "hello"
48}
49Initialized:
50bool(false)
51# Proxy
52lazy proxy object(C)#%d (1) {
53  [0]=>
54  string(5) "hello"
55}
56Initialized:
57bool(false)
58