1.2.249. Could Be Array Typehint¶
This rule spots arguments, class constants, properties or return values that may be labeled with the
array
scalar typehint.
<?php
// $arg is used as an array in this function, so it may be typed : array
functions foo($arg) {
// the returned value is always an array, so this function might be typed as : array
return array($arg[3]);
}
?>
See also Type declarations.
1.2.249.1. Suggestions¶
Add array typehint to the code.
1.2.249.2. Specs¶
Short name |
Typehints/CouldBeArray |
Rulesets |
|
Exakat since |
2.1.2 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
High |
Features |
array |
Available in |