From a492785f79b3d8430d1228402a74c7b67958b78c Mon Sep 17 00:00:00 2001 From: till Date: Tue, 27 May 2008 23:10:54 +0000 Subject: * refactored code git-svn-id: https://svn.roundcube.net/trunk@1443 208e9e7b-5314-0410-a742-e7e81cd9613c --- .../DisallowPEARIfElseElseifSniff.php | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) (limited to 'tools') 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 413778124..b174a3468 100644 --- a/tools/PHP_CodeSniffer/CodeSniffer/Standards/RoundCube/Sniffs/ControlStructures/DisallowPEARIfElseElseifSniff.php +++ b/tools/PHP_CodeSniffer/CodeSniffer/Standards/RoundCube/Sniffs/ControlStructures/DisallowPEARIfElseElseifSniff.php @@ -64,6 +64,8 @@ class RoundCube_Sniffs_ControlStructures_DisallowPEARIfElseElseifSniff implement */ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) { + static $_eol = array("\n", "\r", "\n\r"); + $tokens = $phpcsFile->getTokens(); $count = 0; $error = '} else {/} elseif (...) { not allowed.'; @@ -72,21 +74,9 @@ class RoundCube_Sniffs_ControlStructures_DisallowPEARIfElseElseifSniff implement $phpcsFile->addError($error, $stackPtr); return; } - while(true) { - $count++; - if ($tokens[$stackPtr - 1]['content'] === "\n") { - break; - } - if ($tokens[$stackPtr - 1]['content'] === "\r") { - break; - } - if ($tokens[$stackPtr - 1]['content'] === "\r\n") { - break; - } - if ($count > 3) { - $phpcsFile->addError($error . " - " . var_export($tokens[$stackPtr - 1]['content'], true), $stackPtr); - return; - } + if (!in_array($tokens[$stackPtr - 1]['content'], $_eol)) { + $phpcsFile->addError($error . " - " . var_export($tokens[$stackPtr - 1]['content'], true), $stackPtr); + return; } return; }//end process() -- cgit v1.2.3