using empty on inaccessible object with __isset and __get
- by David
<?php
class Magic_Methods
{
    protected $meta;
    public function __construct() 
    {
        $this->meta = (object) array(
            'test' => 1
        );
    }
    public function __isset($name) 
    {
        echo "pass isset {$name} \n";
        return isset($this->$name);
    }
    public function __get($name) 
    {
        echo "pass get {$name} \n";
        return $this->$name;
    }
}
$mm = new Magic_Methods();
$meta = empty($mm->meta->notExisting);
var_dump($meta);
echo "||\n";
$meta = empty($mm->meta);
var_dump($meta);
The snippet above does not work as expected for me. Why would the first empty() ommit the __isset? I get this:
pass get meta 
bool(true)
||
pass isset meta 
pass get meta 
bool(false)
I would expected identical results or another pass at the __isset, but not a direct call to __get. Or am I missing something here?