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

From: Date: Fri, 18 Jun 2021 17:12:43 +0000
Subject: Bug #81159 [Ver->Csd]: 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-234488@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: git@php.net Reported by: girgias@php.net Summary: Object to int warning when using an object as a string offset -Status: Verified +Status: Closed Type: Bug Package: Scripting Engine problem PHP Version: 8.0.8RC1 Assigned To: girgias Block user comment: N Private report: N New Comment: Automatic comment on behalf of Girgias Revision: https://github.com/php/php-src/commit/f0fd5922eeb735811f0da0458c390178ceb425ec Log: Fix bug #81159: Object to int warning when using an object as a string offset 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 (#234488) next »