xref: /PHP-5.6/Zend/tests/bug60139.phpt (revision fe802ac2)
1--TEST--
2Bug #60139 (Anonymous functions create cycles not detected by the GC)
3--INI--
4zend.enable_gc=1
5--FILE--
6<?php
7class Foo {
8    public $x;
9
10    public function __construct() {
11        $this->x = function() {};
12    }
13}
14
15class Bar {
16    public $x;
17
18    public function __construct() {
19        $self = $this;
20        $this->x = function() use ($self) {};
21    }
22}
23
24gc_collect_cycles();
25new Foo;
26var_dump(gc_collect_cycles());
27new Bar;
28var_dump(gc_collect_cycles());
29?>
30--EXPECT--
31int(2)
32int(2)
33