1--TEST--
2Static variable assign triggering destructor
3--FILE--
4<?php
5
6class Foo {
7    public function __destruct() {
8        throw new Exception('__destruct() called');
9    }
10}
11
12function bar() {
13    echo "bar() called\n";
14    return 42;
15}
16
17function foo(bool $throw) {
18    if ($throw) {
19        $a = new Foo();
20    }
21    static $a = bar();
22    var_dump($a);
23}
24
25try {
26    foo(true);
27} catch (Exception $e) {
28    echo $e->getMessage(), "\n";
29}
30foo(false);
31
32?>
33--EXPECT--
34bar() called
35__destruct() called
36int(42)
37