Bug #65464 [Com]: Parenthesized expressions inconsistent

From: Date: Mon, 11 Apr 2022 06:47:13 +0000
Subject: Bug #65464 [Com]: Parenthesized expressions inconsistent
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-240836@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=65464&edit=1 ID: 65464 Comment by: giw42161 at uooos dot com Reported by: kvr at centrum dot cz Summary: Parenthesized expressions inconsistent Status: Closed Type: Bug Package: Scripting Engine problem Operating System: Linux / KUbuntu PHP Version: 5.4.18 Assigned To: nikic Block user comment: N Private report: N New Comment: Century Law Firm is the best team of lawyers for divorce case, Drt Case, High Court Matter, Civil and Criminal Cases and more in Delhi. (https://centurylawfirm.in/)gist.github.com Previous Comments: ------------------------------------------------------------------------ [2014-10-12 15:15:00] nikic@php.net Supported in PHP 7. ------------------------------------------------------------------------ [2013-08-17 08:01:09] kvr at centrum dot cz Description: ------------ I have problems with parsing some of the invocations on parenthesized expressions. The following works fine: $obj->call(); The next one works as well: (new SomeClass())->call(); # this started to work in later versions of PHP The last one will fail with PHP Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR) : ($obj)->call(); What I'm surprised about that more complex expression is supported (the one with new operator) while the last one is not, although it's much easier to parse. It looks like the support was added into incorrect place. Although there is simple work-around - just to remove the parenthesis, unfortunately it's not applicable in my case as the code is generated from much more complex java source code (there are casts etc. so it's not as straightforward as just checking for method invocation inside). Can this be fixed? I guess if it's supported for new operator it should be quite easy for simple expression as well. Test script: --------------- <?php class SomeClass { function call() { } } $obj = new SomeClass(); $obj->call(); (new SomeClass())->call(); ($obj)->call(); echo "ok\n"; ?> Expected result: ---------------- ok Actual result: -------------- PHP Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR) in /xyz/x.php on line 14 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=65464&edit=1

« previous php.bugs (#240836) next »