1 | <?php |
||
9 | class Post |
||
10 | { |
||
11 | /** |
||
12 | * @var string |
||
13 | */ |
||
14 | private $file; |
||
15 | |||
16 | /** |
||
17 | * @var string |
||
18 | */ |
||
19 | private $title; |
||
20 | |||
21 | /** |
||
22 | * @var string |
||
23 | */ |
||
24 | private $intro; |
||
25 | |||
26 | /** |
||
27 | * @var string |
||
28 | */ |
||
29 | private $readTime; |
||
30 | |||
31 | /** |
||
32 | * @var string |
||
33 | */ |
||
34 | private $content; |
||
35 | |||
36 | /** |
||
37 | * @var string |
||
38 | */ |
||
39 | private $slug; |
||
40 | |||
41 | /** |
||
42 | * @var int |
||
43 | */ |
||
44 | private $num; |
||
45 | |||
46 | /** |
||
47 | * @var \DateTime |
||
48 | */ |
||
49 | private $created; |
||
50 | |||
51 | /** |
||
52 | * @var \DateTime |
||
53 | */ |
||
54 | private $updated; |
||
55 | |||
56 | /** |
||
57 | * Set file |
||
58 | * |
||
59 | * @param string $file |
||
60 | * @return Post |
||
61 | */ |
||
62 | public function setFile($file) |
||
63 | { |
||
64 | $this->file = $file; |
||
65 | |||
66 | return $this; |
||
67 | } |
||
68 | |||
69 | /** |
||
70 | * Get file |
||
71 | * |
||
72 | * @return string |
||
73 | */ |
||
74 | public function getFile() |
||
75 | { |
||
76 | return $this->file; |
||
77 | } |
||
78 | |||
79 | /** |
||
80 | * Set title |
||
81 | * |
||
82 | * @param string $title |
||
83 | * @return Post |
||
84 | */ |
||
85 | public function setTitle($title) |
||
86 | { |
||
87 | $this->title = $title; |
||
88 | |||
89 | return $this; |
||
90 | } |
||
91 | |||
92 | /** |
||
93 | * Get title |
||
94 | * |
||
95 | * @return string |
||
96 | */ |
||
97 | public function getTitle() |
||
98 | { |
||
99 | return $this->title; |
||
100 | } |
||
101 | |||
102 | /** |
||
103 | * Set intro |
||
104 | * |
||
105 | * @param string $intro |
||
106 | * @return Post |
||
107 | */ |
||
108 | public function setIntro($intro) |
||
114 | |||
115 | /** |
||
116 | * Get intro |
||
117 | * |
||
118 | * @return string |
||
119 | */ |
||
120 | public function getIntro() |
||
124 | |||
125 | /** |
||
126 | * Set content |
||
127 | * |
||
128 | * @param string $content |
||
129 | * @return Post |
||
130 | */ |
||
131 | public function setContent($content) |
||
137 | |||
138 | /** |
||
139 | * Get content |
||
140 | * |
||
141 | * @return string |
||
142 | */ |
||
143 | public function getContent() |
||
147 | |||
148 | /** |
||
149 | * Set slug |
||
150 | * |
||
151 | * @param string $slug |
||
152 | * @return Post |
||
153 | */ |
||
154 | public function setSlug($slug) |
||
160 | |||
161 | /** |
||
162 | * Get slug |
||
163 | * |
||
164 | * @return string |
||
165 | */ |
||
166 | public function getSlug() |
||
167 | { |
||
168 | return $this->slug; |
||
169 | } |
||
170 | |||
171 | /** |
||
172 | * @param string $date |
||
173 | */ |
||
174 | public function setCreated($date) |
||
178 | |||
179 | /** |
||
180 | * @return \DateTime |
||
181 | */ |
||
182 | public function getCreated() |
||
186 | |||
187 | /** |
||
188 | * @param string $date |
||
189 | */ |
||
190 | public function setUpdated($date) |
||
194 | |||
195 | /** |
||
196 | * @return \DateTime |
||
197 | */ |
||
198 | public function getUpdated() |
||
202 | |||
203 | /** |
||
204 | * Set num |
||
205 | * |
||
206 | * @param int $id |
||
207 | * @return Post |
||
208 | */ |
||
209 | public function setNum($id) |
||
215 | |||
216 | /** |
||
217 | * Get num |
||
218 | * |
||
219 | * @return string |
||
220 | */ |
||
221 | public function getNum() |
||
225 | |||
226 | /** |
||
227 | * Set read time |
||
228 | * |
||
229 | * @param string $readTime |
||
230 | * @return Post |
||
231 | */ |
||
232 | public function setReadTime($readTime) |
||
238 | |||
239 | /** |
||
240 | * Get read time |
||
241 | * |
||
242 | * @return string |
||
243 | */ |
||
244 | public function getReadTime() |
||
248 | |||
249 | } |
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.