1.2.1457. Wrong Type With Call¶
This analysis checks that a call to a method uses the types.
This analysis is compatible with Union types and with Intersection types.
Currently, this analysis doesn’t take into account strict_types = 1
. As such, int
and string
won’t be compatible.
<?php
function foo(string $a) {
}
// wrong type used
foo(1);
// wrong type used
foo("1");
?>
1.2.1457.2. Connex PHP features¶
1.2.1457.2.1. Suggestions¶
Use the right type with all arguments
Force the type with a cast
Check the type before calling
1.2.1457.2.2. Specs¶
Short name |
Functions/WrongTypeWithCall |
Rulesets |
|
Exakat since |
1.9.9 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
Very high |
Available in |