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() |
||
32 | |||
33 | |||
34 | /** |
||
35 | * Processes this test, when one of its tokens is encountered. |
||
36 | * |
||
37 | * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. |
||
38 | * @param int $stackPtr The position of the current token in the |
||
39 | * stack passed in $tokens. |
||
40 | * |
||
41 | * @return void |
||
42 | */ |
||
43 | public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) |
||
60 | |||
61 | |||
62 | }//end class |
||
63 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.