Open westonruter opened 3 months ago
https://github.com/phpstan/phpstan-strict-rules Is your friend.
Works like a charm
But I said we were done with PHPStan PRs 😂
Per https://github.com/WordPress/performance/pull/1489#discussion_r1725404800, let's change this issue to be only about empty()
- or, if we want to include isset()
, it should only be prevented on variable checks like isset( $something )
, but not on e.g. array key or object property checks like isset( $arr['something'] )
.
Feature Description
The use of
empty()
andisset( $var )
can mask code problems (e.g. typos). And they rarely need to be used, for example:cf. comment by @felixarntz in https://github.com/WordPress/performance/pull/1091#discussion_r1543908524
We should consider adding sniffs to warn against their use. (Granted, PHPStan should catch the problematic uses of
isset()
andempty()
.)