Re: [RFC] Alternative typehinting syntax for accessors

From: Date: Sat, 05 Jan 2013 03:31:36 +0000
Subject: Re: [RFC] Alternative typehinting syntax for accessors
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-64539@lists.php.net to get a copy of this message
On 1/4/2013 4:29 PM, Stas Malyshev wrote:
Hi!
This shouldn't be an issue because it is not possible to set the property without going through the setter, which would be a type hinted accessor function.
It is possible, if this property's guard is set. Since guard works for all code called from inside the setter, if setter is doing something not trivial (meaning, calls any functions, explicitly or implicitly) it is possible to set the property directly. Since the value you are getting is defined by the getter, there are no guarantees there too. So effectively, unless both getter and setter are implicit, this does not give you anything compared to the typed setter. I think I was referring to the possibility I mentioned in another email about a second call to a getter which was already guarded would return NULL and likewise a second call to a setter which was already being guarded would do whatever __set() does...? Ignored?
-- -Clint

« previous php.internals (#64539) next »