1--TEST--
2ZE2 accessing globals from destructor in shutdown
3--FILE--
4<?php
5$test_cnt = 0;
6$test_num = 0;
7
8function Show() {
9  global $test_cnt;
10  echo "Count: $test_cnt\n";
11}
12
13class counter {
14  protected $id;
15
16  public function __construct() {
17    global $test_cnt, $test_num;
18    $test_cnt++;
19    $this->id = $test_num++;
20  }
21
22  public function Show() {
23    echo 'Id: '.$this->id."\n";
24  }
25
26  // try protected here
27  public function __destruct() {
28    global $test_cnt;
29    $test_cnt--;
30  }
31
32  static public function destroy(&$obj) {
33    $obj = NULL;
34    }
35}
36Show();
37$obj1 = new counter;
38$obj1->Show();
39Show();
40$obj2 = new counter;
41$obj2->Show();
42Show();
43counter::destroy($obj1);
44Show();
45// or uncomment this line and it works
46//counter::destroy($obj2);
47echo "Done\n";
48?>
49--EXPECT--
50Count: 0
51Id: 0
52Count: 1
53Id: 1
54Count: 2
55Count: 1
56Done
57