From:             tompaw at irc dot pl
Operating system: Windows XP SP2 CORP ENU
PHP version:      5CVS-2004-10-22 (dev)
PHP Bug Type:     Class/Object related
Bug description:  Parentheses around returned object cause a parse error

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 bug report at http://bugs.php.net/?id=30533&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=30533&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=30533&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=30533&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=30533&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=30533&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=30533&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=30533&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=30533&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=30533&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=30533&r=notwrong
Not enough info:             http://bugs.php.net/fix.php?id=30533&r=notenoughinfo
Submitted twice:             http://bugs.php.net/fix.php?id=30533&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=30533&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=30533&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=30533&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=30533&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=30533&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=30533&r=float
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=30533&r=mysqlcfg

Reply via email to