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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: nightstorm at tlen dot pl
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Mon Jul 14 18:01:33 2025 UTC