php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67772 Member-Selection Operator Syntax
Submitted: 2014-08-05 16:52 UTC Modified: 2016-11-11 21:50 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: joelm@php.net Assigned:
Status: Open Package: PHP Language Specification
PHP Version: PHP-5.6 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
45 + 7 = ?
Subscribe to this entry?

 
 [2014-08-05 16:52 UTC] joelm@php.net
Description:
------------
https://github.com/php/php-langspec/blob/master/spec/10-expressions.md#member-selection-operator

The specified syntax is wrong. PHP does not allow arbitrary expressions to follow the "->" token, if the programmer wants to use an expression (aside from a bare local variable) they have to wrap it in curly braces. This section makes it sound like instance properties and methods both live in the same namespace (which is wrong, they have distinct namespaces and you can have a method and an instance property with the same name). Also, the description of the member-selection operator is not precise enough to allow the reader to distinguish between an arrow-style method call expression and an instance property access, which is key to describing how a parsed expression involving the -> operator is interpreted by the engine. Finally, this section doesn't describe how arrow-style method lookup or instance property lookup works. For example if there is a private property named 'x' and a public property named 'x' in the inheritance hierarchy, how do we decide which one gets accessed? Same goes for methods. 


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-06-28 21:12 UTC] stas@php.net
I agree that description of the expressions following -> are not complete, though I am not sure how to write a proper grammar there. Contributions are welcome there.

I do not think the description though implies anywhere that properties and methods share the same namespace. I don't see anything written there that can give such impression. 

I also don't think this is the right place to describe private/protected semantics and inheritance - this should be done in 14-classes where visibility and inheritance is discussed. Of course, contributions there are welcome too.
 [2015-06-28 21:39 UTC] stas@php.net
-PHP Version: Irrelevant +PHP Version: PHP-5.6
 [2016-11-11 21:50 UTC] nikic@php.net
Now at: https://github.com/php/php-langspec/blob/master/spec/10-expressions.md#member-access-operator

The syntax specification should be accurate. However the actual property / method lookup is still underspecified.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 22:01:28 2024 UTC