Re: [VOTE] Property Accessors for 5.5

From: Date: Thu, 17 Jan 2013 22:24:35 +0000
Subject: Re: [VOTE] Property Accessors for 5.5
References: 1  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
On 1/17/13 1:20 PM, Clint Priest wrote:
I'm happy to say that Property Accessors is ready for a vote for inclusion in 5.5 release. Nikita and I (as well as Stas a bit) have all been working hard to make this happen for 5.5, voting and the specifications are here:
I'll say my peace on this. This is a very good implementation, and as long as authors use accessors that depend on a separate property for storage (like other langs require), everything will be straightforward. Otherwise, I fear they're in for some confusing behavior. Consider the code from the RFC: class TimePeriod {
    public $Hours {
        get { return $this->Hours ?: "not specified"; }
        set { $this->Hours = $value; }
    }
} $tp = new TimePeriod(); $tp->Hours; // "not specified" isset($tp->Hours); // true!? The auto implementation of isset compares $this->Hours to NULL, but since $this->Hours goes through the getter, it will return "not specified". So the property will always appear to be isset. * The guards seem spooky: A set of tokens ($this->prop) will have varying behavior (e.g. direct prop read vs. getter call) *depending on the call stack*. * Giving issetter/unsetter no direct access to the property limits functionality and leads to weirdness like the example above. Steve Clay -- http://www.mrclay.org/

Thread (51 messages)

« previous php.internals (#65017) next »