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:

> https://wiki.php.net/rfc/propertygetsetsyntax-v1.2#voting

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/

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to