[Downgrade 7.0] Constant array isset
Feature Request
PHP 5 does not like using isset on ArrayDimFetch on a (class) constant
Fatal error: Cannot use isset() on the result of an expression (you can use "null !== expression" instead) in /in/TJa2A
Diff
const LEVEL_MAP = [ 'foo' => true ];
-var_dump(isset(LEVEL_MAP['foo']));
+var_dump(array_key_exists(LEVEL_MAP, 'foo') && LEVEL_MAP['foo'] !== null);
or maybe
-var_dump(isset(LEVEL_MAP['foo']));
+var_dump((($newTempVariable = LEVEL_MAP) && false) || isset($newTempVariable['foo']));
Hi, thanks for the diff and 3v4l.org. I'm curious, where are you using this downgrade to PHP 7.0?
Hi, I aim to convert selfoss RSS reader code base to PHP 8.1, while still allowing users to use it on ancient LTS distros (i.e. PHP 5.6).
I see. It's not in our feature list to be honest, as we focus mainly on quality support mainly to PHP 7.1.
Would you like to contribute this rule?
Yes, it is on my to-do list.
What solution from the opening post do you prefer?
The first one look more straight forward.
I'm going through old issues to narrow tracker focus on unclear issues that needs our attention. Feel free to send PR with it :+1:
Closing as accepted.