Skip to content

JIT: Integer string in variable used as offset produces wrong undefined array key warning #12812

Closed
@Girgias

Description

@Girgias

Description

Found while working on #12723

The following code:

<?php

$container = [];
$dimension = '7';

try {
    var_dump($container['7']);
} catch (\Throwable $e) {
    echo $e->getMessage(), "\n";
}
try {
    var_dump($container[$dimension]);
} catch (\Throwable $e) {
    echo $e->getMessage(), "\n";
}

Resulted in this output:

Warning: Undefined array key 7 in %s on line %d
NULL

Warning: Undefined array key "7" in %s on line %d
NULL

But I expected this output instead:

Warning: Undefined array key 7 in %s on line %d
NULL

Warning: Undefined array key 7 in %s on line %d
NULL

PHP Version

PHP 8.2

Operating System

No response

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