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 |
||
| 7 | class AdminInscription extends Inscription { |
||
| 8 | protected $acces_administration; |
||
| 9 | protected $id_liste_droit_acces; |
||
| 10 | |||
| 11 | |||
| 12 | //-------------------------- CONSTRUCTEUR ----------------------------------------------------------------------------// |
||
| 13 | //-------------------------- FIN CONSTRUCTEUR ----------------------------------------------------------------------------// |
||
| 14 | |||
| 15 | |||
| 16 | //-------------------------- GETTER ----------------------------------------------------------------------------// |
||
| 17 | public function getAccesAdministration() { |
||
| 23 | //-------------------------- FIN GETTER ----------------------------------------------------------------------------// |
||
| 24 | |||
| 25 | |||
| 26 | //-------------------------- SETTER ----------------------------------------------------------------------------// |
||
| 27 | /** |
||
| 28 | * vient de la partie admin n du site pages gestion-comptes/creer-utilisateur |
||
| 29 | * @param $value |
||
| 30 | * @param null $required |
||
|
|
|||
| 31 | * @return bool |
||
| 32 | */ |
||
| 33 | View Code Duplication | protected function setVerifAccesAdministration($value) { |
|
| 49 | |||
| 50 | /** |
||
| 51 | * vient de la partie admin du site pages gestion-comptes/creer-utilisateur |
||
| 52 | * @param $value |
||
| 53 | * @param null $required |
||
| 54 | * @return bool |
||
| 55 | */ |
||
| 56 | View Code Duplication | protected function setVerifListeDroitAcces($value) { |
|
| 72 | |||
| 73 | /** |
||
| 74 | * si tous les test concernant le formulaire sont passés on inscrit le user |
||
| 75 | */ |
||
| 76 | public function setInscrireUtilisateur() { |
||
| 97 | //-------------------------- FIN SETTER ----------------------------------------------------------------------------// |
||
| 98 | } |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.