| @@ 73-84 (lines=12) @@ | ||
| 70 | /* |
|
| 71 | * Check class constant assignments. |
|
| 72 | */ |
|
| 73 | case 'T_STRING': |
|
| 74 | // Walk back to check for the const keyword. |
|
| 75 | $constPtr = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($prevNonEmpty - 1), null, true, null, true); |
|
| 76 | if ($constPtr === false || $tokens[$constPtr]['code'] !== T_CONST) { |
|
| 77 | // Not a constant assignment. |
|
| 78 | return; |
|
| 79 | } |
|
| 80 | ||
| 81 | if ($this->isClassConstant($phpcsFile, $constPtr) === true) { |
|
| 82 | $this->throwError($phpcsFile, $stackPtr, 'const'); |
|
| 83 | } |
|
| 84 | return; |
|
| 85 | ||
| 86 | case 'T_VARIABLE': |
|
| 87 | /* |
|
| @@ 86-108 (lines=23) @@ | ||
| 83 | } |
|
| 84 | return; |
|
| 85 | ||
| 86 | case 'T_VARIABLE': |
|
| 87 | /* |
|
| 88 | * Check class property assignments. |
|
| 89 | */ |
|
| 90 | if ($this->isClassProperty($phpcsFile, $prevNonEmpty) === true) { |
|
| 91 | $this->throwError($phpcsFile, $stackPtr, 'property'); |
|
| 92 | } |
|
| 93 | ||
| 94 | /* |
|
| 95 | * Check static variable assignments. |
|
| 96 | */ |
|
| 97 | else { |
|
| 98 | // Walk back to check this is a static variable `static $var =`. |
|
| 99 | $staticPtr = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($prevNonEmpty - 1), null, true, null, true); |
|
| 100 | if ($staticPtr === false || $tokens[$staticPtr]['code'] !== T_STATIC) { |
|
| 101 | // Not a static variable assignment. |
|
| 102 | return; |
|
| 103 | } |
|
| 104 | ||
| 105 | // Still here ? Then we have a static variable assignment |
|
| 106 | $this->throwError($phpcsFile, $stackPtr, 'staticvar'); |
|
| 107 | } |
|
| 108 | return; |
|
| 109 | } |
|
| 110 | } |
|
| 111 | ||