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