vimeo/psalm

Prevent comparison of null

Open

#6,869 opened on Nov 9, 2021

View on GitHub
 (6 comments) (1 reaction) (0 assignees)PHP (668 forks)batch import
Help wantedenhancement

Repository metrics

Stars
 (5,369 stars)
PR merge metrics
 (Avg merge 3d 12h) (5 merged PRs in 30d)

Description

With code like https://psalm.dev/r/890c56e8d0 (or a more complicated equivalent) I think it's often easy to forget to consider the case where the variable is null.

It might be useful for Psalm to emit an issue to stop comparisons with nullable values, and force the programmer to handle the null explicitly as a special case.

Contributor guide