| 1 | <?php |
||
| 13 | class Location extends AbstractLocation |
||
| 14 | { |
||
| 15 | /** |
||
| 16 | * @var string |
||
| 17 | */ |
||
| 18 | protected $countryName; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @var string |
||
| 22 | */ |
||
| 23 | protected $state; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @var string |
||
| 27 | */ |
||
| 28 | protected $city; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * @var Country |
||
| 32 | */ |
||
| 33 | protected $country; |
||
| 34 | |||
| 35 | public function __construct($countryCode, $state, $city) |
||
| 41 | |||
| 42 | /** |
||
| 43 | * {@inheritdoc} |
||
| 44 | */ |
||
| 45 | public function toString() |
||
| 49 | |||
| 50 | protected function applyCountry($countryCode) |
||
| 59 | |||
| 60 | /** |
||
| 61 | * @return string |
||
| 62 | */ |
||
| 63 | public function getCountryName() |
||
| 67 | |||
| 68 | /** |
||
| 69 | * @param string $countryName |
||
| 70 | * @return Location |
||
| 71 | */ |
||
| 72 | public function setCountryName($countryName) |
||
| 77 | |||
| 78 | /** |
||
| 79 | * @return string |
||
| 80 | */ |
||
| 81 | public function getState() |
||
| 85 | |||
| 86 | /** |
||
| 87 | * @param string $state |
||
| 88 | * @return Location |
||
| 89 | */ |
||
| 90 | public function setState($state) |
||
| 95 | |||
| 96 | /** |
||
| 97 | * @return string |
||
| 98 | */ |
||
| 99 | public function getCity() |
||
| 103 | |||
| 104 | /** |
||
| 105 | * @param string $city |
||
| 106 | * @return Location |
||
| 107 | */ |
||
| 108 | public function setCity($city) |
||
| 113 | } |
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.