On 7 March 2013 09:45, Sebastian Krebs <krebs....@gmail.com> wrote:

>
> So I guess this is the only useful behaviour. However, I have no idea, what
> this information should tell me. If I call unset() then I want to ensure,
> that the variable is not set anymore, but for what reason I should need to
> know, whether it was set before, or not?
>

I think I actually had an use case with proxies, where I wanted to know if
a property was set or not. That's useful to reset the proxy state
(basically to intercept property access) and differentiate null properties
vs non existing properties:

    class Blah extends Blubb
    {
        protected $prop;
        public function __construct() { unset($this->prop); }
        public function init() { $this->prop = 'stuff'; }
        public function reset() { return unset($this->prop); } // we now
know if `init` was called
    }

This *could* be useful if I want to keep track of the state of a proxy, but
it's just an additional property to keep track of manually on the other
side. The additional property is also more explicit and easier to track.

Yes, it needs a better use case.

Marco Pivetta

http://twitter.com/Ocramius

http://ocramius.github.com/

Reply via email to