Skip to content

Bogus write-only error when appending to an array-like object in private class property #6777

Description

@dktapps

Bug report

Using array-access to write to an object field should not be considered a write-only operation, because the object may be used outside of the scope of the class the field it's used in.

This affects both ArrayAccess objects and also special-snowflakes like Threaded which masquerade as arrays without actually implementing ArrayAccess.

Code snippet that reproduces the problem

https://phpstan.org/r/cee77620-54cd-4324-a330-e2990e6edbaf
https://phpstan.org/r/0c8ef0d5-80d9-494d-a400-2b87d0d15b37

Expected output

No error should be reported in either test case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions