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