summaryrefslogtreecommitdiff
path: root/Zend/tests/closures/closure_from_callable_gc.phpt
blob: e326fc3b099ef9a26219d8c0067af655c13f713a (plain)
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
--TEST--
Closure::fromCallable() and GC
--FILE--
<?php

class Test {
    public function method() {}

    public function method2($y) {
        static $x;
        $x = $y;
    }
}

$fn = Closure::fromCallable([new Test, 'method2']);
$fn($fn);
unset($fn); // Still referenced from static var.
gc_collect_cycles();

$fn = Closure::fromCallable([new Test, 'method']);
$fn2 = $fn; unset($fn2); // Add to root buffer.
gc_collect_cycles();

?>
===DONE===
--EXPECT--
===DONE===