1 | <?php |
||
23 | class PHPCompatibility_Sniffs_PHP_ForbiddenFunctionParametersWithSameNameSniff extends PHPCompatibility_Sniff |
||
24 | { |
||
25 | |||
26 | /** |
||
27 | * If true, an error will be thrown; otherwise a warning. |
||
28 | * |
||
29 | * @var bool |
||
30 | */ |
||
31 | protected $error = true; |
||
32 | |||
33 | /** |
||
34 | * Returns an array of tokens this test wants to listen for. |
||
35 | * |
||
36 | * @return array |
||
37 | */ |
||
38 | public function register() |
||
43 | |||
44 | /** |
||
45 | * Processes this test, when one of its tokens is encountered. |
||
46 | * |
||
47 | * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. |
||
48 | * @param int $stackPtr The position of the current token |
||
49 | * in the stack passed in $tokens. |
||
50 | * |
||
51 | * @return void |
||
52 | */ |
||
53 | public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) |
||
77 | |||
78 | }//end class |
||
79 |
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.