Req #63954 [Opn]: Parser should recognize objects within parenthesis
| From: | aharvey@php.net | Date: | Thu, 10 Jan 2013 02:40:02 +0000 |
| Subject: | Req #63954 [Opn]: Parser should recognize objects within parenthesis | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-175918@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=63954&edit=1
ID: 63954
Updated by: aharvey@php.net
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