1--TEST--
2Lazy objects: getLazyInitializer() returns initializer
3--FILE--
4<?php
5
6class C {
7    public $a;
8
9    public static function initStatic() {}
10    public function init() {}
11}
12
13function foo() {
14}
15
16$reflector = new ReflectionClass(C::class);
17
18$initializers = [
19    'foo',
20    foo(...),
21    function () {},
22    [C::class, 'initStatic'],
23    [new C(), 'init'],
24    C::initStatic(...),
25    (new C())->init(...),
26];
27
28foreach ($initializers as $i => $initializer) {
29    $c = $reflector->newLazyGhost($initializer);
30    if ($reflector->getLazyInitializer($c) !== $initializer) {
31        printf("Initializer %d: failed\n", $i);
32        continue;
33    }
34
35    $reflector->initializeLazyObject($c);
36    if ($reflector->getLazyInitializer($c) !== null) {
37        printf("Initializer %d: failed\n", $i);
38        continue;
39    }
40
41    printf("Initializer %d: ok\n", $i);
42}
43
44?>
45--EXPECT--
46Initializer 0: ok
47Initializer 1: ok
48Initializer 2: ok
49Initializer 3: ok
50Initializer 4: ok
51Initializer 5: ok
52Initializer 6: ok
53