ID:               30533
 Updated by:       [EMAIL PROTECTED]
 Reported By:      tompaw at irc dot pl
-Status:           Open
+Status:           Bogus
 Bug Type:         Class/Object related
 Operating System: Windows XP SP2 CORP ENU
 PHP Version:      5CVS-2004-10-22 (dev)
 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

,


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

[2004-10-22 18:58:09] tompaw at irc dot pl

Description:
------------
I use Singleton classes in my code. In each of them there must be a
function that returns the instance of the object of that class (or
creates that object before). The problem occurs, when I try to put that
method insinde parentheses, like (MobilDB::GI())->test(); in the
following example. Please notice, that MobilDB::GI()->test(); works
perfectly, so the problem seems to be related to the parentheses around
MobilDB::GI().

Reproduce code:
---------------
class MobilDB {
        private static $instance = null;
        private function __construct() {
                echo "const";
        }
        public static function GI() {
                if (self::$instance == null) {
                        self::$instance = new MobilDB;
                }
                return self::$instance;
        }
        function test() {
                echo "test";
        }
}
(MobilDB::GI())->test();

Expected result:
----------------
I expected the constructor from the MobilDB class to be run (as this is
the first instance of GI() function and appropriate object must be
created) and then the test() method  from the same class to be run.

The expected output was "consttest".

Actual result:
--------------
Parse error: parse error, unexpected T_OBJECT_OPERATOR in
D:\www\mobil\m.php on line 8


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


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

Reply via email to