xref: /PHP-8.0/Zend/tests/try/catch_novar_2.phpt (revision 23ee4d4b)
1--TEST--
2catch without capturing a variable - exception in destructor
3--FILE--
4<?php
5class ThrowsOnDestruct extends Exception {
6    public function __destruct() {
7        echo "Throwing\n";
8        throw new RuntimeException(__METHOD__);
9    }
10}
11try {
12    throw new ThrowsOnDestruct();
13} catch (Exception) {
14    echo "Unreachable catch\n";
15}
16echo "Unreachable fallthrough\n";
17
18?>
19--EXPECTF--
20Throwing
21
22Fatal error: Uncaught RuntimeException: ThrowsOnDestruct::__destruct in %s:%d
23Stack trace:
24#0 %s(%d): ThrowsOnDestruct->__destruct()
25#1 {main}
26  thrown in %s on line %d
27