summaryrefslogtreecommitdiff
path: root/tools/PHP_CodeSniffer/CodeSniffer/Standards/RoundCube/Sniffs/ControlStructures/DisallowPEARIfElseElseifSniff.php
diff options
context:
space:
mode:
authortill <till@208e9e7b-5314-0410-a742-e7e81cd9613c>2008-05-27 23:10:54 +0000
committertill <till@208e9e7b-5314-0410-a742-e7e81cd9613c>2008-05-27 23:10:54 +0000
commita492785f79b3d8430d1228402a74c7b67958b78c (patch)
tree9a5c8a58d2c42557f3a0d55b71343010d0d81fdf /tools/PHP_CodeSniffer/CodeSniffer/Standards/RoundCube/Sniffs/ControlStructures/DisallowPEARIfElseElseifSniff.php
parent6d52d3d810f8dc97c2d1452a1237fa0c6179a608 (diff)
* refactored code
git-svn-id: https://svn.roundcube.net/trunk@1443 208e9e7b-5314-0410-a742-e7e81cd9613c
Diffstat (limited to 'tools/PHP_CodeSniffer/CodeSniffer/Standards/RoundCube/Sniffs/ControlStructures/DisallowPEARIfElseElseifSniff.php')
-rw-r--r--tools/PHP_CodeSniffer/CodeSniffer/Standards/RoundCube/Sniffs/ControlStructures/DisallowPEARIfElseElseifSniff.php20
1 files changed, 5 insertions, 15 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 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()