bug53071.phpt 508 B

123456789101112131415161718192021222324252627
  1. --TEST--
  2. Bug #53071 (Usage of SPLObjectStorage defeats gc_collect_cycles)
  3. --FILE--
  4. <?php
  5. gc_enable();
  6. class myClass
  7. {
  8. public $member;
  9. }
  10. function LimitedScope()
  11. {
  12. $myA = new myClass();
  13. $myB = new SplObjectStorage();
  14. $myC = new myClass();
  15. $myC->member = $myA; // myC has a reference to myA
  16. $myB->Attach($myC); // myB attaches myC
  17. $myA->member = $myB; // myA has myB, comleting the cycle
  18. }
  19. LimitedScope();
  20. var_dump(gc_collect_cycles());
  21. echo "Done.\n";
  22. ?>
  23. --EXPECT--
  24. int(3)
  25. Done.