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  | 
            ||
| 8 | class Question extends ActiveRecordModelExtender  | 
            ||
| 9 | { | 
            ||
| 10 | |||
| 11 | /**  | 
            ||
| 12 | * @var string $tableName name of the database table.  | 
            ||
| 13 | */  | 
            ||
| 14 | protected $tableName = "ramverk1_questions";  | 
            ||
| 15 | |||
| 16 | /**  | 
            ||
| 17 | * Columns in the table.  | 
            ||
| 18 | *  | 
            ||
| 19 | * @var integer $id primary key auto incremented.  | 
            ||
| 20 | */  | 
            ||
| 21 | public $id;  | 
            ||
| 22 | public $user;  | 
            ||
| 23 | |||
| 24 | public $title;  | 
            ||
| 25 | public $tags;  | 
            ||
| 26 | |||
| 27 | public $created;  | 
            ||
| 28 | public $status; # default is active  | 
            ||
| 29 | |||
| 30 | public $di;  | 
            ||
| 31 | |||
| 32 | |||
| 33 | /**  | 
            ||
| 34 | * Constructor injects with DI container.  | 
            ||
| 35 | *  | 
            ||
| 36 | */  | 
            ||
| 37 | public function __construct($di = null)  | 
            ||
| 41 | |||
| 42 | /**  | 
            ||
| 43 | * Returns post with markdown and gravatar  | 
            ||
| 44 | * @param string $sql  | 
            ||
| 45 | * @param array $param  | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 46 | *  | 
            ||
| 47 | * @return array  | 
            ||
| 48 | */  | 
            ||
| 49 | public function getQuestions($sql, $params)  | 
            ||
| 68 | |||
| 69 | /**  | 
            ||
| 70 | * Returns one question with it's own question text and other answers  | 
            ||
| 71 | * @param int $id  | 
            ||
| 72 | *  | 
            ||
| 73 | * @return object  | 
            ||
| 74 | */  | 
            ||
| 75 | public function getQuestion($id)  | 
            ||
| 94 | |||
| 95 | /**  | 
            ||
| 96 | * Returns array of tags, keys are name, value is the integer of how many.  | 
            ||
| 97 | *  | 
            ||
| 98 | * @return array  | 
            ||
| 99 | */  | 
            ||
| 100 | public function getPopularTags()  | 
            ||
| 117 | |||
| 118 | |||
| 119 | |||
| 120 | |||
| 121 | /**  | 
            ||
| 122 | * Check if a post belongs to user  | 
            ||
| 123 | *  | 
            ||
| 124 | *  | 
            ||
| 125 | * @return boolean  | 
            ||
| 126 | */  | 
            ||
| 127 | View Code Duplication | public function controlAuthority($name)  | 
            |
| 139 | }  | 
            ||
| 140 | 
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.
Consider the following example. The parameter
$irelandis not defined by the methodfinale(...).The most likely cause is that the parameter was changed, but the annotation was not.