Skip to content

Commit 3f3512b

Browse files
committed
test exception from destructor
1 parent fca2f52 commit 3f3512b

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

Zend/tests/gh7922.phpt

+50
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,44 @@ try {
2828
} catch (\Throwable $e) {
2929
echo (string) $e . "\n";
3030
}
31+
32+
try {
33+
$a = new class() extends A {
34+
public function __debugInfo(): array
35+
{
36+
new class() {
37+
public function __destruct()
38+
{
39+
throw new \Exception('z_wo_assign');
40+
}
41+
};
42+
43+
return ['foo' => 2];
44+
}
45+
};
46+
print_r($a);
47+
} catch (\Throwable $e) {
48+
echo (string) $e . "\n";
49+
}
50+
51+
try {
52+
$a = new class() extends A {
53+
public function __debugInfo(): array
54+
{
55+
$o = new class() {
56+
public function __destruct()
57+
{
58+
throw new \Exception('z_w_assign');
59+
}
60+
};
61+
62+
return ['foo' => 2];
63+
}
64+
};
65+
print_r($a);
66+
} catch (\Throwable $e) {
67+
echo (string) $e . "\n";
68+
}
3169
?>
3270
--EXPECTF--
3371
Error: x in %s:6
@@ -41,3 +79,15 @@ Stack trace:
4179
#0 [internal function]: A@anonymous->__debugInfo()
4280
#1 %s(24): print_r(Object(A@anonymous), true)
4381
#2 {main}
82+
83+
Exception: z_wo_assign in %s:35
84+
Stack trace:
85+
#0 [internal function]: A@anonymous->__destruct()
86+
#1 %s(42): print_r(Object(A@anonymous))
87+
#2 {main}
88+
89+
Exception: z_w_assign in %s:54
90+
Stack trace:
91+
#0 [internal function]: A@anonymous->__destruct()
92+
#1 %s(61): print_r(Object(A@anonymous))
93+
#2 {main}

0 commit comments

Comments
 (0)