Closed
Description
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