Skip to content

Function JIT emits "could not convert to int" warning at the same time as invalid offset Error #12748

Closed
@Girgias

Description

@Girgias

Description

The following code:

<?php

$container = "string";
// Is
try {
    echo "isset():\n";
    var_dump(isset($container[new stdClass()]));
} catch (\Throwable $e) {
    echo $e->getMessage(), "\n";
}
try {
    echo "empty():\n";
    var_dump(empty($container[new stdClass()]));
} catch (\Throwable $e) {
    echo $e->getMessage(), "\n";
}
try {
    echo "Coalesce():\n";
    var_dump($container[new stdClass()] ?? 'default');
} catch (\Throwable $e) {
    echo $e->getMessage(), "\n";
}

?>

Resulted in this output:

isset():
bool(false)
empty():
bool(true)
Coalesce():

Warning: Object of class stdClass could not be converted to int in %s on line %d
Cannot access offset of type stdClass on string

But I expected this output instead:

isset():
bool(false)
empty():
bool(true)
Coalesce():
Cannot access offset of type stdClass on string

Related to #12723

PHP Version

PHP 8.2-dev

Operating System

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions