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 |
||
28 | class KrsEntity extends ModelAbstract |
||
29 | { |
||
30 | const CONTEXT = 'krs_podmioty'; |
||
31 | const PULL_NONE = 0; |
||
32 | const PULL_COMPANIES = 1; |
||
33 | const PULL_DEPARTMENTS = 2; |
||
34 | const PULL_PARTNERS = 4; |
||
35 | const PULL_PKDS = 8; |
||
36 | const PULL_SHARES = 16; |
||
37 | const PULL_PERSON_REPRESENTATION = 32; |
||
38 | const PULL_PERSON_SUPERVISION = 64; |
||
39 | const PULL_PERSON_PROXY = 128; |
||
40 | const PULL_PERSON_FOUNDING = 256; |
||
41 | const PULL_ALL = 511; |
||
42 | |||
43 | |||
44 | /** |
||
45 | * Krs jako int |
||
46 | * |
||
47 | * @var integer |
||
48 | **/ |
||
49 | public $id; |
||
50 | /** |
||
51 | * krs |
||
52 | * |
||
53 | * @var string |
||
54 | **/ |
||
55 | public $krs; |
||
56 | /** |
||
57 | * nip |
||
58 | * |
||
59 | * @var string|null |
||
60 | **/ |
||
61 | public $nip; |
||
62 | /** |
||
63 | * regon |
||
64 | * |
||
65 | * @var string|null |
||
66 | **/ |
||
67 | public $regon; |
||
68 | /** |
||
69 | * nazwa |
||
70 | * |
||
71 | * @var string |
||
72 | **/ |
||
73 | public $nazwa; |
||
74 | /** |
||
75 | * nazwa_skrocona |
||
76 | * |
||
77 | * @var string |
||
78 | **/ |
||
79 | public $nazwa_skrocona; |
||
80 | /** |
||
81 | * adres |
||
82 | * |
||
83 | * @var string |
||
84 | **/ |
||
85 | public $adres; |
||
86 | /** |
||
87 | * wojewodztwo_id |
||
88 | * |
||
89 | * @var integer |
||
90 | **/ |
||
91 | public $wojewodztwo_id; |
||
92 | /** |
||
93 | * powiat_id |
||
94 | * |
||
95 | * @var integer |
||
96 | **/ |
||
97 | public $powiat_id; |
||
98 | /** |
||
99 | * gmina_id |
||
100 | * |
||
101 | * @var integer |
||
102 | **/ |
||
103 | public $gmina_id; |
||
104 | /** |
||
105 | * miejscowosc_id |
||
106 | * |
||
107 | * @var integer |
||
108 | **/ |
||
109 | public $miejscowosc_id; |
||
110 | /** |
||
111 | * kod_pocztowy_id |
||
112 | * |
||
113 | * @var integer |
||
114 | **/ |
||
115 | public $kod_pocztowy_id; |
||
116 | /** |
||
117 | * adres_kod_pocztowy |
||
118 | * |
||
119 | * @var integer |
||
120 | **/ |
||
121 | public $adres_kod_pocztowy; |
||
122 | /** |
||
123 | * adres_kraj |
||
124 | * |
||
125 | * @var string |
||
126 | **/ |
||
127 | public $adres_kraj; |
||
128 | /** |
||
129 | * adres_lokal |
||
130 | * |
||
131 | * @var string |
||
132 | **/ |
||
133 | public $adres_lokal; |
||
134 | /** |
||
135 | * adres_miejscowosc |
||
136 | * |
||
137 | * @var string |
||
138 | **/ |
||
139 | public $adres_miejscowosc; |
||
140 | /** |
||
141 | * adres_numer |
||
142 | * |
||
143 | * @var string |
||
144 | **/ |
||
145 | public $adres_numer; |
||
146 | /** |
||
147 | * adres_poczta |
||
148 | * |
||
149 | * @var string |
||
150 | **/ |
||
151 | public $adres_poczta; |
||
152 | /** |
||
153 | * adres_ulica |
||
154 | * |
||
155 | * @var string |
||
156 | **/ |
||
157 | public $adres_ulica; |
||
158 | /** |
||
159 | * siedziba |
||
160 | * |
||
161 | * @var string |
||
162 | **/ |
||
163 | public $siedziba; |
||
164 | /** |
||
165 | * cel_dzialania |
||
166 | * |
||
167 | * @var string |
||
168 | **/ |
||
169 | public $cel_dzialania; |
||
170 | /** |
||
171 | * data_dokonania_wpisu |
||
172 | * |
||
173 | * @var string |
||
174 | **/ |
||
175 | public $data_dokonania_wpisu; |
||
176 | /** |
||
177 | * data_ostatni_wpis |
||
178 | * |
||
179 | * @var string|null |
||
180 | **/ |
||
181 | public $data_ostatni_wpis; |
||
182 | /** |
||
183 | * data_rejestracji |
||
184 | * |
||
185 | * @var string |
||
186 | **/ |
||
187 | public $data_rejestracji; |
||
188 | /** |
||
189 | * data_sprawdzenia |
||
190 | * |
||
191 | * @var string |
||
192 | **/ |
||
193 | public $data_sprawdzenia; |
||
194 | /** |
||
195 | * dotacje_ue_beneficjent_id |
||
196 | * |
||
197 | * @var integer|null |
||
198 | **/ |
||
199 | public $dotacje_ue_beneficjent_id; |
||
200 | /** |
||
201 | |||
202 | **/ |
||
203 | public $email; |
||
204 | /** |
||
205 | * firma |
||
206 | **/ |
||
207 | public $firma; |
||
208 | /** |
||
209 | * forma_prawna_id |
||
210 | * |
||
211 | * @var integer |
||
212 | **/ |
||
213 | public $forma_prawna_id; |
||
214 | /** |
||
215 | * forma_prawna_str |
||
216 | * |
||
217 | * @var string |
||
218 | **/ |
||
219 | public $forma_prawna_str; |
||
220 | /** |
||
221 | * forma_prawna_typ_id |
||
222 | * |
||
223 | * @var integer |
||
224 | **/ |
||
225 | public $forma_prawna_typ_id; |
||
226 | /** |
||
227 | * forma_prawna_typ_str - pole dodaane jako dodatkowe |
||
228 | * |
||
229 | * @var string |
||
230 | **/ |
||
231 | public $forma_prawna_typ_str; |
||
232 | /** |
||
233 | * gpw |
||
234 | * |
||
235 | * @var mixed |
||
236 | **/ |
||
237 | public $gpw; |
||
238 | /** |
||
239 | * gpw_spolka_id |
||
240 | * |
||
241 | * @var integer|null |
||
242 | **/ |
||
243 | public $gpw_spolka_id; |
||
244 | /** |
||
245 | * knf_ostrzezenie_id |
||
246 | * |
||
247 | * @var integer|null |
||
248 | **/ |
||
249 | public $knf_ostrzezenie_id; |
||
250 | /** |
||
251 | * liczba_akcji_wszystkich_emisji |
||
252 | * |
||
253 | * @var integer |
||
254 | **/ |
||
255 | public $liczba_akcji_wszystkich_emisji; |
||
256 | /** |
||
257 | * liczba_czlonkow_komitetu_zal |
||
258 | * |
||
259 | * @var integer |
||
260 | **/ |
||
261 | public $liczba_czlonkow_komitetu_zal; |
||
262 | /** |
||
263 | * liczba_dzialalnosci |
||
264 | * |
||
265 | * @var integer |
||
266 | **/ |
||
267 | public $liczba_dzialalnosci; |
||
268 | /** |
||
269 | * liczba_emisji_akcji |
||
270 | * |
||
271 | * @var integer |
||
272 | **/ |
||
273 | public $liczba_emisji_akcji; |
||
274 | /** |
||
275 | * liczba_jedynych_akcjonariuszy |
||
276 | * |
||
277 | * @var integer |
||
278 | **/ |
||
279 | public $liczba_jedynych_akcjonariuszy; |
||
280 | /** |
||
281 | * liczba_nadzorcow |
||
282 | * |
||
283 | * @var integer |
||
284 | **/ |
||
285 | public $liczba_nadzorcow; |
||
286 | /** |
||
287 | * liczba_oddzialow |
||
288 | * |
||
289 | * @var integer |
||
290 | **/ |
||
291 | public $liczba_oddzialow; |
||
292 | /** |
||
293 | * liczba_prokurentow |
||
294 | * |
||
295 | * @var integer |
||
296 | **/ |
||
297 | public $liczba_prokurentow; |
||
298 | /** |
||
299 | * liczba_reprezentantow |
||
300 | * |
||
301 | * @var integer |
||
302 | **/ |
||
303 | public $liczba_reprezentantow; |
||
304 | /** |
||
305 | * liczba_wspolnikow |
||
306 | * |
||
307 | * @var integer |
||
308 | **/ |
||
309 | public $liczba_wspolnikow; |
||
310 | /** |
||
311 | * liczba_zmian |
||
312 | * |
||
313 | * @var integer |
||
314 | **/ |
||
315 | public $liczba_zmian; |
||
316 | /** |
||
317 | * liczba_zmian_umow |
||
318 | * |
||
319 | * @var integer |
||
320 | **/ |
||
321 | public $liczba_zmian_umow; |
||
322 | /** |
||
323 | * nazwa_organu_nadzoru |
||
324 | * |
||
325 | * @var string |
||
326 | **/ |
||
327 | public $nazwa_organu_nadzoru; |
||
328 | /** |
||
329 | * nazwa_organu_reprezentacji |
||
330 | * |
||
331 | * @var string |
||
332 | **/ |
||
333 | public $nazwa_organu_reprezentacji; |
||
334 | /** |
||
335 | * nieprzedsiebiorca |
||
336 | * |
||
337 | * @var string |
||
338 | * @todo DO wyjasnienia znaczenie pola |
||
339 | **/ |
||
340 | public $nieprzedsiebiorca; |
||
341 | /** |
||
342 | * numer_wpisu |
||
343 | * |
||
344 | * @var string |
||
345 | **/ |
||
346 | public $numer_wpisu; |
||
347 | /** |
||
348 | * opp |
||
349 | * |
||
350 | * @var string|null |
||
351 | **/ |
||
352 | public $opp; |
||
353 | /** |
||
354 | * ostatni_wpis_id |
||
355 | * |
||
356 | * @var integer|null |
||
357 | **/ |
||
358 | public $ostatni_wpis_id; |
||
359 | /** |
||
360 | * oznaczenie_sadu |
||
361 | * |
||
362 | * @var string |
||
363 | **/ |
||
364 | public $oznaczenie_sadu; |
||
365 | /** |
||
366 | * rejestr |
||
367 | * |
||
368 | * @var string |
||
369 | **/ |
||
370 | public $rejestr; |
||
371 | /** |
||
372 | * rejestr_stowarzyszen |
||
373 | * |
||
374 | * @var string |
||
375 | **/ |
||
376 | public $rejestr_stowarzyszen; |
||
377 | /** |
||
378 | * sposob_reprezentacji |
||
379 | * |
||
380 | * @var string |
||
381 | **/ |
||
382 | public $sposob_reprezentacji; |
||
383 | /** |
||
384 | * sygnatura_akt |
||
385 | * |
||
386 | * @var string |
||
387 | **/ |
||
388 | public $sygnatura_akt; |
||
389 | /** |
||
390 | * twitter_account_id |
||
391 | * |
||
392 | * @var string |
||
393 | **/ |
||
394 | public $twitter_account_id; |
||
395 | /** |
||
396 | * umowa_spolki_cywilnej |
||
397 | * |
||
398 | * @var string|null |
||
399 | **/ |
||
400 | public $umowa_spolki_cywilnej; |
||
401 | /** |
||
402 | * wartosc_czesc_kapitalu_wplaconego |
||
403 | * |
||
404 | * @var integer |
||
405 | **/ |
||
406 | public $wartosc_czesc_kapitalu_wplaconego; |
||
407 | /** |
||
408 | * wartosc_kapital_docelowy |
||
409 | * |
||
410 | * @var integer |
||
411 | **/ |
||
412 | public $wartosc_kapital_docelowy; |
||
413 | /** |
||
414 | * wartosc_kapital_zakladowy |
||
415 | * |
||
416 | * @var integer |
||
417 | **/ |
||
418 | public $wartosc_kapital_zakladowy; |
||
419 | /** |
||
420 | * wartosc_nominalna_akcji |
||
421 | * |
||
422 | * @var integer |
||
423 | **/ |
||
424 | public $wartosc_nominalna_akcji; |
||
425 | /** |
||
426 | * wartosc_nominalna_podwyzszenia_kapitalu |
||
427 | * |
||
428 | * @var integer |
||
429 | **/ |
||
430 | public $wartosc_nominalna_podwyzszenia_kapitalu; |
||
431 | /** |
||
432 | * wczesniejsza_rejestracja_str |
||
433 | * |
||
434 | * @var string |
||
435 | **/ |
||
436 | public $wczesniejsza_rejestracja_str; |
||
437 | /** |
||
438 | * www |
||
439 | * |
||
440 | * @var string |
||
441 | **/ |
||
442 | public $www; |
||
443 | /** |
||
444 | * wykreslony |
||
445 | * |
||
446 | * @var string |
||
447 | **/ |
||
448 | public $wykreslony; |
||
449 | /** |
||
450 | * @var \mrcnpdlk\MojePanstwo\Model\KrsEntity\Pkd[] |
||
451 | */ |
||
452 | public $dzialalnosci = []; |
||
453 | /** |
||
454 | * @var \mrcnpdlk\MojePanstwo\Model\KrsEntity\Share[] |
||
455 | */ |
||
456 | public $emisje_akcji = []; |
||
457 | /** |
||
458 | * @var \mrcnpdlk\MojePanstwo\Model\KrsEntity\Companies[] |
||
459 | */ |
||
460 | public $firmy = []; |
||
461 | /** |
||
462 | * @var \mrcnpdlk\MojePanstwo\Model\KrsEntity\Person |
||
463 | */ |
||
464 | public $nadzor = []; |
||
465 | /** |
||
466 | * @var \mrcnpdlk\MojePanstwo\Model\KrsEntity\Person |
||
467 | */ |
||
468 | public $prokurenci = []; |
||
469 | /** |
||
470 | * @var \mrcnpdlk\MojePanstwo\Model\KrsEntity\Person |
||
471 | */ |
||
472 | public $reprezentacja = []; |
||
473 | /** |
||
474 | * @var \mrcnpdlk\MojePanstwo\Model\KrsEntity\Person |
||
475 | */ |
||
476 | public $komitetZalozycielski = []; |
||
477 | /** |
||
478 | * @var \mrcnpdlk\MojePanstwo\Model\KrsEntity\Partner |
||
479 | */ |
||
480 | public $wspolnicy = []; |
||
481 | /** |
||
482 | * @var \mrcnpdlk\MojePanstwo\Model\KrsEntity\Department |
||
483 | */ |
||
484 | public $oddzialy = []; |
||
485 | |||
486 | /** |
||
487 | * KrsEntity constructor. |
||
488 | * |
||
489 | * @param \stdClass|null $oData |
||
490 | * @param \stdClass|null $oLayers |
||
491 | * |
||
492 | * @throws \mrcnpdlk\MojePanstwo\Exception |
||
493 | */ |
||
494 | 1 | public function __construct(\stdClass $oData = null, \stdClass $oLayers = null) |
|
584 | } |
||
585 |
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.