summaryrefslogtreecommitdiff
path: root/tools/PHP_CodeSniffer/CodeSniffer
diff options
context:
space:
mode:
authortill <till@208e9e7b-5314-0410-a742-e7e81cd9613c>2008-05-27 19:51:17 +0000
committertill <till@208e9e7b-5314-0410-a742-e7e81cd9613c>2008-05-27 19:51:17 +0000
commit043061efb5966bc4409f7b2d8ddfa5b3fb6c5b71 (patch)
treefda1aefa0627385a6b0b9a7639102de021511d84 /tools/PHP_CodeSniffer/CodeSniffer
parent2eb24aa5f712bf698f3c600e45f1529241399549 (diff)
* added check for new line before else/elseif
git-svn-id: https://svn.roundcube.net/trunk@1439 208e9e7b-5314-0410-a742-e7e81cd9613c
Diffstat (limited to 'tools/PHP_CodeSniffer/CodeSniffer')
-rw-r--r--tools/PHP_CodeSniffer/CodeSniffer/Standards/RoundCube/Sniffs/ControlStructures/DisallowPEARIfElseElseifSniff.php21
1 files changed, 18 insertions, 3 deletions
diff --git a/tools/PHP_CodeSniffer/CodeSniffer/Standards/RoundCube/Sniffs/ControlStructures/DisallowPEARIfElseElseifSniff.php b/tools/PHP_CodeSniffer/CodeSniffer/Standards/RoundCube/Sniffs/ControlStructures/DisallowPEARIfElseElseifSniff.php
index f13c2a117..377b21d46 100644
--- a/tools/PHP_CodeSniffer/CodeSniffer/Standards/RoundCube/Sniffs/ControlStructures/DisallowPEARIfElseElseifSniff.php
+++ b/tools/PHP_CodeSniffer/CodeSniffer/Standards/RoundCube/Sniffs/ControlStructures/DisallowPEARIfElseElseifSniff.php
@@ -65,9 +65,24 @@ class RoundCube_Sniffs_ControlStructures_DisallowPEARIfElseElseifSniff implement
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
{
$tokens = $phpcsFile->getTokens();
- // NOT YET DONE, WORKING ON IT
-
+ $count = 0;
+ while(true) {
+ $count++;
+ if ($tokens[$stackPtr - 1] === "\n") {
+ break;
+ }
+ if ($tokens[$stackPtr - 1] === "\r") {
+ break;
+ }
+ if ($tokens[$stackPtr - 1] === "\r\n") {
+ break;
+ }
+ if ($count > 3) {
+ $phpcsFile->addError('} else {/} elseif (...) { not allowed.', $stackPtr);
+ return;
+ }
+ }
+ return;
}//end process()
-
}//end class