mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
37 lines
555 B
PHP
37 lines
555 B
PHP
--TEST--
|
|
Lazy objects: GC 006
|
|
--FILE--
|
|
<?php
|
|
|
|
class Foo {
|
|
public $foo;
|
|
}
|
|
|
|
class Initializer {
|
|
public function __invoke($obj) {
|
|
$obj->foo = $this;
|
|
var_dump(__METHOD__);
|
|
}
|
|
public function __destruct() {
|
|
var_dump(__METHOD__);
|
|
}
|
|
}
|
|
|
|
$reflector = new ReflectionClass(Foo::class);
|
|
$foo = $reflector->newLazyGhost(new Initializer());
|
|
|
|
print "Dump\n";
|
|
|
|
var_dump($foo->foo);
|
|
|
|
print "Done\n";
|
|
|
|
?>
|
|
--EXPECTF--
|
|
Dump
|
|
string(21) "Initializer::__invoke"
|
|
object(Initializer)#%d (0) {
|
|
}
|
|
Done
|
|
string(23) "Initializer::__destruct"
|