Quote from the PHP documentation on overloading:
It is not possible to use overloaded properties in other language constructs than isset(). This means if empty() is called on an overloaded property, the overloaded method is not called.
To workaround that limitation, the overloaded property must be copied into a local variable in the scope and then be handed to empty().
Does this really mean that I cannot use something like
if (empty($this->foobar))
in a class, where $this->foobar is a magic property, resolved through __get(), or am I misunderstanding something here?
It will work if you override the
__issetmethod as well. The reason the documentation is written as such is because you can’t callempty() or isset()on the result of a method call.