From:
Operating system: *
PHP version: Irrelevant
Package: Class/Object related
Bug Type: Bug
Bug description:After destructor execution, object exists
Description:
------------
I think, in this example after destructor executing, object shouldn`t
exist. But result of this code tells something else...
Test script:
---------------
<?php
class A {
protected $var;
private static $instance = NULL;
public static function getInstance() {
if (is_null(self::$instance))
self::$instance = new A();
return self::$instance;
}
protected function __construct() {
echo "creating instance of A\n";
$this->var = "existing var in instance of A \n";
}
public function show() {
echo $this->var;
}
public function __destruct() {
echo "deleting instance of A\n";
}
}
class B {
private static $instance = NULL;
public static function getInstance() {
if (is_null(self::$instance))
self::$instance = new B();
return self::$instance;
}
protected function __construct() {
echo "creating instance of B\n";
}
public function __destruct() {
A::getInstance()->show();
echo "deleting instance of B\n";
}
}
header('Content-type: text/plain');
A::getInstance()->show();
B::getInstance();
?>
Expected result:
----------------
Some error?
Actual result:
--------------
creating instance of A
existing var in instance of A
creating instance of B
deleting instance of A
existing var in instance of A
deleting instance of B
--
Edit bug report at http://bugs.php.net/bug.php?id=53699&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=53699&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=53699&r=trysnapshot53
Try a snapshot (trunk):
http://bugs.php.net/fix.php?id=53699&r=trysnapshottrunk
Fixed in SVN:
http://bugs.php.net/fix.php?id=53699&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=53699&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=53699&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=53699&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=53699&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=53699&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=53699&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=53699&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=53699&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=53699&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=53699&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=53699&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=53699&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=53699&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=53699&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=53699&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=53699&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=53699&r=mysqlcfg