Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
1 | <?php |
||
19 | class PostVote extends Game implements InputFilterAwareInterface |
||
20 | { |
||
21 | const CLASSTYPE = 'postvote'; |
||
22 | |||
23 | /** |
||
24 | * Display mode of Posts : |
||
25 | * 'date' : sort by post date desc |
||
26 | * 'random' : ... |
||
27 | * 'votes' : sort by number of vote desc |
||
28 | * |
||
29 | * @ORM\Column(name="post_display_mode", type="string", nullable=false) |
||
30 | */ |
||
31 | protected $postDisplayMode = 'date'; |
||
32 | |||
33 | /** |
||
34 | * Number of Post displayed : |
||
35 | * 0 : infinite |
||
36 | * |
||
37 | * @ORM\Column(name="post_display_number", type="integer", nullable=false) |
||
38 | */ |
||
39 | protected $postDisplayNumber = 0; |
||
40 | |||
41 | /** |
||
42 | * Is it possible to vote ? |
||
43 | * @ORM\Column(name="vote_active", type="boolean", nullable=false) |
||
44 | */ |
||
45 | protected $voteActive = 1; |
||
46 | |||
47 | /** |
||
48 | * Is it possible to vote anonymously ? |
||
49 | * @ORM\Column(name="vote_anonymous", type="boolean", nullable=false) |
||
50 | */ |
||
51 | protected $voteAnonymous; |
||
52 | |||
53 | /** |
||
54 | * Type of moderation : moderate posts before their publication, or after their publication (default) |
||
55 | * @ORM\Column(name="moderation_type", type="boolean", nullable=false, options={"default" = 0}) |
||
56 | */ |
||
57 | protected $moderationType = 0; |
||
58 | |||
59 | /** |
||
60 | * @ORM\Column(name="mail_moderation_validated",type="boolean", nullable=true) |
||
61 | */ |
||
62 | protected $mailModerationValidated = 0; |
||
63 | |||
64 | /** |
||
65 | * @Gedmo\Translatable |
||
66 | * @ORM\Column(name="mail_moderation_validated_subject",type="string", nullable=true) |
||
67 | */ |
||
68 | protected $mailModerationValidatedSubject; |
||
69 | |||
70 | /** |
||
71 | * @Gedmo\Translatable |
||
72 | * @ORM\Column(name="mail_moderation_validated_block", type="text", nullable=true) |
||
73 | */ |
||
74 | protected $mailModerationValidatedBlock; |
||
75 | |||
76 | /** |
||
77 | * @ORM\Column(name="mail_moderation_rejected",type="boolean", nullable=true) |
||
78 | */ |
||
79 | protected $mailModerationRejected = 0; |
||
80 | |||
81 | /** |
||
82 | * @Gedmo\Translatable |
||
83 | * @ORM\Column(name="mail_moderation_rejected_subject", type="string", nullable=true) |
||
84 | */ |
||
85 | protected $mailModerationRejectedSubject; |
||
86 | |||
87 | /** |
||
88 | * @Gedmo\Translatable |
||
89 | * @ORM\Column(name="mail_moderation_rejected_block", type="text", nullable=true) |
||
90 | */ |
||
91 | protected $mailModerationRejectedBlock; |
||
92 | |||
93 | /** |
||
94 | * @ORM\OneToOne(targetEntity="PostVoteForm", mappedBy="postvote", cascade={"persist","remove"}) |
||
95 | **/ |
||
96 | private $form; |
||
97 | |||
98 | /** |
||
99 | * @ORM\OneToMany(targetEntity="PostVotePost", mappedBy="postvote") |
||
100 | **/ |
||
101 | private $posts; |
||
102 | |||
103 | public function __construct() |
||
109 | |||
110 | /** |
||
111 | * Add a post to the game |
||
112 | * |
||
113 | * @param PostVotePost $post |
||
114 | * |
||
115 | * @return void |
||
116 | */ |
||
117 | public function addPost($post) |
||
121 | |||
122 | public function getPosts() |
||
126 | |||
127 | public function setPosts($posts) |
||
133 | |||
134 | /** |
||
135 | * @return the unknown_type |
||
136 | */ |
||
137 | public function getForm() |
||
141 | |||
142 | /** |
||
143 | * @param unknown_type $form |
||
144 | */ |
||
145 | public function setForm($form) |
||
151 | |||
152 | /** |
||
153 | * @return string unknown_type |
||
154 | */ |
||
155 | public function getPostDisplayMode() |
||
159 | |||
160 | /** |
||
161 | * @param unknown_type $postDisplayMode |
||
162 | */ |
||
163 | public function setPostDisplayMode($postDisplayMode) |
||
169 | |||
170 | /** |
||
171 | * @return int |
||
172 | */ |
||
173 | public function getPostDisplayNumber() |
||
177 | |||
178 | /** |
||
179 | * @param int $postDisplayNumber |
||
180 | * |
||
181 | * @return PostVote |
||
182 | */ |
||
183 | public function setPostDisplayNumber($postDisplayNumber) |
||
189 | |||
190 | /** |
||
191 | * @return the unknown_type |
||
192 | */ |
||
193 | public function getVoteActive() |
||
197 | |||
198 | /** |
||
199 | * @param unknown_type $voteActive |
||
200 | */ |
||
201 | public function setVoteActive($voteActive) |
||
207 | |||
208 | /** |
||
209 | * @return the unknown_type |
||
210 | */ |
||
211 | public function getVoteAnonymous() |
||
215 | |||
216 | /** |
||
217 | * @param unknown_type $voteAnonymous |
||
218 | */ |
||
219 | public function setVoteAnonymous($voteAnonymous) |
||
225 | |||
226 | /** |
||
227 | * @return bool |
||
228 | */ |
||
229 | public function getModerationType() |
||
233 | |||
234 | /** |
||
235 | * @param bool $moderationType |
||
236 | */ |
||
237 | public function setModerationType($moderationType) |
||
243 | |||
244 | /** |
||
245 | * @return bool |
||
246 | */ |
||
247 | public function getMailModerationValidated() |
||
251 | |||
252 | /** |
||
253 | * @param bool $mailModerationValidated |
||
254 | */ |
||
255 | public function setMailModerationValidated($mailModerationValidated) |
||
261 | |||
262 | /** |
||
263 | * @return bool |
||
264 | */ |
||
265 | public function getMailModerationValidatedSubject() |
||
269 | |||
270 | /** |
||
271 | * @param bool $mailModerationValidatedSubject |
||
272 | */ |
||
273 | public function setMailModerationValidatedSubject($mailModerationValidatedSubject) |
||
279 | |||
280 | /** |
||
281 | * @return bool |
||
282 | */ |
||
283 | public function getMailModerationValidatedBlock() |
||
287 | |||
288 | /** |
||
289 | * @param bool $mailModerationValidatedBlock |
||
290 | */ |
||
291 | public function setMailModerationValidatedBlock($mailModerationValidatedBlock) |
||
297 | |||
298 | /** |
||
299 | * @return bool |
||
300 | */ |
||
301 | public function getMailModerationRejected() |
||
305 | |||
306 | /** |
||
307 | * @param bool $mailModerationRejected |
||
308 | */ |
||
309 | public function setMailModerationRejected($mailModerationRejected) |
||
315 | |||
316 | /** |
||
317 | * @return bool |
||
318 | */ |
||
319 | public function getMailModerationRejectedSubject() |
||
323 | |||
324 | /** |
||
325 | * @param bool $mailModerationRejectedSubject |
||
326 | */ |
||
327 | public function setMailModerationRejectedSubject($mailModerationRejectedSubject) |
||
333 | |||
334 | /** |
||
335 | * @return bool |
||
336 | */ |
||
337 | public function getMailModerationRejectedBlock() |
||
341 | |||
342 | /** |
||
343 | * @param bool $mailModerationRejectedBlock |
||
344 | */ |
||
345 | public function setMailModerationRejectedBlock($mailModerationRejectedBlock) |
||
351 | |||
352 | /** |
||
353 | * Convert the object to an array. |
||
354 | * |
||
355 | * @return array |
||
356 | */ |
||
357 | public function getArrayCopy() |
||
364 | |||
365 | /** |
||
366 | * Populate from an array. |
||
367 | * |
||
368 | * @param array $data |
||
369 | */ |
||
370 | View Code Duplication | public function populate($data = array()) |
|
382 | |||
383 | public function setInputFilter(InputFilterInterface $inputFilter) |
||
387 | |||
388 | public function getInputFilter() |
||
463 | } |
||
464 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..