2016-05-26 7:00 GMT+02:00 Stanislav Malyshev <smalys...@gmail.com>:

> Hi!
>
> > Also, property access never was safe. Consider:
> >
> > $obj = new class {
> >     public $foo;
> >     function __construct() {
> >         unset($this->foo);
> >     }
> >     function __get($prop) {
> >         throw new Exception("No $prop for you today!");
> >     }
> > };
> > var_dump($obj->foo); // exception.
>
> This is different. Your code throws exception purposefully so you intend
> something to break here - you might as well just written exit(1) and
> said there's no safe code at all since you could exit at any moment.
> That's not what I mean. I mean that operation that was previously not
> prone to fatal errors just because of variable holding some value would
> now produce such errors - not because the user wrote code to
> specifically do that but because of hidden properties of the engine. If
> the engine would by itself insert such code as above into user classes
> that would be dangerous too but of course it does not.
>
> >
> > isset() checks will continue to work.
>
> For some definition of "work" - since it would return false for null
> values, but null values are actually OK.


If there's a function to check it, how would you handle it? It's clearly a
programming mistake.

> It's just about getting a *value*. (and to check whether it's a typed
> property, there's Reflection support in the RFC.)
>
> You don't propose using Reflection before each variable access I
> presume. Reflection is useless in runtime scenario.
>
> --
> Stas Malyshev
> smalys...@gmail.com
>

Reply via email to