| 1 | <?php |
||
| 14 | class Level |
||
| 15 | { |
||
| 16 | /** @var int */ |
||
| 17 | const UNCLASSIFIED = 0; |
||
| 18 | |||
| 19 | /** @var int */ |
||
| 20 | const LOCAL_CLASS = 1; |
||
| 21 | |||
| 22 | /** @var int */ |
||
| 23 | const REGIONAL_CLASS = 2; |
||
| 24 | |||
| 25 | /** @var int */ |
||
| 26 | const NATIONAL_CLASS = 3; |
||
| 27 | |||
| 28 | /** @var int */ |
||
| 29 | const WORLD_CLASS = 4; |
||
| 30 | |||
| 31 | /** @var int */ |
||
| 32 | const WORLD_RECORD_CLASS = 5; |
||
| 33 | |||
| 34 | /** @var array */ |
||
| 35 | protected $Limits = [0.0, 0.6, 0.7, 0.8, 0.9, 1.0]; |
||
| 36 | |||
| 37 | /** @var int */ |
||
| 38 | protected $Class = 0; |
||
| 39 | |||
| 40 | /** |
||
| 41 | * @param float $ageGrade |
||
| 42 | */ |
||
| 43 | 4 | public function __construct($ageGrade = 0.0) |
|
| 47 | |||
| 48 | /** |
||
| 49 | * @param float $ageGrade in [0.0 .. 1.0] |
||
| 50 | * @return int |
||
| 51 | */ |
||
| 52 | 4 | public function setFromAgeGrade($ageGrade) |
|
| 63 | |||
| 64 | /** |
||
| 65 | * @return int |
||
| 66 | */ |
||
| 67 | 3 | public function getClass() |
|
| 71 | } |
||
| 72 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountIdthat can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theidproperty of an instance of theAccountclass. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.