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 InMemoryStorage implements Storage  | 
            ||
| 20 | { | 
            ||
| 21 | /**  | 
            ||
| 22 | * The data collection.  | 
            ||
| 23 | *  | 
            ||
| 24 | * @var array  | 
            ||
| 25 | */  | 
            ||
| 26 | private $data;  | 
            ||
| 27 | |||
| 28 | /**  | 
            ||
| 29 | * Constructor.  | 
            ||
| 30 | *  | 
            ||
| 31 | * @param mixed $data The data  | 
            ||
| 32 | */  | 
            ||
| 33 | public function __construct($data)  | 
            ||
| 37 | |||
| 38 | /**  | 
            ||
| 39 |      * {@inheritdoc} | 
            ||
| 40 | */  | 
            ||
| 41 | View Code Duplication | public function findAll($limit, $offset)  | 
            |
| 54 | |||
| 55 | /**  | 
            ||
| 56 |      * {@inheritdoc} | 
            ||
| 57 | */  | 
            ||
| 58 | View Code Duplication | public function query(array $criteria, $limit, $offset)  | 
            |
| 76 | |||
| 77 | /**  | 
            ||
| 78 |      * {@inheritdoc} | 
            ||
| 79 | */  | 
            ||
| 80 | public function properties()  | 
            ||
| 88 | |||
| 89 | /**  | 
            ||
| 90 |      * {@inheritdoc} | 
            ||
| 91 | */  | 
            ||
| 92 | public function size()  | 
            ||
| 96 | |||
| 97 | /**  | 
            ||
| 98 | * Paginates the given collection of data.  | 
            ||
| 99 | *  | 
            ||
| 100 | * @param array $data The collection data  | 
            ||
| 101 | * @param int $limit Logs per page  | 
            ||
| 102 | * @param int $offset The number of the page  | 
            ||
| 103 | *  | 
            ||
| 104 | * @return array  | 
            ||
| 105 | */  | 
            ||
| 106 | private function paginate($data, $limit, $offset)  | 
            ||
| 110 | |||
| 111 | /**  | 
            ||
| 112 | * Compares the given two items.  | 
            ||
| 113 | *  | 
            ||
| 114 | * @param mixed $item1 The first item  | 
            ||
| 115 | * @param mixed $item2 The second item  | 
            ||
| 116 | *  | 
            ||
| 117 | * @return int  | 
            ||
| 118 | */  | 
            ||
| 119 | View Code Duplication | private function sort($item1, $item2)  | 
            |
| 137 | }  | 
            ||
| 138 | 
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..