Bug #81159 [Opn->Ver]: Object to int warning when using an object as a string offset

From: Date: Thu, 17 Jun 2021 22:01:13 +0000
Subject: Bug #81159 [Opn->Ver]: Object to int warning when using an object as a string offset
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-234469@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=81159&edit=1 ID: 81159 Updated by: girgias@php.net Reported by: girgias@php.net Summary: Object to int warning when using an object as a string offset -Status: Open +Status: Verified Type: Bug Package: Scripting Engine problem PHP Version: 8.0.8RC1 -Assigned To: +Assigned To: girgias Block user comment: N Private report: N Previous Comments: ------------------------------------------------------------------------ [2021-06-17 21:59:31] girgias@php.net 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 this bug report at https://bugs.php.net/bug.php?id=81159&edit=1

« previous php.bugs (#234469) next »