Skip to content

Null wrongly added as possible variable value #9395

@MoonE

Description

@MoonE

Psalm adds null as a possible value to a variable that never gets assigned null.
After the comparison $as value according to psalm is -1|null

<?php

$a = -1;
if ($a !== null) {
}
echo $a;

Obviously the if block serves no purpose here. However the same problem occurred in a more complex function where an int variable was compared to an int|null variable.

https://psalm.dev/r/1502d48747

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions