Conditions | 4 |
Paths | 3 |
Total Lines | 17 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
43 | public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) |
||
44 | { |
||
45 | $tokens = $phpcsFile->getTokens(); |
||
|
|||
46 | |||
47 | $whitespace = $phpcsFile->findNext(T_WHITESPACE, $stackPtr + 1, $stackPtr + 2); |
||
48 | $class = $phpcsFile->findNext(T_ANON_CLASS, $stackPtr + 2, $stackPtr + 3); |
||
49 | if ($whitespace == false || $class == false) { |
||
50 | return false; |
||
51 | } |
||
52 | |||
53 | if ($this->supportsAbove('7.0')) { |
||
54 | return false; |
||
55 | } else { |
||
56 | $phpcsFile->addError('Anonymous classes are not supported in PHP 5.6 or earlier', $stackPtr); |
||
57 | } |
||
58 | |||
59 | }//end process() |
||
60 | |||
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.