| 1 | <?php |
||
| 19 | class Relation extends AbstractLine { |
||
| 20 | use MagicGet; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @var integer|null $distance Distance of relation. Defaults null. |
||
| 24 | */ |
||
| 25 | private $distance; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * Relation constructor. |
||
| 29 | * |
||
| 30 | * @param Point $from Start object of relation. |
||
| 31 | * @param Point $to End object of relation. |
||
| 32 | * @param integer|null $distance Distance of relation. Must be greater than 0. |
||
| 33 | */ |
||
| 34 | public function __construct($from, $to, $distance = null) |
||
| 42 | |||
| 43 | /** |
||
| 44 | * Method checks distance. If greater than 0 set sent argument as object parameter or throws exception otherwise. |
||
| 45 | * |
||
| 46 | * @param integer $distance Distance of relation. Must be greater than 0. |
||
| 47 | * @throws RelationException Method throws exception when $distance is less or equal to 0. |
||
| 48 | */ |
||
| 49 | public function setDistance($distance) |
||
| 57 | } |
||
| 58 |
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.