MissingIssetImplementation
error on by defaultGroup: Probable bugs · PhpStorm name: MissingIssetImplementationInspection
isset($obj->name) / empty($obj->name) on a property the class does not declare can only answer correctly if the class implements __isset(). When it does not (typically classes with __get only), the check is always false/empty, which is a silent logic bug.
Example
php
<?php
class Profile
{
public $nick;
private $secret;
}
class Lazy
{
public function __get($k) { return 1; }
public function __isset($k) { return true; }
}
class Bag
{
public function __get($k) { return null; }
public function probe(): array
{
$p = new Profile();
$l = new Lazy();
$b = new Bag();
$o = new \STDCLASS();
$k = 'x';
return [
isset($p->nick),
isset($l->anything),
isset($b->color, $b->{$k}),
empty($b->size),
empty($b->$k),
isset($this->dynamic),
isset($o->field),
isset(Bag::${$k}),
];
}
}Reported:
- line 28: \Bag has no __isset(); this isset/empty check is always false.
- line 29: \Bag has no __isset(); this isset/empty check is always false.
Configure
In custos.json:
json
{
"rules": {
"MissingIssetImplementation": {
"enabled": false
}
}
}Suppress
Before the statement or declaration (or the first statement of the file), either of:
php
// @custos-ignore MissingIssetImplementation
/**
* @noinspection MissingIssetImplementationInspection
*/