Bug #81160 [NEW]: isset/empty doesn't throw a TypeError on invalid string offset

From: Date: Thu, 17 Jun 2021 22:02:52 +0000
Subject: Bug #81160 [NEW]: isset/empty doesn't throw a TypeError on invalid string offset
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-234470@lists.php.net to get a copy of this message
From: girgias Operating system: PHP version: 8.0.8RC1 Package: Scripting Engine problem Bug Type: Bug Bug description:isset/empty doesn't throw a TypeError on invalid string offset Description: ------------ An invalid array offset will trigger a TypeError when used in isset/empty. The same should be done for string offsets. Test script: --------------- <?php $s = 'Hello'; $o = new stdClass(); $a = []; try { var_dump(isset($s[$o])); } catch (\Throwable $e) { echo $e->getMessage(), "\n"; } try { var_dump(empty($s[$o])); } catch (\Throwable $e) { echo $e->getMessage(), "\n"; } try { var_dump(isset($s[$a])); } catch (\Throwable $e) { echo $e->getMessage(), "\n"; } try { var_dump(empty($s[$a])); } catch (\Throwable $e) { echo $e->getMessage(), "\n"; } try { var_dump(isset($s[[]])); } catch (\Throwable $e) { echo $e->getMessage(), "\n"; } try { var_dump(empty($s[[]])); } catch (\Throwable $e) { echo $e->getMessage(), "\n"; } ?> -- Edit bug report at https://bugs.php.net/bug.php?id=81160&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=81160&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=81160&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=81160&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=81160&r=needscript Try newer version: https://bugs.php.net/fix.php?id=81160&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=81160&r=support Expected behavior: https://bugs.php.net/fix.php?id=81160&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=81160&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=81160&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=81160&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=81160&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=81160&r=dst IIS Stability: https://bugs.php.net/fix.php?id=81160&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=81160&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=81160&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=81160&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=81160&r=mysqlcfg

« previous php.bugs (#234470) next »