1.2.711. 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.711.1. Connex PHP features

1.2.711.1.1. Suggestions

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

1.2.711.1.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

Available in

Entreprise Edition, Exakat Cloud