1.2.1644. isset() With Constant¶
Until PHP 7, it was possible to use arrays as constants, but it was not possible to test them with isset.
This would yield an error : Cannot use `isset() <https://www.www.php.net/isset>`_ on the `result <https://www.php.net/result>`_ of an expression (you can use "null !== expression" instead)
. This is a backward incompatibility.
<?php
const X = [1,2,3];
if (isset(X[4])) {}
?>
1.2.1644.2. Connex PHP features¶
1.2.1644.2.1. Suggestions¶
Avoid testing values on constants.
1.2.1644.2.2. Specs¶
Short name |
Structures/IssetWithConstant |
Rulesets |
All, Changed Behavior, CompatibilityPHP53, CompatibilityPHP54, CompatibilityPHP55, CompatibilityPHP56 |
Exakat since |
0.8.4 |
PHP Version |
With PHP 7.0 and more recent |
Severity |
Major |
Time To Fix |
Instant (5 mins) |
Changed Behavior |
PHP 7.0 |
Precision |
Very high |
Available in |