xref: /PHP-8.0/Zend/tests/bug29368_1.phpt (revision afd3e39d)
1--TEST--
2Bug #29368.1 (The destructor is called when an exception is thrown from the constructor).
3--FILE--
4<?php
5function throwme($arg)
6{
7    throw new Exception;
8}
9
10class foo {
11  function __construct() {
12    echo "Inside constructor\n";
13    throwme($this);
14  }
15
16  function __destruct() {
17    echo "Inside destructor\n";
18  }
19}
20
21try {
22  $bar = new foo;
23} catch(Exception $exc) {
24  echo "Caught exception!\n";
25}
26?>
27--EXPECT--
28Inside constructor
29Caught exception!
30