Skip to content

More array access checks on strings #1308

@iluuu1994

Description

@iluuu1994

PHPStan 0.10.2

Summary of a problem or a feature request

Array access is allowed on type string. However, the offset must be an int (or convertible to an int). Additionally, when assigning, the [] = assignment is not allowed:

https://3v4l.org/qJG1U
https://3v4l.org/mDX6U

Both of these are not reported by PHPStan right now

Code snippet that reproduces the problem

https://phpstan.org/r/20740a7cbc817c5a9f5c00a2d7b7f65e

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions