Skip to content

Report using null as array offset #13592

@derrabus

Description

@derrabus

Feature request

PHP 8.5 will emit a deprecation notice if null is used as an array offset.

Reproducer:

$array = ['' => 'foo'];

var_dump($array[null]);
var_dump(isset($array[null]));

Output:

Deprecated: Using null as an array offset is deprecated, use an empty string instead in /in/h1Iie on line 5
string(3) "foo"

Deprecated: Using null as an array offset is deprecated, use an empty string instead in /in/h1Iie on line 6
bool(true)

https://3v4l.org/h1Iie/rfc#vgit.master

It would be great if PHPStan would report using null or an expression that can evaluate to null as an array offset so we can track down where our codebase might trigger this new deprecation.

Did PHPStan help you today? Did it make you happy in any way?

It did. 🙂

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