xref: /PHP-8.2/Zend/tests/bug52361.phpt (revision f8d79582)
1--TEST--
2Bug #52361 (Throwing an exception in a destructor causes invalid catching)
3--FILE--
4<?php
5class aaa {
6    public function __destruct() {
7        try {
8            throw new Exception(__CLASS__);
9        } catch(Exception $ex) {
10            echo "1. $ex\n";
11        }
12    }
13}
14function bbb() {
15    $a = new aaa();
16    throw new Exception(__FUNCTION__);
17}
18try {
19    bbb();
20    echo "must be skipped !!!";
21} catch(Exception $ex) {
22    echo "2. $ex\n";
23}
24?>
25--EXPECTF--
261. Exception: aaa in %sbug52361.php:5
27Stack trace:
28#0 %sbug52361.php(16): aaa->__destruct()
29#1 {main}
302. Exception: bbb in %sbug52361.php:13
31Stack trace:
32#0 %sbug52361.php(16): bbb()
33#1 {main}
34