1.2.290. Could Typehint¶
Arguments that are tested with instanceof, is_array(), is_string(), etc. could be modernized with a typehint.
<?php
function foo($a, $b) {
// $a is tested for B with instanceof.
if (!$a instanceof B) {
return;
}
// More code
}
function foo(B $a, $b) {
// May omit the initial test
// More code
}
?>
1.2.290.1. Connex PHP features¶
1.2.290.1.1. Suggestions¶
Add the typehint, remove the test on the type
1.2.290.1.2. Specs¶
Short name |
Functions/CouldTypehint |
Rulesets |
|
Exakat since |
0.11.5 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
Very high |
Available in |