From: kvr at centrum dot cz Operating system: Linux / KUbuntu PHP version: 5.4.18 Package: Scripting Engine problem Bug Type: Bug Bug description:Parenthesized expressions inconsistent
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 bug report at https://bugs.php.net/bug.php?id=65464&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=65464&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=65464&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=65464&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=65464&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=65464&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=65464&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=65464&r=needscript Try newer version: https://bugs.php.net/fix.php?id=65464&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=65464&r=support Expected behavior: https://bugs.php.net/fix.php?id=65464&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=65464&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=65464&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=65464&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=65464&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=65464&r=dst IIS Stability: https://bugs.php.net/fix.php?id=65464&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=65464&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=65464&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=65464&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=65464&r=mysqlcfg