xref: /PHP-8.2/Zend/tests/bug69212.phpt (revision f8d79582)
1--TEST--
2Bug #69212: Leaking VIA_HANDLER func when exception thrown in __call/... arg passing
3--FILE--
4<?php
5
6class Test {
7    public static function __callStatic($method, $args) {}
8    public function __call($method, $args) {}
9}
10
11function do_throw() { throw new Exception; }
12
13try {
14    Test::foo(do_throw());
15} catch (Exception $e) {
16    echo "Caught!\n";
17}
18try {
19    (new Test)->bar(do_throw());
20} catch (Exception $e) {
21    echo "Caught!\n";
22}
23
24try {
25    $f = function () {};
26    $f->__invoke(do_throw());
27} catch (Exception $e) {
28    echo "Caught!\n";
29}
30
31try {
32    $t = new Test;
33    $f->__invoke($t->bar(Test::foo(do_throw())));
34} catch (Exception $e) {
35    echo "Caught!\n";
36}
37
38?>
39--EXPECT--
40Caught!
41Caught!
42Caught!
43Caught!
44