Req #79762 [NEW]: ord should throw ValueError exception on empty string

From: Date: Wed, 01 Jul 2020 00:21:49 +0000
Subject: Req #79762 [NEW]: ord should throw ValueError exception on empty string
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-227749@lists.php.net to get a copy of this message
From: raincomplain at outlook dot com Operating system: PHP version: 8.0.0alpha1 Package: Strings related Bug Type: Feature/Change Request Bug description:ord should throw ValueError exception on empty string Description: ------------ Empty string in PHP doesn't equal U+0000 which is why mb_ord will not return 0 when passing empty string. On the other hand, ord will not complain about passing empty string. I know ord is not aware of any string encoding but this behavior however leads to a wrong assumption that empty string === U+0000 which in turn leads to bugs like https://bugs.php.net/bug.php?id=69162 So one might think if var_dump(ord('') === 0); // true And var_dump(ord("\u{0000}") === 0); // true Then the following must be true var_dump("\u{0000}" === ''); // false Test script: --------------- var_dump(ord('')); Expected result: ---------------- Fatal error: Uncaught ValueError: ord(): Argument #1 ($str) must not be empty Actual result: -------------- int(0) -- Edit bug report at https://bugs.php.net/bug.php?id=79762&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=79762&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=79762&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=79762&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=79762&r=needscript Try newer version: https://bugs.php.net/fix.php?id=79762&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=79762&r=support Expected behavior: https://bugs.php.net/fix.php?id=79762&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=79762&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=79762&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=79762&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=79762&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=79762&r=dst IIS Stability: https://bugs.php.net/fix.php?id=79762&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=79762&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=79762&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=79762&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=79762&r=mysqlcfg

« previous php.bugs (#227749) next »