|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2014-10-12 15:15 UTC] nikic@php.net
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: nikic
[2014-10-12 15:15 UTC] nikic@php.net
[2022-04-11 06:47 UTC] giw42161 at uooos dot com
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 15:00:01 2025 UTC |
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