1.2.823. No Null For Index¶
Avoid using null
value as an index in an array. PHP actually casts it to the empty string. This means that later, it might be impossible to find the null
in the list of keys.
<?php
$a = [];
$a[null] = 1;
print_r(array_keys($a));
// [''] empty string
?>
1.2.823.1. Connex PHP features¶
1.2.823.1.1. Suggestions¶
Always checks for null values. Given it then a valid value.
1.2.823.1.2. Specs¶
Short name |
Structures/NoNullForIndex |
Rulesets |
|
Exakat since |
2.5.3 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
Medium |
Available in |