1--TEST--
2Lazy objects: Object is still lazy after initializer exception (overridden prop)
3--FILE--
4<?php
5
6class B {
7    public int $b = 1;
8}
9class C extends B {
10    public $a = 1;
11    public int $b = 2;
12}
13
14function test(string $name, object $obj) {
15    $reflector = new ReflectionClass(C::class);
16
17    printf("# %s:\n", $name);
18
19    $reflector->getProperty('b')->skipLazyInitialization($obj);
20    $i = 5;
21    $obj->b = &$i;
22
23    try {
24        $reflector->initializeLazyObject($obj);
25    } catch (Exception $e) {
26        printf("%s\n", $e->getMessage());
27    }
28
29    printf("Is lazy: %d\n", $reflector->isUninitializedLazyObject($obj));
30}
31
32$reflector = new ReflectionClass(C::class);
33
34$obj = $reflector->newLazyGhost(function ($obj) {
35    var_dump("initializer");
36    $obj->a = 3;
37    $obj->b = 4;
38    throw new Exception('initializer exception');
39});
40
41test('Ghost', $obj);
42
43$obj = $reflector->newLazyProxy(function ($obj) {
44    var_dump("initializer");
45    $obj->a = 3;
46    $obj->b = 4;
47    throw new Exception('initializer exception');
48});
49
50test('Proxy', $obj);
51
52--EXPECT--
53# Ghost:
54string(11) "initializer"
55initializer exception
56Is lazy: 1
57# Proxy:
58string(11) "initializer"
59initializer exception
60Is lazy: 1
61