Skip to content

greater.alwaysFalse triggers erroneously with comparison to time() #13874

@mikethea1

Description

@mikethea1

Bug report

The associated code snippet triggers an error which seems to be making a wrong assumption that functions will return determinstic values.

  • Replacing time() with mt_rand() makes the issue go away
  • Replacing time() with a function call to a user-defined function self::foo() exhibits the same issue

Code snippet that reproduces the problem

https://phpstan.org/r/44b1d4c8-3b9d-46b9-85d7-5a35b8c45ca4

Expected output

No error

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

I've been super impressed with phpstan so far. I've been working my way through the levels and have discovered and fixed many small bugs along the way. In addition to the core functionality, I appreciate the extra attention to developer ergonomics (readable output, thoughtful error messages, sanity checks on ignore regexes, etc). Feels a step above other linters in this regard.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions