1.2.1434. Weak Type With Array¶
Using array as a type, to use specific index later.
The type of array is too weak : it allows to know that the array syntax has to be used in the function. Yet, it doesn’t enforce the presence or absence of a specific index.
<?php
function foo(array $variable) {
echo $array['display'];
}
?>
See also Stop using Arrays and Never* Use Arrays.
1.2.1434.1. Connex PHP features¶
1.2.1434.1.1. Suggestions¶
Use a class as type, instead of
1.2.1434.1.2. Specs¶
Short name |
Arrays/WeakType |
Rulesets |
|
Exakat since |
2.5.1 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
High |
Available in |