Misusing empty()

PHP developers like using empty() for boolean checks for just about everything. There are cases, though, where this can lead to confusion.

<?php
// PHP 5.0 or later: 
$array = [];
var_dump(empty($array)); 
// outputs bool(true)
$array = new ArrayObject();
var_dump(empty($array));
// outputs bool(false)
// why don't these both produce the same output?

class Magic {
    private $values = ['test' => 'value'];
    public function __get($key) {
        if (isset($this->values[$key])) {
            return $this->values[$key];
        }
    }
}

$regular = new Regular();
var_dump($regular->test);
// outputs string(4) "value" $magic = new Magic();
var_dump($magic->test);
// outputs string(4) "value" Fine so far.
?>

https://www.toptal.com/php/10-most-common-mistakes-php-programmers-make