| 1 | <?php |
||
| 21 | class PHPCompatibility_Sniffs_PHP_NewAnonymousClassesSniff extends PHPCompatibility_Sniff |
||
| 22 | { |
||
| 23 | /** |
||
| 24 | * Returns an array of tokens this test wants to listen for. |
||
| 25 | * |
||
| 26 | * @return array |
||
| 27 | */ |
||
| 28 | public function register() |
||
| 29 | { |
||
| 30 | if (version_compare(PHP_CodeSniffer::VERSION, '2.3.4') >= 0) { |
||
| 31 | return array(T_NEW); |
||
| 32 | } else { |
||
| 33 | return array(); |
||
| 34 | } |
||
| 35 | }//end register() |
||
| 36 | |||
| 37 | |||
| 38 | /** |
||
| 39 | * Processes this test, when one of its tokens is encountered. |
||
| 40 | * |
||
| 41 | * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. |
||
| 42 | * @param int $stackPtr The position of the current token in the |
||
| 43 | * stack passed in $tokens. |
||
| 44 | * |
||
| 45 | * @return void |
||
| 46 | */ |
||
| 47 | public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) |
||
| 62 | |||
| 63 | |||
| 64 | }//end class |
||
| 65 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.