3v4l.org

run code in 300+ PHP versions simultaneously
<?php class TestClass { public function __destruct() { App::$flg = true; } } class App { public static $flg = false; public static function main() { $methods = array_filter( (new \ReflectionClass(__CLASS__))->getMethods(), function (\ReflectionMethod $r) { return preg_match('/^test/', $r->getName()); } ); array_walk($methods, function (\ReflectionMethod $r) { $r->invoke(null, null); }); } public static function testArray() { self::$flg = false; call_user_func(function () { $aa = new TestClass(); $bb = array($aa); $aa->bb = $bb; }); gc_collect_cycles(); printf("%s: %s\n", __FUNCTION__, var_export(self::$flg, true)); } public static function testObject() { self::$flg = false; call_user_func(function () { $aa = new TestClass(); $bb = new \stdClass(); $bb->aa = $aa; $aa->bb = $bb; }); gc_collect_cycles(); printf("%s: %s\n", __FUNCTION__, var_export(self::$flg, true)); } public static function testSplFixedArray() { self::$flg = false; call_user_func(function () { $aa = new TestClass(); $bb = new \SplFixedArray(1); $bb[0] = $aa; $aa->bb = $bb; }); gc_collect_cycles(); printf("%s: %s\n", __FUNCTION__, var_export(self::$flg, true)); } public static function testSplObjectStorage() { self::$flg = false; call_user_func(function () { $aa = new TestClass(); $bb = new \SplObjectStorage(); $bb->attach($aa); $aa->bb = $bb; }); gc_collect_cycles(); printf("%s: %s\n", __FUNCTION__, var_export(self::$flg, true)); } public static function testArrayObject() { self::$flg = false; call_user_func(function () { $aa = new TestClass(); $bb = new \ArrayObject([$aa]); $aa->bb = $bb; }); gc_collect_cycles(); printf("%s: %s\n", __FUNCTION__, var_export(self::$flg, true)); } public static function testSplDoublyLinkedList() { self::$flg = false; call_user_func(function () { $aa = new TestClass(); $bb = new \SplDoublyLinkedList(); $bb->push($aa); $aa->bb = $bb; }); gc_collect_cycles(); printf("%s: %s\n", __FUNCTION__, var_export(self::$flg, true)); } public static function testSplMaxHeap() { self::$flg = false; call_user_func(function () { $aa = new TestClass(); $bb = new \SplMaxHeap(); $bb->insert($aa); $aa->bb = $bb; }); gc_collect_cycles(); printf("%s: %s\n", __FUNCTION__, var_export(self::$flg, true)); } public static function testSplPriorityQueue() { self::$flg = false; call_user_func(function () { $aa = new TestClass(); $bb = new \SplPriorityQueue(); $bb->insert($aa, 1); $aa->bb = $bb; }); gc_collect_cycles(); printf("%s: %s\n", __FUNCTION__, var_export(self::$flg, true)); } } App::main();
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Creation of dynamic property TestClass::$bb is deprecated in /in/hW7s7 on line 35 testArray: true Deprecated: Creation of dynamic property TestClass::$bb is deprecated in /in/hW7s7 on line 50 testObject: true Deprecated: Creation of dynamic property TestClass::$bb is deprecated in /in/hW7s7 on line 65 testSplFixedArray: true Deprecated: Creation of dynamic property TestClass::$bb is deprecated in /in/hW7s7 on line 80 testSplObjectStorage: true Deprecated: Creation of dynamic property TestClass::$bb is deprecated in /in/hW7s7 on line 94 testArrayObject: true Deprecated: Creation of dynamic property TestClass::$bb is deprecated in /in/hW7s7 on line 109 testSplDoublyLinkedList: true Deprecated: Creation of dynamic property TestClass::$bb is deprecated in /in/hW7s7 on line 124 testSplMaxHeap: true Deprecated: Creation of dynamic property TestClass::$bb is deprecated in /in/hW7s7 on line 139 testSplPriorityQueue: true

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
43.65 ms | 403 KiB | 8 Q