summaryrefslogtreecommitdiff
path: root/Zend/tests/closures/closure_from_callable_gc.phpt
diff options
context:
space:
mode:
Diffstat (limited to 'Zend/tests/closures/closure_from_callable_gc.phpt')
-rw-r--r--Zend/tests/closures/closure_from_callable_gc.phpt27
1 files changed, 27 insertions, 0 deletions
diff --git a/Zend/tests/closures/closure_from_callable_gc.phpt b/Zend/tests/closures/closure_from_callable_gc.phpt
new file mode 100644
index 0000000000..e326fc3b09
--- /dev/null
+++ b/Zend/tests/closures/closure_from_callable_gc.phpt
@@ -0,0 +1,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===