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_block", type="text", nullable=true) |
||
67 | */ |
||
68 | protected $mailModerationValidatedBlock; |
||
69 | |||
70 | /** |
||
71 | * @ORM\Column(name="mail_moderation_rejected",type="boolean", nullable=true) |
||
72 | */ |
||
73 | protected $mailModerationRejected = 0; |
||
74 | |||
75 | /** |
||
76 | * @Gedmo\Translatable |
||
77 | * @ORM\Column(name="mail_moderation_rejected_block", type="text", nullable=true) |
||
78 | */ |
||
79 | protected $mailModerationRejectedBlock; |
||
80 | |||
81 | /** |
||
82 | * @ORM\OneToOne(targetEntity="PostVoteForm", mappedBy="postvote", cascade={"persist","remove"}) |
||
83 | **/ |
||
84 | private $form; |
||
85 | |||
86 | /** |
||
87 | * @ORM\OneToMany(targetEntity="PostVotePost", mappedBy="postvote") |
||
88 | **/ |
||
89 | private $posts; |
||
90 | |||
91 | public function __construct() |
||
97 | |||
98 | /** |
||
99 | * Add a post to the game |
||
100 | * |
||
101 | * @param PostVotePost $post |
||
102 | * |
||
103 | * @return void |
||
104 | */ |
||
105 | public function addPost($post) |
||
109 | |||
110 | public function getPosts() |
||
114 | |||
115 | public function setPosts($posts) |
||
121 | |||
122 | /** |
||
123 | * @return the unknown_type |
||
124 | */ |
||
125 | public function getForm() |
||
129 | |||
130 | /** |
||
131 | * @param unknown_type $form |
||
132 | */ |
||
133 | public function setForm($form) |
||
139 | |||
140 | /** |
||
141 | * @return string unknown_type |
||
142 | */ |
||
143 | public function getPostDisplayMode() |
||
147 | |||
148 | /** |
||
149 | * @param unknown_type $postDisplayMode |
||
150 | */ |
||
151 | public function setPostDisplayMode($postDisplayMode) |
||
157 | |||
158 | /** |
||
159 | * @return int |
||
160 | */ |
||
161 | public function getPostDisplayNumber() |
||
165 | |||
166 | /** |
||
167 | * @param int $postDisplayNumber |
||
168 | * |
||
169 | * @return PostVote |
||
170 | */ |
||
171 | public function setPostDisplayNumber($postDisplayNumber) |
||
177 | |||
178 | /** |
||
179 | * @return the unknown_type |
||
180 | */ |
||
181 | public function getVoteActive() |
||
185 | |||
186 | /** |
||
187 | * @param unknown_type $voteActive |
||
188 | */ |
||
189 | public function setVoteActive($voteActive) |
||
195 | |||
196 | /** |
||
197 | * @return the unknown_type |
||
198 | */ |
||
199 | public function getVoteAnonymous() |
||
203 | |||
204 | /** |
||
205 | * @param unknown_type $voteAnonymous |
||
206 | */ |
||
207 | public function setVoteAnonymous($voteAnonymous) |
||
213 | |||
214 | /** |
||
215 | * @return bool |
||
216 | */ |
||
217 | public function getModerationType() |
||
221 | |||
222 | /** |
||
223 | * @param bool $moderationType |
||
224 | */ |
||
225 | public function setModerationType($moderationType) |
||
231 | |||
232 | /** |
||
233 | * @return bool |
||
234 | */ |
||
235 | public function getMailModerationValidated() |
||
239 | |||
240 | /** |
||
241 | * @param bool $mailModerationValidated |
||
242 | */ |
||
243 | public function setMailModerationValidated($mailModerationValidated) |
||
249 | |||
250 | /** |
||
251 | * @return bool |
||
252 | */ |
||
253 | public function getMailModerationValidatedBlock() |
||
257 | |||
258 | /** |
||
259 | * @param bool $mailModerationValidatedBlock |
||
260 | */ |
||
261 | public function setMailModerationValidatedBlock($mailModerationValidatedBlock) |
||
267 | |||
268 | /** |
||
269 | * @return bool |
||
270 | */ |
||
271 | public function getMailModerationRejected() |
||
275 | |||
276 | /** |
||
277 | * @param bool $mailModerationRejected |
||
278 | */ |
||
279 | public function setMailModerationRejected($mailModerationRejected) |
||
285 | |||
286 | /** |
||
287 | * @return bool |
||
288 | */ |
||
289 | public function getMailModerationRejectedBlock() |
||
293 | |||
294 | /** |
||
295 | * @param bool $mailModerationRejectedBlock |
||
296 | */ |
||
297 | public function setMailModerationRejectedBlock($mailModerationRejectedBlock) |
||
303 | |||
304 | /** |
||
305 | * Convert the object to an array. |
||
306 | * |
||
307 | * @return array |
||
308 | */ |
||
309 | public function getArrayCopy() |
||
316 | |||
317 | /** |
||
318 | * Populate from an array. |
||
319 | * |
||
320 | * @param array $data |
||
321 | */ |
||
322 | View Code Duplication | public function populate($data = array()) |
|
334 | |||
335 | public function setInputFilter(InputFilterInterface $inputFilter) |
||
339 | |||
340 | public function getInputFilter() |
||
415 | } |
||
416 |
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..