iterator_068.phpt 613 B

1234567891011121314151617181920212223242526272829303132
  1. --TEST--
  2. SPL: Iterator: Overloaded object and destruction
  3. --FILE--
  4. <?php
  5. class Test implements Iterator {
  6. function foo() {
  7. echo __METHOD__ . "()\n";
  8. }
  9. function rewind(): void {}
  10. function valid(): bool {}
  11. function current(): mixed {}
  12. function key(): mixed {}
  13. function next(): void {}
  14. }
  15. class TestIteratorIterator extends IteratorIterator {
  16. function __destruct() {
  17. echo __METHOD__ . "()\n";
  18. $this->foo();
  19. }
  20. }
  21. $obj = new TestIteratorIterator(new Test);
  22. $obj->foo();
  23. unset($obj);
  24. ?>
  25. --EXPECT--
  26. Test::foo()
  27. TestIteratorIterator::__destruct()
  28. Test::foo()