Edit report at https://bugs.php.net/bug.php?id=63954&edit=1
ID: 63954 Updated by: [email protected] Reported by: php at kfee-programming dot com Summary: Parser should recognize objects within parenthesis Status: Open Type: Feature/Change Request -Package: Compile Failure +Package: Scripting Engine problem Operating System: Debian GNU/Linux 6.0 PHP Version: 5.3.20 Block user comment: N Private report: N New Comment: There are probably two separate issues here: (clone $foo)->bar() should probably work since (new $foo)->bar() does, then there's the bigger issue of objects being treated more consistently as the result of parenthesised expressions. Previous Comments: ------------------------------------------------------------------------ [2013-01-10 01:22:07] php at kfee-programming dot com Description: ------------ Placing any object within parentheses and attempting to access members of that object causes the parser to fail with an error. This makes chaining difficult, particularly with clones. One would expect that parenthesis should have no effect on the identity of the variable or expression they are surrounding, but this failure of the parser causes a change in identity to not-an-object. This was reported as a bug #30533, but was declared NAB with no additional reasoning. This is thus a change request. Test script: --------------- <?php $Now = new \DateTime(); $OneSecAgo = (clone $Now)->sub(new \DateInterval("PT1S")); //Or $OneSecAgo = clone($Now)->sub(new \DateInterval("PT1S")); //Neither work. echo $Now->format("c") , "\n" , $OneSecAgo->format("c"); Expected result: ---------------- 2013-01-09T17:01:35-08:00 2013-01-09T17:01:34-08:00 Actual result: -------------- [Wed Jan 09 17:01:35 2013] [error] [client *.*.*.*] PHP Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /var/www/test.php on line 3 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=63954&edit=1
