try_finally_023.phpt 587 B

12345678910111213141516171819202122232425262728293031323334353637
  1. --TEST--
  2. Loop var dtor throwing exception during return inside try/catch inside finally
  3. --FILE--
  4. <?php
  5. class Dtor {
  6. public function __destruct() {
  7. throw new Exception(2);
  8. }
  9. }
  10. function test() {
  11. try {
  12. throw new Exception(1);
  13. } finally {
  14. try {
  15. foreach ([new Dtor] as $v) {
  16. unset($v);
  17. return 42;
  18. }
  19. } catch (Exception $e) {
  20. }
  21. }
  22. }
  23. try {
  24. test();
  25. } catch (Exception $e) {
  26. echo $e, "\n";
  27. }
  28. ?>
  29. --EXPECTF--
  30. Exception: 1 in %s:%d
  31. Stack trace:
  32. #0 %s(%d): test()
  33. #1 {main}