Bug #67772 [Opn]: Member-Selection Operator Syntax

[email protected] Fri, 11 Nov 2016 21:50:10 GMT
Newsgroups php.standards
Message-ID <[email protected]>
Edit report at https://bugs.php.net/bug.php?id=67772&edit=1

 ID:                 67772
 Updated by:         [email protected]
 Reported by:        [email protected]
 Summary:            Member-Selection Operator Syntax
 Status:             Open
 Type:               Bug
 Package:            PHP Language Specification
 PHP Version:        PHP-5.6
 Block user comment: N
 Private report:     N

 New Comment:

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.


Previous Comments:
------------------------------------------------------------------------
[2015-06-28 21:12:15] [email protected]

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.

------------------------------------------------------------------------
[2014-08-05 16:52:27] [email protected]

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. 



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=67772&edit=1