|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30533 Parentheses around returned object cause a parse error
Submitted: 2004-10-22 18:58 UTC Modified: 2004-10-22 19:14 UTC
From: tompaw at irc dot pl Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5CVS-2004-10-22 (dev) OS: Windows XP SP2 CORP ENU
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: tompaw at irc dot pl
New email:
PHP Version: OS:


 [2004-10-22 18:58 UTC] tompaw at irc dot pl
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";

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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-10-22 19:14 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Feb 21 10:01:28 2024 UTC