Emitted when conditional doesn't make sense given the docblock types supplied.


 * @param string $s
 * @return void
function foo($s) {
    if ($s === null) {
        throw new \Exception('Bad input');

    echo $s;

Why this is bad

This can sometimes point to a flaw in either your docblock types, or some unnecessary runtime checks in an environment where all types can be checked by Psalm, without the need for additional runtime checks.

How to fix

A lot of old PHP code is set up to prevent unexpected errors with checks like the one above.

As you migrate your code to newer versions of PHP you can also use stricter type-hints:


function foo(string $s) : void {
    echo $s;

Since it's impossible for $s to be anything but a string inside the function, the null check can be removed.