phpstan-strict-rules icon indicating copy to clipboard operation
phpstan-strict-rules copied to clipboard

Rule to prefer !== null check over isset() for existing variable/key/property

Open VincentLanglet opened this issue 2 years ago • 1 comments

When using isset() we're checking that

  • The property/variable/... is defined
  • The value is not null

When the value is always defined, it could be clearer to write $foo !== null instead.

VincentLanglet avatar Apr 26 '22 10:04 VincentLanglet

This is somewhat a code sniffer rule already for me. But in PHPStan it would be easier or more correct to check the existence within a scope

dereuromark avatar Nov 23 '23 02:11 dereuromark