<?php
class A { function __destruct() { echo "a dtor\n"; $GLOBALS['b']->doSomething(); } }
class B { function __destruct() { echo "b dtor\n"; } function doSomething() { echo "b still alive\n"; } }
$a = new A;
$b = new B;
b dtor
a dtor
Warning: Undefined global variable $b in /in/6stii on line 2
Fatal error: Uncaught Error: Call to a member function doSomething() on null in /in/6stii:2
Stack trace:
#0 [internal function]: A->__destruct()
#1 {main}
thrown in /in/6stii on line 2
Process exited with code 255.
Output for 8.0.0 - 8.0.30
b dtor
a dtor
Warning: Undefined array key "b" in /in/6stii on line 2
Fatal error: Uncaught Error: Call to a member function doSomething() on null in /in/6stii:2
Stack trace:
#0 [internal function]: A->__destruct()
#1 {main}
thrown in /in/6stii on line 2
Process exited with code 255.
b dtor
a dtor
Notice: Undefined index: b in /in/6stii on line 2
Fatal error: Uncaught Error: Call to a member function doSomething() on null in /in/6stii:2
Stack trace:
#0 [internal function]: A->__destruct()
#1 {main}
thrown in /in/6stii on line 2
Process exited with code 255.
Output for 7.3.32 - 7.3.33
b dtor
a dtor
Fatal error: Uncaught Error: Call to a member function doSomething() on null in /in/6stii:2
Stack trace:
#0 [internal function]: A->__destruct()
#1 {main}
thrown in /in/6stii on line 2
Process exited with code 255.
Output for 5.6.0 - 5.6.28
b dtor
a dtor
Notice: Undefined index: b in /in/6stii on line 2
Fatal error: Call to a member function doSomething() on null in /in/6stii on line 2
Process exited with code 255.
b dtor
a dtor
Notice: Undefined index: b in /in/6stii on line 2
Fatal error: Call to a member function doSomething() on a non-object in /in/6stii on line 2
Process exited with code 255.
Output for 5.4.0 - 5.4.6
b dtor
a dtor
Notice: Undefined index: b in /in/6stii on line 2
Fatal error: Call to a member function doSomething() on a non-object in /in/6stii on line 2
Output for 5.2.0 - 5.2.17
b dtor
a dtor
Notice: Undefined index: b in /in/6stii on line 2
Fatal error: Call to a member function doSomething() on a non-object in /in/6stii on line 2
Process exited with code 255.