<?php
class Foo {
public $foo;
public function __wakeup() {
echo 'In foo', PHP_EOL, PHP_EOL;
$this->foo = null;
}
public function __destruct() {
echo 'Destruct foo', PHP_EOL, PHP_EOL;
}
}
class Bar {
public $bar;
public function __wakeup() {
echo 'In bar', PHP_EOL, PHP_EOL;
$this->bar = null;
}
public function __destruct() {
echo 'Destruct bar', PHP_EOL, PHP_EOL;
throw new \Exception('x');
}
}
$f = new Foo;
$b = new Bar;
$f->foo = $b;
$b->bar = $f;
try {
var_dump(unserialize(serialize([$f])));
} catch (\Throwable $e) {
echo $e, PHP_EOL, PHP_EOL;
}
echo "==========", PHP_EOL, PHP_EOL;
try {
var_dump(unserialize(serialize([$f, $b])));
} catch (\Throwable $e) {
echo $e, PHP_EOL, PHP_EOL;
}
echo "==========", PHP_EOL, PHP_EOL;
try {
var_dump(unserialize(serialize([$b, $f])));
} catch (\Throwable $e) {
echo $e, PHP_EOL, PHP_EOL;
}
echo "==========", PHP_EOL, PHP_EOL;
preferences:
50.22 ms | 402 KiB | 5 Q