From:             [EMAIL PROTECTED]
Operating system: All
PHP version:      4.2.1
PHP Bug Type:     Scripting Engine problem
Bug description:  Static vars can't store ref to new instance

ola,

we've recently put in a set of methods in the binarycloud 
core classes so they can enforce their singleton status.

An example:

    // {{{ method GetInstance()

    /**
     * This method enforces this class's singleton
     * status. It check s astatic var for an instance,
     * if that instance exists a reference to it
     * is returned. If it does not exist it is created
     * and a reference is returned.
         * @author hans lellelid, [EMAIL PROTECTED]
            * @access public
     */
    function &GetInstance() {
                    static $instance;
                if(!isset($instance)) {
                        $instance = new Request();
                }        
      return $instance;
    }

    // }}}

note the line:

$instance = new Request();

that means the instance is always overwritten.

we have to do that because:

$instance =& new Request();

results in a null $instance.

We believe this is a bug, but it's on the edge of possible 
expected behavior.

thanks,

_alex


-- 
Edit bug report at http://bugs.php.net/?id=20175&edit=1
-- 
Try a CVS snapshot:         http://bugs.php.net/fix.php?id=20175&r=trysnapshot
Fixed in CVS:               http://bugs.php.net/fix.php?id=20175&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=20175&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=20175&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=20175&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=20175&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=20175&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=20175&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=20175&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=20175&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=20175&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=20175&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=20175&r=isapi

Reply via email to