xref: /PHP-8.4/Zend/tests/lazy_objects/gc_006.phpt (revision 58aa6fc8)
1--TEST--
2Lazy objects: GC 006
3--FILE--
4<?php
5
6class Foo {
7    public $foo;
8}
9
10class Initializer {
11    public function __invoke($obj) {
12        $obj->foo = $this;
13        var_dump(__METHOD__);
14    }
15    public function __destruct() {
16        var_dump(__METHOD__);
17    }
18}
19
20$reflector = new ReflectionClass(Foo::class);
21$foo = $reflector->newLazyGhost(new Initializer());
22
23print "Dump\n";
24
25var_dump($foo->foo);
26
27print "Done\n";
28
29?>
30--EXPECTF--
31Dump
32string(21) "Initializer::__invoke"
33object(Initializer)#%d (0) {
34}
35Done
36string(23) "Initializer::__destruct"
37