ID:               30447
 User updated by:  arend at auton dot nl
 Reported By:      arend at auton dot nl
-Status:           Bogus
+Status:           Open
 Bug Type:         Zend Engine 2 problem
 Operating System: Linux
 PHP Version:      5.0.2
 New Comment:

I didn't complain about $this not being available, but about a global
reference to the class not being available. This global  reference *is*
available when the variable runs out of scope, but it's not available
when explicitly deleted using unset(). This way, the current behavior
is simply not consistent. To fix this, it would be best if the global
reference was kept intact until *after* the destructor has finished.


Previous Comments:
------------------------------------------------------------------------

[2005-01-13 01:20:49] [EMAIL PROTECTED]

No bug here:

"Because static methods are callable without an instance of the object
created, the pseudo variable $this is not available inside the method
declared as static."
http://php.net/manual/en/language.oop5.static.php

------------------------------------------------------------------------

[2004-10-15 16:11:47] arend at auton dot nl

Description:
------------
If you use singleton classes, it is often handy to have one global
instance of your class and manipulate this instance using static
functions. Then it can also be handy to call such a static function for
cleanup purposes inside the destructor. However, if the object is
cleaned up using unset(), the static functions lose access to the
global instance before the destructor is finished. If the instance just
runs out of scope, it works normally however.

Btw, this bug seems somewhat similar to Bug #29685 in which it also
appears the destructor is called too late with a singleton pattern,
with the exception that this code does not have a private instance and
simply uses a global instance.

Reproduce code:
---------------
class Test
{
        public function __construct() { $this->a = "test"; }
        public function __destruct() { self::printA(); }

        static public function printA() { global $test; echo
"$test->a\n"; }

        private $a;
}

$test = new Test;
unset($test);

Expected result:
----------------
It should print: "test".

Actual result:
--------------
It prints nothing.


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=30447&edit=1

Reply via email to