From 043061efb5966bc4409f7b2d8ddfa5b3fb6c5b71 Mon Sep 17 00:00:00 2001 From: till Date: Tue, 27 May 2008 19:51:17 +0000 Subject: * added check for new line before else/elseif git-svn-id: https://svn.roundcube.net/trunk@1439 208e9e7b-5314-0410-a742-e7e81cd9613c --- .../DisallowPEARIfElseElseifSniff.php | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'tools/PHP_CodeSniffer/CodeSniffer/Standards/RoundCube/Sniffs') 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 -- cgit v1.2.3