| Total Complexity | 5 |
| Total Lines | 59 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | final class To extends Recipient |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * @var string |
||
| 11 | */ |
||
| 12 | private $message; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * @var array |
||
| 16 | */ |
||
| 17 | private $tos; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @var bool |
||
| 21 | */ |
||
| 22 | private $useIconv; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @param string|array $tos |
||
| 26 | * @param string $message |
||
| 27 | * @param bool $useIconv |
||
| 28 | */ |
||
| 29 | public function __construct($tos, string $message, bool $useIconv = false) |
||
| 30 | { |
||
| 31 | $this->message = $message; |
||
| 32 | $this->tos = $tos; |
||
|
|
|||
| 33 | $this->useIconv = $useIconv; |
||
| 34 | } |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @return array|string |
||
| 38 | */ |
||
| 39 | public function getTo() |
||
| 40 | { |
||
| 41 | return $this->tos; |
||
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * @return string |
||
| 46 | */ |
||
| 47 | public function getMessage(): string |
||
| 48 | { |
||
| 49 | return $this->message; |
||
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * {@inheritdoc} |
||
| 54 | */ |
||
| 55 | public function useIconv(): bool |
||
| 58 | } |
||
| 59 | |||
| 60 | /** |
||
| 61 | * @return bool |
||
| 62 | */ |
||
| 63 | public function asMulti(): bool |
||
| 66 | } |
||
| 67 | } |
||
| 68 |
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.