Sherif,

Don't get me wrong, I liked it, but I also disliked the fact that it
> introduces language changes that aren't easy to grasp or document. To me
> this means we've borderline changed the behavior of a property (which most
> PHP users currently understand to be a variable) into potential methods.
> This is basically saying we can now completely change the behavior of a
> property from a storage unit to a functional unit. That's a bit of a scary
> thought to me, because it makes me question everything I know about
> properties in PHP.
>

Except that everything that's proposed here is possible today with __get,
__set, __isset and __unset. So already today you can't assume that a
property is a "variable". In fact, you could build something like this
using __get, etc extremely dirty:

class Foo {
    public function __get($name) {
        $method = 'get' . ucfirst($name);
        if (method_exists($this, $method)) {
            return $this->method();
        }
        return $this->$name; // public properties
    }
    public function __set($name, $value) {
        $method = 'set' . ucfirst($name);
        if (method_exists($this, $method)) {
            return $this->method($value);
        }
        return $this->$name = $value; // public properties
    }
}

The difference in functionality that this provides is the ability to
custom-scope getters and setters. And it's a LOT cleaner...

Anthony

Reply via email to