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