I use magical methods in my PHP classes but when i try to put them private, I’m warned :
WARN: The magic method __get() must have public visibility and cannot
be static in …
I wouldn’t like to have these methods in Eclipse auto completion. (maybe a way with phpdoc ?)
So my question is, why must these methods be public ?
Because you are invoking the methods from a scope outside of the class.
For example:
The above code is “converted” to:
Later when you get the property value like:
This code is “converted” to:
In each case the magic method,
__getand__set, are being invoked from outside the class so those methods will need to bepublic.