| @@ 85-101 (lines=17) @@ | ||
| 82 | * |
|
| 83 | * @return int |
|
| 84 | */ |
|
| 85 | public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) |
|
| 86 | { |
|
| 87 | $tokens = $phpcsFile->getTokens(); |
|
| 88 | ||
| 89 | // Ignore assignments used in a condition, like an IF or FOR. |
|
| 90 | if (isset($tokens[$stackPtr]['nested_parenthesis']) === true) { |
|
| 91 | foreach ($tokens[$stackPtr]['nested_parenthesis'] as $start => $end) { |
|
| 92 | if (isset($tokens[$start]['parenthesis_owner']) === true) { |
|
| 93 | return; |
|
| 94 | } |
|
| 95 | } |
|
| 96 | } |
|
| 97 | ||
| 98 | $lastAssign = $this->checkAlignment($phpcsFile, $stackPtr); |
|
| 99 | return ($lastAssign + 1); |
|
| 100 | ||
| 101 | }//end process() |
|
| 102 | ||
| 103 | ||
| 104 | /** |
|
| @@ 53-69 (lines=17) @@ | ||
| 50 | * |
|
| 51 | * @return void |
|
| 52 | */ |
|
| 53 | public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) |
|
| 54 | { |
|
| 55 | $tokens = $phpcsFile->getTokens(); |
|
| 56 | if (isset($tokens[$stackPtr]['nested_parenthesis']) === true) { |
|
| 57 | $foundOwner = false; |
|
| 58 | foreach ($tokens[$stackPtr]['nested_parenthesis'] as $open => $close) { |
|
| 59 | if (isset($tokens[$open]['parenthesis_owner']) === true) { |
|
| 60 | // Any owner means we are not just a simple statement. |
|
| 61 | return; |
|
| 62 | } |
|
| 63 | } |
|
| 64 | } |
|
| 65 | ||
| 66 | $error = 'Boolean operators are not allowed outside of control structure conditions'; |
|
| 67 | $phpcsFile->addError($error, $stackPtr, 'Found'); |
|
| 68 | ||
| 69 | }//end process() |
|
| 70 | ||
| 71 | ||
| 72 | }//end class |
|