Re: Multiple Visibility Level Getters/Setters
| From: | Keloran | Date: | Sat, 19 Nov 2011 21:12:19 +0000 |
| Subject: | Re: Multiple Visibility Level Getters/Setters | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-56435@lists.php.net to get a copy of this message | ||
personally i think only public should be done with this method
all others should be follow the __set/__get method, since if you need
special rules, then they would be set-able by a public method
On Sat, Nov 19, 2011 at 7:45 PM, Lars Strojny <lars@strojny.net> wrote:
> Just throw an error if conflicting accessors are defined. In the case of
> subtypes: accessors may broaden the interface, but not limit it => LSP. So
> it’s fine to make a parents protected accessor public, but not the other
> way around.
>
> Am 19.11.2011 um 02:46 schrieb Clint M Priest:
>
> > What would everyone think about multiple levels of visibility for
> getters/setters?
> >
> > class Sample {
> >
> > public $Variable {
> > public get { return "Public"; }
> > protected get { return "Protected"; }
> > private get { return "Private"; }
> >
> > public set { ... }
> > private set { ... }
> > }
> > }
> >
> > Whichever getter/setter would be called with the most restricted access,
> so externally public, internally protected (if inherited) or private from
> within.
> >
> > Any value to this? I can see some use cases and wouldn't be any more
> difficult to implement into what I'm already doing.
> >
> > -Clint
>
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>