xref: /PHP-7.0/Zend/tests/bug20240.phpt (revision db76b708)
1--TEST--
2Bug #20240 (order of destructor calls)
3--SKIPIF--
4<?php if (version_compare(zend_version(), '2.0.0-dev', '<')) die('skip ZendEngine 2 is needed'); ?>
5--FILE--
6<?php
7
8class test
9{
10    public $member;
11
12    function __construct() {
13        $this->member = 1;
14        register_shutdown_function(array($this, 'destructor'));
15    }
16
17    function destructor() {
18        print __METHOD__ . "\n";
19    }
20
21    function __destruct() {
22        print __METHOD__ . "\n";
23    }
24
25    function add() {
26        $this->member += 1;
27        print $this->member."\n";
28    }
29}
30
31$t = new test();
32
33$t->add();
34$t->add();
35
36echo "Done\n";
37?>
38--EXPECT--
392
403
41Done
42test::destructor
43test::__destruct
44