php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #46668 Changing static class operator to "->"
Submitted: 2008-11-25 17:09 UTC Modified: 2008-11-25 17:41 UTC
From: nightstorm at tlen dot pl Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 6CVS-2008-11-25 (CVS) OS:
Private report: No CVE-ID: None
 [2008-11-25 17:09 UTC] nightstorm at tlen dot pl
Description:
------------
Hi everyone,

I've recently read about some controversies concerning the new namespace operator and I noticed a possible solution which I want to share with you. Unfortunately, it breaks the backward compatibility.

The idea is to use "->" both for normal object and static class element access, as id does not introduce any ambiguity and can be resolved directly by the lexical parser:

$variable->field    - object call
$variable->method() - object call
ClassName->field    - static call
ClassName->method() - static call
ClassName->method()->method2()->field - first one is static, the rest are object calls.

Now "::" can be used as the namespace access operator. I use the same rules in my template engine to convert the object calls to the PHP syntax and I'm pretty sure they are correct.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-11-25 17:41 UTC] scottmac@php.net
You'd break all previously written PHP code if :: suddenly became a namespace separator.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Apr 29 10:01:30 2024 UTC