gc_029.phpt 629 B

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