Re: RFC: C-sharp style property get/set syntax for PHP
| From: | Richard Quadling | Date: | Wed, 01 Dec 2010 12:40:03 +0000 |
| Subject: | Re: RFC: C-sharp style property get/set syntax for PHP | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-50773@lists.php.net to get a copy of this message | ||
On 1 December 2010 12:30, Stas Malyshev <smalyshev@sugarcrm.com> wrote:
> Hi!
>
>> No. The prototype of all setters would be the same. As would the
>> prototype of all getters.
>
> But we'd have two sets of properties - one handled by __get/__isset, another
> - by get($isset). Not a good idea.
So, should properties isset/unset go via the magic methods?
With properties, there would be the duplication anyway (__get()/get()
and __set()/set()).
Either way, only the property knows what should happen when an isset()
or unset() is called against it. It is for that reason that I think
the property should handle it.
__get, __set, __isset and __unset are for undefined class members. Not
properties. From the user of the class, completely invisible.
Having more than 1 way to skin the cat is pretty much de rigueur for PHP.
--
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY