xref: /PHP-8.2/Zend/tests/try/catch_003.phpt (revision f8d79582)
1--TEST--
2Catching an exception in a constructor fired form a static method
3--FILE--
4<?php
5
6class MyObject
7{
8    function fail()
9    {
10        throw new Exception();
11    }
12
13    function __construct()
14    {
15        self::fail();
16        echo __METHOD__ . "() Must not be reached\n";
17    }
18
19    function __destruct()
20    {
21        echo __METHOD__ . "() Must not be called\n";
22    }
23}
24
25try
26{
27    new MyObject();
28}
29catch(Exception $e)
30{
31    echo "Caught\n";
32}
33
34?>
35--EXPECT--
36Caught
37