1 | <?php |
||
4 | class FilmSpeed extends FilmSpeedAbstract implements FilmSpeedInterface |
||
5 | { |
||
6 | |||
7 | /** |
||
8 | * @param int|float $asa ASA value |
||
9 | * @param int|float $din DIN value |
||
10 | */ |
||
11 | 28 | public function __construct( $asa, $din) |
|
25 | |||
26 | |||
27 | /** |
||
28 | * Returns a string representation, for example: "ISO 200/24°" |
||
29 | * @return string [description] |
||
30 | */ |
||
31 | public function __toString() |
||
35 | |||
36 | |||
37 | /** |
||
38 | * @param bool $rounded Optional: round value; default is FALSE |
||
39 | * @inheritDoc |
||
40 | */ |
||
41 | 44 | public function getDin( $rounded = false) : float |
|
46 | |||
47 | |||
48 | /** |
||
49 | * @param bool $rounded Optional: round value; default is FALSE |
||
50 | * @inheritDoc |
||
51 | */ |
||
52 | 44 | public function getAsa( $rounded = false) : float |
|
57 | |||
58 | |||
59 | /** |
||
60 | * @param bool $rounded Optional: round value; default is TRUE |
||
61 | * @inheritDoc |
||
62 | */ |
||
63 | 36 | public function getIso( $rounded = true ) : string |
|
70 | } |
||
71 |
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
$accountId
that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theid
property of an instance of theAccount
class. 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.