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  | 
            ||
| 17 | class PHPCompatibility_Sniffs_PHP_NewHashAlgorithmsSniff extends PHPCompatibility_Sniff  | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 18 | { | 
            ||
| 19 | /**  | 
            ||
| 20 | * A list of new hash algorithms, not present in older versions.  | 
            ||
| 21 | *  | 
            ||
| 22 | * The array lists : version number with false (not present) or true (present).  | 
            ||
| 23 | * If's sufficient to list the first version where the hash algorithm appears.  | 
            ||
| 24 | *  | 
            ||
| 25 | * @var array(string => array(string => bool))  | 
            ||
| 26 | */  | 
            ||
| 27 | protected $newAlgorithms = array(  | 
            ||
| 28 | 'md2' => array(  | 
            ||
| 29 | '5.2' => false,  | 
            ||
| 30 | '5.3' => true,  | 
            ||
| 31 | ),  | 
            ||
| 32 | 'ripemd256' => array(  | 
            ||
| 33 | '5.2' => false,  | 
            ||
| 34 | '5.3' => true,  | 
            ||
| 35 | ),  | 
            ||
| 36 | 'ripemd320' => array(  | 
            ||
| 37 | '5.2' => false,  | 
            ||
| 38 | '5.3' => true,  | 
            ||
| 39 | ),  | 
            ||
| 40 | 'salsa10' => array(  | 
            ||
| 41 | '5.2' => false,  | 
            ||
| 42 | '5.3' => true,  | 
            ||
| 43 | ),  | 
            ||
| 44 | 'salsa20' => array(  | 
            ||
| 45 | '5.2' => false,  | 
            ||
| 46 | '5.3' => true,  | 
            ||
| 47 | ),  | 
            ||
| 48 | 'snefru256' => array(  | 
            ||
| 49 | '5.2' => false,  | 
            ||
| 50 | '5.3' => true,  | 
            ||
| 51 | ),  | 
            ||
| 52 | 'sha224' => array(  | 
            ||
| 53 | '5.2' => false,  | 
            ||
| 54 | '5.3' => true,  | 
            ||
| 55 | ),  | 
            ||
| 56 | 'joaat' => array(  | 
            ||
| 57 | '5.3' => false,  | 
            ||
| 58 | '5.4' => true,  | 
            ||
| 59 | ),  | 
            ||
| 60 | 'fnv132' => array(  | 
            ||
| 61 | '5.3' => false,  | 
            ||
| 62 | '5.4' => true,  | 
            ||
| 63 | ),  | 
            ||
| 64 | 'fnv164' => array(  | 
            ||
| 65 | '5.3' => false,  | 
            ||
| 66 | '5.4' => true,  | 
            ||
| 67 | ),  | 
            ||
| 68 | 'gost-crypto' => array(  | 
            ||
| 69 | '5.5' => false,  | 
            ||
| 70 | '5.6' => true,  | 
            ||
| 71 | ),  | 
            ||
| 72 | );  | 
            ||
| 73 | |||
| 74 | |||
| 75 | /**  | 
            ||
| 76 | * Returns an array of tokens this test wants to listen for.  | 
            ||
| 77 | *  | 
            ||
| 78 | * @return array  | 
            ||
| 79 | */  | 
            ||
| 80 | public function register()  | 
            ||
| 85 | |||
| 86 | |||
| 87 | /**  | 
            ||
| 88 | * Processes this test, when one of its tokens is encountered.  | 
            ||
| 89 | *  | 
            ||
| 90 | * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.  | 
            ||
| 91 | * @param int $stackPtr The position of the current token in the  | 
            ||
| 92 | * stack passed in $tokens.  | 
            ||
| 93 | *  | 
            ||
| 94 | * @return void  | 
            ||
| 95 | */  | 
            ||
| 96 | View Code Duplication | public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)  | 
            |
| 116 | |||
| 117 | |||
| 118 | /**  | 
            ||
| 119 | * Retrieve the relevant (version) information for the error message.  | 
            ||
| 120 | *  | 
            ||
| 121 | * @param string $algorithm The name of the algorithm.  | 
            ||
| 122 | *  | 
            ||
| 123 | * @return array  | 
            ||
| 124 | */  | 
            ||
| 125 | protected function getErrorInfo($algorithm)  | 
            ||
| 140 | |||
| 141 | |||
| 142 | /**  | 
            ||
| 143 | * Generates the error or warning for this sniff.  | 
            ||
| 144 | *  | 
            ||
| 145 | * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.  | 
            ||
| 146 | * @param int $stackPtr The position of the function  | 
            ||
| 147 | * in the token array.  | 
            ||
| 148 | * @param string $algorithm The name of the algorithm.  | 
            ||
| 149 | * @param array $errorInfo Array with details about the versions  | 
            ||
| 150 | * in which the algorithm was deprecated  | 
            ||
| 151 | * and/or removed.  | 
            ||
| 152 | *  | 
            ||
| 153 | * @return void  | 
            ||
| 154 | */  | 
            ||
| 155 | protected function addError($phpcsFile, $stackPtr, $algorithm, $errorInfo)  | 
            ||
| 167 | |||
| 168 | }//end class  | 
            ||
| 169 | 
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.