Skip to content

[NAN] === mixed is always evaluated as false #11054

@ethernidee

Description

@ethernidee

Bug report

I thought the bug was already fixed in the last version (#10956), but it seems, that it was solved only partially.

Strict comparison using === between mixed and array{NAN} will always evaluate to false.

In PHP every value, include array with NAN on any depth level IS equal to itself, even when you assign one variable to another (increasing refcount, but keeping same zval).

Example:

$a = [NAN];
assert($a === $a);
/** @var mixed $b */
$b = $a;
assert($b === $b);
assert($b === $a);
assert($b !== [NAN]); // other zvals's are compared structurally with the rule that NAN !== NAN.

Code snippet that reproduces the problem

https://phpstan.org/r/c56b5606-3a01-42b2-8c77-c03483568949

Expected output

No error

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