+
Skip to content

array_diff() with arrays containing non-stringable values not reported #5848

@dktapps

Description

@dktapps

Bug report

array_diff() attempts to (string) $value in order to compare them. This is a problem when the values aren't stringable, like objects without __toString(), or arrays.

Code snippet that reproduces the problem

https://phpstan.org/r/59da99db-33f2-4546-892f-51240144c160
https://3v4l.org/VhL6n

Expected output

An error should be reported on line 6, because stdClass is not castable to string.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载