Bug #81159 [NEW]: Object to int warning when using an object as a string offset
From: girgias
Operating system:
PHP version: 8.0.8RC1
Package: Scripting Engine problem
Bug Type: Bug
Bug description:Object to int warning when using an object as a string offset
Description:
------------
As of PHP 8.0 objects cannot be used as string offsets, but they still
emit an E_WARNING about conversion to int on top of the TypeError
Test script:
---------------
<?php
$s = 'Hello';
$o = new stdClass();
try {
$s[$o] = 'A';
} catch (\Throwable $e) {
echo $e->getMessage(), "\n";
}
try {
var_dump($s[$o]);
} catch (\Throwable $e) {
echo $e->getMessage(), "\n";
}
?>
Expected result:
----------------
Cannot access offset of type stdClass on string
Cannot access offset of type stdClass on string
Actual result:
--------------
Warning: Object of class stdClass could not be converted to int in
/in/YhEYe on line 11
Cannot access offset of type stdClass on string
Warning: Object of class stdClass could not be converted to int in
/in/YhEYe on line 16
Cannot access offset of type stdClass on string
--
Edit bug report at https://bugs.php.net/bug.php?id=81159&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=81159&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=81159&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=81159&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=81159&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=81159&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=81159&r=support
Expected behavior: https://bugs.php.net/fix.php?id=81159&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=81159&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=81159&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=81159&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=81159&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=81159&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=81159&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=81159&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=81159&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=81159&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=81159&r=mysqlcfg
Thread (3 messages)
- girgias@php.net