Skip to content

Second rand(1,x) results in incorrect error #3553

@Fosse

Description

@Fosse

Bug report

It seems that a second rand() results in a false positive only when using rand(1, x). E.g. rand(0, 100) does not give an error.

Error:
Comparison operation "<" between int<5, max> and 5 is always false.

Code snippet that reproduces the problem

https://phpstan.org/r/f6cd6866-3de6-4034-8b7c-dc083bbc17c2

Another example, without the elseif:
https://phpstan.org/r/1db5d8ae-21df-46bd-8361-818e872964c0

Expected output

Expected output is no error. When rand(1, 100) is changed to something else like rand(0, 100) the error also disappears.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions