xref: /PHP-8.2/Zend/tests/bug20240.phpt (revision a8d901a8)
1--TEST--
2Bug #20240 (order of destructor calls)
3--FILE--
4<?php
5
6class test
7{
8    public $member;
9
10    function __construct() {
11        $this->member = 1;
12        register_shutdown_function(array($this, 'destructor'));
13    }
14
15    function destructor() {
16        print __METHOD__ . "\n";
17    }
18
19    function __destruct() {
20        print __METHOD__ . "\n";
21    }
22
23    function add() {
24        $this->member += 1;
25        print $this->member."\n";
26    }
27}
28
29$t = new test();
30
31$t->add();
32$t->add();
33
34echo "Done\n";
35?>
36--EXPECT--
372
383
39Done
40test::destructor
41test::__destruct
42