1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
--TEST--
Verifies that generated lazy loading ghost objects can skip calling the proxied destructor
--FILE--
<?php
require_once __DIR__ . '/init.php';
#[AllowDynamicProperties]
class Destructable
{
public function __destruct()
{
echo __FUNCTION__;
}
}
$factory = new \ProxyManager\Factory\LazyLoadingGhostFactory($configuration);
$init = function ($object, $method, $parameters, & $initializer) {
echo 'init';
$initializer = null;
};
$proxy = $factory->createProxy(Destructable::class, $init, ['skipDestructor' => true]);
echo "NO __destruct\n";
unset($proxy);
$proxy = $factory->createProxy(Destructable::class, $init, ['skipDestructor' => true]);
echo 'DO ';
$proxy->triggerInit = true;
unset($proxy);
$proxy = $factory->createProxy(Destructable::class, $init);
echo "\nDO ";
unset($proxy);
?>
--EXPECT--
NO __destruct
DO init__destruct
DO __destruct
|