Skip to content

false positive for "Call to function is_null() with null will always evaluate to false" #12087

@bepsvpt

Description

@bepsvpt

Bug report

<?php declare(strict_types = 1);

enum Button: int
{
	case On = 1;

	case Off = 0;
}

$value = 10;

var_dump(is_null($value = Button::tryFrom($value)));

After running the above code, the value of $value is null, but PHPStan reports "Call to function is_null() with null will always evaluate to false."

https://onlinephp.io/c/9d888d2d-344e-48bf-9a16-f3fc3f6dc111

Code snippet that reproduces the problem

https://phpstan.org/r/3332b922-4e1f-48b3-a83b-4ea9ac13a32a

Expected output

Call to function is_null() with null will always evaluate to true.

Did PHPStan help you today? Did it make you happy in any way?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions