1.2.699. Mismatched Typehint¶
Relayed arguments don’t have the same typehint.
Typehint acts as a filter method. When an object is checked with a first class, and then checked again with a second distinct class, the whole process is always false : $a can’t be of two different classes at the same time. Note : This analysis currently doesn’t check generalisation of classes : for example, when B is a child of BB, it is still reported as a mismatch.
<?php
// Foo() calls bar()
function foo(A $a, B $b) {
bar($a, $b);
}
// $a is of A typehint in both methods, but
// $b is of B then BB typehing
function bar(A $a, BB $b) {
}
?>
1.2.699.1. Connex PHP features¶
1.2.699.1.1. Suggestions¶
Ensure that the default value match the expected typehint.
1.2.699.1.2. Specs¶
Short name |
Functions/MismatchedTypehint |
Rulesets |
|
Exakat since |
0.12.3 |
PHP Version |
All |
Severity |
Major |
Time To Fix |
Quick (30 mins) |
Precision |
High |
Examples |
|
Available in |