Skip to content

False positive Strict comparison using === when treatPhpDocTypesAsCertain is false #5698

@canvural

Description

@canvural

Bug report

Code snippet that reproduces the problem

<?php

function foo(int ...$foo): void {
    var_dump($foo === []);
}

foo();
foo(5);

When treatPhpDocTypesAsCertain is true there is no error reported for the above code: https://phpstan.org/r/df01e23e-636a-4d09-b106-806a14fd46ed

But when treatPhpDocTypesAsCertain is false, there is Strict comparison using === between array<int, int> and array() will always evaluate to false.: https://phpstan.org/r/16b5347b-fd04-4ae9-be7a-366f87918cac

Calling foo with no arguments is valid: https://3v4l.org/lmbDD

Expected output

No error in both cases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions