Skip to content

False positive when order of statements is changed #5162

@mind-bending-forks

Description

@mind-bending-forks

Bug report

In certain circumstances, logic used to narrow down types is not correctly understood by phpstan.

Code snippet that reproduces the problem

https://phpstan.org/r/68974319-0f1f-4b77-9561-86f5da7cbc54

Expected output

  • phpstan should understand that $result2['a'] is numeric and so can be cast to float.
  • no errors reported by phpstan

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

Yes

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions