xref: /php-src/Zend/tests/gc_050.phpt (revision a470110f)
1--TEST--
2GC 050: Destructor are never called twice
3--FILE--
4<?php
5
6class G
7{
8    public static $v;
9}
10
11class WithDestructor
12{
13    public function __destruct()
14    {
15        echo "d\n";
16
17        G::$v = $this;
18    }
19}
20
21$o = new WithDestructor();
22$weakO = \WeakReference::create($o);
23echo "---\n";
24unset($o);
25echo "---\n";
26var_dump($weakO->get() !== null); // verify if kept allocated
27G::$v = null;
28echo "---\n";
29var_dump($weakO->get() !== null); // verify if released
30?>
31--EXPECT--
32---
33d
34---
35bool(true)
36---
37bool(false)
38