Skip to content

Bad type detection inside the cycle #923

Closed

Description

@dg

Inside cycle is type detected as array|Obj instead of array.

Code snippet that reproduces the problem

https://phpstan.org/r/65554843120524c6a9a2fb03d35fe92f

Expected output

No error 'Parameter #1 $arr of class Obj constructor expects array, array|Obj given.'

Activity

  1. muglug commented on Apr 17, 2018

    @muglug
    Contributor

    Might want to follow what I do, and pass the do conditional to the loop checker to be re-evaluated on each pass.

  2. ondrejmirtes commented on Apr 17, 2018

    @ondrejmirtes
    Member

    The do-while loop analysis usually works, this might be something about the reused $arr = new Obj($arr); on the same line. Again, something that will be solved by @JanTvrdik's refactoring...

  3. ondrejmirtes commented on Mar 2, 2019

    @ondrejmirtes
    Member

    Will be fixed by #1938

  4. added a commit that references this issue on Mar 3, 2019
    d612a84
  5. locked as resolved and limited conversation to collaborators on Dec 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions