1.2.707. Missing __isset() Method

When using empty() on magic properties, the magic method __isset() must be implemented.

<?php

class foo {
    function __get($name) { return 'foo'; }
    // No __isset method
}

// Return TRUE, until __isset() exists
var_dump(
   empty((new foo)->bar);
);

?>

See also When empty is not empty.

1.2.707.1. Suggestions

  • Implement __isset() method when using empty on magic properties

1.2.707.2. Specs

Short name

Php/MissingMagicIsset

Rulesets

All, Analyze, Changed Behavior, Class Review

Exakat since

2.2.0

PHP Version

All

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

Medium

Features

magic-method, isset

Available in

Entreprise Edition, Exakat Cloud