gc_029.phpt 604 B

1234567891011121314151617181920212223242526272829303132333435
  1. --TEST--
  2. GC 029: GC and destructors
  3. --INI--
  4. zend.enable_gc=1
  5. --FILE--
  6. <?php
  7. class Foo {
  8. public $bar;
  9. public $x = array(1,2,3);
  10. function __destruct() {
  11. if ($this->bar !== null) {
  12. $this->x = null;
  13. unset($this->bar);
  14. }
  15. }
  16. }
  17. class Bar {
  18. public $foo;
  19. function __destruct() {
  20. if ($this->foo !== null) {
  21. unset($this->foo);
  22. }
  23. }
  24. }
  25. $foo = new Foo();
  26. $bar = new Bar();
  27. $foo->bar = $bar;
  28. $bar->foo = $foo;
  29. unset($foo);
  30. unset($bar);
  31. var_dump(gc_collect_cycles());
  32. ?>
  33. --EXPECT--
  34. int(1)