NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Tag @property and private properties


Joined: 03 Jul 2009
Posts: 5
Reply with quote
Code completion is not working for class tag @property, when property with same name exists as private.

This works fine:


But now property $test is missing in code completion:
View user's profileFind all posts by elemSend private message
Guru master

Joined: 05 Jul 2004
Posts: 659
Location: Belgium
Reply with quote
IMHO its not really good coding practice to name an member variable the same as a property.
I would find it utterly confusing anyway... which of both you are using in the class itself? Logically the private member, but what if you wanted the other?

The parser handles the case correctly anyway: Actual code should always have precedence above comments.
View user's profileFind all posts by BlizzSend private messageVisit poster's website


Joined: 03 Jul 2009
Posts: 5
Reply with quote
Blizz wrote:
IMHO its not really good coding practice to name an member variable the same as a property.

What is exactly bad on this? because I see only trouble with for example protected member with name $_test…

Blizz wrote:
I would find it utterly confusing anyway... which of both you are using in the class itself? Logically the private member, but what if you wanted the other?

There is no other property, they are the same, $test is private because I need to control what value can be write to this member from outside world, so magic __get and __set is used.

Blizz wrote:
The parser handles the case correctly anyway: Actual code should always have precedence above comments.

I think parser is wrong, because he just overwrite my property with private member, that's bug, because in PHP is possible to do this (private property can exists simultaneously with the same named public property, because of magic method __get).

edit: I tried Netbeans and Zend Studio. Their behaviour is as I expected, doesn't matter if there is private property or not…
View user's profileFind all posts by elemSend private message
Tag @property and private properties
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic