Skip to content

@var defining array type seems to be ignored #3269

@Seldaek

Description

@Seldaek

Bug report

It seems the @var annotation is ignored in favor of phpstan detecting the array type from the first insertion done into it. However it ends up with a static value for a string which can be start or end.

Code snippet that reproduces the problem

https://phpstan.org/r/c035c7a7-c737-45e0-8d9e-fa5413d22d8b

Expected output

This should error on line 6 as I am inserting an invalid value into the array.

If I explicit type something I expect it to follow that, not try to guess.

Note that using @phpstan-var or @var does not seem to be making any difference.

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