1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00
Files
archived-php-src/Zend/tests/try/try_finally_020.phpt
2020-02-03 22:52:20 +01:00

43 lines
776 B
PHP

--TEST--
Combination of foreach, finally and exception (call order)
--FILE--
<?php
class A {
public $n = 0;
function __construct($n) {
$this->n = $n;
}
function __destruct() {
echo "destruct" . $this->n . "\n";
}
}
foreach ([new A(1)] as $a) {
$a = null;
try {
foreach ([new A(2)] as $a) {
$a = null;
try {
foreach ([new A(3)] as $a) {
$a = null;
throw new Exception();
}
} finally {
echo "finally1\n";
}
}
} catch (Exception $e) {
echo "catch\n";
} finally {
echo "finally2\n";
}
}
?>
--EXPECT--
destruct3
finally1
destruct2
catch
finally2
destruct1