1--TEST--
2Lazy objects: destructor of lazy objets is not called if not initialized
3--FILE--
4<?php
5
6class C {
7    public $a;
8    public function __destruct() {
9        var_dump(__METHOD__);
10    }
11}
12
13$reflector = new ReflectionClass(C::class);
14
15print "# Ghost:\n";
16
17print "In newLazyGhost\n";
18$obj = $reflector->newLazyGhost(function () {
19    var_dump("initializer");
20});
21print "After newLazyGhost\n";
22
23// Does not call destructor
24$obj = null;
25
26print "# Proxy:\n";
27
28print "In newLazyProxy\n";
29$obj = $reflector->newLazyProxy(function () {
30    var_dump("initializer");
31});
32print "After newLazyGhost\n";
33
34// Does not call destructor
35$obj = null;
36
37--EXPECT--
38# Ghost:
39In newLazyGhost
40After newLazyGhost
41# Proxy:
42In newLazyProxy
43After newLazyGhost
44