1--TEST--
2GH-15823: Wrong expectations in zend_lazy_object_get_properties()
3--FILE--
4<?php
5
6class C {
7    public int $a = 1;
8}
9
10$reflector = new ReflectionClass(C::class);
11$calls = 0;
12$obj = $reflector->newLazyGhost(function ($obj) use (&$calls) {
13    if ($calls++ === 0) {
14        throw new Error("initializer");
15    }
16    $obj->a = 2;
17});
18
19// Builds properties ht without lazy initialization
20var_dump($obj);
21try {
22    // Lazy initialization fails during fetching of properties ht
23    json_encode($obj);
24} catch (Error $e) {
25    printf("%s: %s\n", $e::class, $e->getMessage());
26}
27
28var_dump(json_encode($obj));
29
30?>
31--EXPECTF--
32lazy ghost object(C)#%d (0) {
33  ["a"]=>
34  uninitialized(int)
35}
36Error: initializer
37string(7) "{"a":2}"
38