Skip to content

PHPStan fails to detect modifications of static class properties (e.g. arrays) at runtime #3747

@InvisibleSmiley

Description

@InvisibleSmiley

Bug report

A static class property, after having been initialized as an empty array, is modified, e.g. by method calls of the same class or PHPUnit mock object callbacks in the same class. Yet PHPStan still believes the array is empty. Example output:
Offset (int|string) does not exist on array().

Code snippet that reproduces the problem

https://phpstan.org/r/0d08bf7b-5819-412f-a890-1b9a3caf9abd

Expected output

None

Coming from #1940.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions