1 | <?php |
||
5 | class LobPostcard |
||
6 | { |
||
7 | /** @var string */ |
||
8 | public $type = 'postcards'; |
||
9 | |||
10 | /** @var string|null */ |
||
11 | protected $fromAddress = null; |
||
12 | |||
13 | /** @var string|null */ |
||
14 | protected $toAddress = null; |
||
15 | |||
16 | /** @var string */ |
||
17 | protected $front; |
||
18 | |||
19 | /** @var string */ |
||
20 | protected $message; |
||
21 | |||
22 | /** @var string */ |
||
23 | protected $size = '4x6'; |
||
24 | |||
25 | /** |
||
26 | * @param string $message |
||
27 | * |
||
28 | * @return static |
||
29 | */ |
||
30 | public static function create($message = '') |
||
34 | |||
35 | /** |
||
36 | * @param string $message |
||
37 | */ |
||
38 | public function __construct($message = '') |
||
42 | |||
43 | /** |
||
44 | * @param string|LobAddress $value |
||
45 | * |
||
46 | * @return $this |
||
47 | */ |
||
48 | public function fromAddress($value) |
||
54 | |||
55 | /** |
||
56 | * @param string|LobAddress $value |
||
57 | * |
||
58 | * @return $this |
||
59 | */ |
||
60 | public function toAddress($value) |
||
66 | |||
67 | /** |
||
68 | * @param mixed $front |
||
69 | * |
||
70 | * @return $this |
||
71 | */ |
||
72 | public function front($front) |
||
78 | |||
79 | /** |
||
80 | * @param string $message |
||
81 | * |
||
82 | * @return $this |
||
83 | */ |
||
84 | public function message($message) |
||
90 | |||
91 | /** |
||
92 | * @param string $size |
||
93 | * |
||
94 | * @return $this |
||
95 | */ |
||
96 | public function size($size) |
||
102 | |||
103 | /** |
||
104 | * @return $this |
||
105 | */ |
||
106 | public function size4x6() |
||
112 | |||
113 | /** |
||
114 | * @return $this |
||
115 | */ |
||
116 | public function size6x11() |
||
122 | |||
123 | /** |
||
124 | * Get an array representation of the message. |
||
125 | * |
||
126 | * @return array |
||
127 | */ |
||
128 | public function toArray() |
||
138 | } |
||
139 |
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.