Skip to content

isset (and ?? operator) could should a notice if the inner expression is non-array #8349

@mvorisek

Description

@mvorisek

Description

The following code:

$oneDimensionalArray = [];
var_dump($oneDimensionalArray[0][1]);
var_dump($oneDimensionalArray[0][1] ?? '');

https://3v4l.org/1LMRe

Resulted in this output:

Warning: Undefined array key 0 in /in/1LMRe on line 4

Warning: Trying to access array offset on value of type null in /in/1LMRe on line 4
NULL
string(0) ""

But I expected this output instead:

Warning: Undefined array key 0 in /in/1LMRe on line 4

Warning: Trying to access array offset on value of type null in /in/1LMRe on line 4
NULL
Warning: Undefined array key 0 in /in/1LMRe on line 4

string(0) ""

PHP Version

8 - master

Operating System

any

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