Req #81417 [NEW]: Add a configuration option to determine if reading an undefined array key shoul
| From: | nicolas at gestixi dot com | Date: | Sun, 05 Sep 2021 12:20:50 +0000 |
| Subject: | Req #81417 [NEW]: Add a configuration option to determine if reading an undefined array key shoul | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-236422@lists.php.net to get a copy of this message | ||
From: nicolas at gestixi dot com
Operating system:
PHP version: 8.0.10
Package: *Configuration Issues
Bug Type: Feature/Change Request
Bug description:Add a configuration option to determine if reading an undefined array key shoul
Description:
------------
In some languages, such as JavaScript, accessing an undefined array key
can be performed silently without throwing an error.
We have a 10 years old code base which does conditions like this
everywhere:
if ($array['key']).
With PHP 8, this coding style throws a warning if the key is not
defined. Replacing it by `if (array_key_exists('key', $array) &&
$array['key'])` would take us weeks... and, I actually prefer our actual
syntax which I found more readable.
For these reasons, I do not plan to upgrade all our code base to avoid
this warning. And I do not want to ignore all warnings just for this
one...
Would it be possible to add a configuration setting to determine if this
coding style should throw a warning, a notice or be silently ignored?
Another solution I see would be to be able to ignore specific
warnings/notices.
--
Edit bug report at https://bugs.php.net/bug.php?id=81417&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=81417&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=81417&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=81417&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=81417&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=81417&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=81417&r=support
Expected behavior: https://bugs.php.net/fix.php?id=81417&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=81417&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=81417&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=81417&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=81417&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=81417&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=81417&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=81417&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=81417&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=81417&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=81417&r=mysqlcfg