1--TEST--
2Lazy objects: skipLazyInitialization() marks property as non-lazy and sets default value if any
3--FILE--
4<?php
5
6class C {
7    public $a;
8    public $b = 1;
9    public $c;
10}
11
12function test(string $name, object $obj) {
13    printf("# %s\n", $name);
14
15    $reflector = new ReflectionClass(C::class);
16    $reflector->getProperty('a')->skipLazyInitialization($obj);
17    $reflector->getProperty('b')->skipLazyInitialization($obj);
18
19    var_dump($obj->a);
20    var_dump($obj->b);
21    var_dump(!$reflector->isUninitializedLazyObject($obj));
22    var_dump($obj);
23}
24
25$reflector = new ReflectionClass(C::class);
26$obj = $reflector->newLazyGhost(function () {
27    throw new \Exception('initializer');
28});
29
30test('Ghost', $obj);
31
32$obj = $reflector->newLazyProxy(function () {
33    throw new \Exception('initializer');
34});
35
36test('Proxy', $obj);
37
38?>
39--EXPECTF--
40# Ghost
41NULL
42int(1)
43bool(false)
44lazy ghost object(C)#%d (2) {
45  ["a"]=>
46  NULL
47  ["b"]=>
48  int(1)
49}
50# Proxy
51NULL
52int(1)
53bool(false)
54lazy proxy object(C)#%d (2) {
55  ["a"]=>
56  NULL
57  ["b"]=>
58  int(1)
59}
60