Completed
Branch master (205409)
by Timothy
02:36
created
build/CodeIgniter/Sniffs/Files/ByteOrderMarkSniff.php 1 patch
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -32,67 +32,67 @@
 block discarded – undo
32 32
 
33 33
 class ByteOrderMarkSniff implements Sniff
34 34
 {
35
-    /**
36
-     * Returns an array of tokens this test wants to listen for.
37
-     *
38
-     * @return array
39
-     */
40
-    public function register()
41
-    {
42
-        return array( T_OPEN_TAG );
43
-    }//end register()
35
+	/**
36
+	 * Returns an array of tokens this test wants to listen for.
37
+	 *
38
+	 * @return array
39
+	 */
40
+	public function register()
41
+	{
42
+		return array( T_OPEN_TAG );
43
+	}//end register()
44 44
 
45
-    /**
46
-     * List of supported BOM definitions.
47
-     *
48
-     * Use encoding names as keys and hex BOM representations as values.
49
-     *
50
-     * @return array
51
-     */
52
-    protected function getBomDefinitions()
53
-    {
54
-        return array(
55
-            'UTF-8'       => 'efbbbf',
56
-            'UTF-16 (BE)' => 'feff',
57
-            'UTF-16 (LE)' => 'fffe',
58
-            'UTF-32 (BE)' => '0000feff',
59
-            'UTF-32 (LE)' => 'fffe0000'
60
-        );
61
-    }//end getBomDefinitions()
45
+	/**
46
+	 * List of supported BOM definitions.
47
+	 *
48
+	 * Use encoding names as keys and hex BOM representations as values.
49
+	 *
50
+	 * @return array
51
+	 */
52
+	protected function getBomDefinitions()
53
+	{
54
+		return array(
55
+			'UTF-8'       => 'efbbbf',
56
+			'UTF-16 (BE)' => 'feff',
57
+			'UTF-16 (LE)' => 'fffe',
58
+			'UTF-32 (BE)' => '0000feff',
59
+			'UTF-32 (LE)' => 'fffe0000'
60
+		);
61
+	}//end getBomDefinitions()
62 62
 
63
-    /**
64
-     * Process tokens.
65
-     *
66
-     * Actually, only proceed when we're at index 0, this should be the only case
67
-     * that will contain BOM. Then check if BOM definition matches what
68
-     * we've found as file's inline HTML. Inline HTML could be longer than just BOM
69
-     * so make sure you test as much as needed.
70
-     *
71
-     * @param File $phpcsFile The current file being scanned.
72
-     * @param int                  $stackPtr  The position of the current token
73
-     *                                        in the stack passed in $tokens.
74
-     *
75
-     * @return void
76
-     */
77
-    public function process(File $phpcsFile, $stackPtr )
78
-    {
79
-        // We are only interested if this is the first open tag.
80
-        if ($stackPtr !== 0) {
81
-            if ($phpcsFile->findPrevious(T_OPEN_TAG, ($stackPtr - 1)) !== false) {
82
-                return;
83
-            }
84
-        }
63
+	/**
64
+	 * Process tokens.
65
+	 *
66
+	 * Actually, only proceed when we're at index 0, this should be the only case
67
+	 * that will contain BOM. Then check if BOM definition matches what
68
+	 * we've found as file's inline HTML. Inline HTML could be longer than just BOM
69
+	 * so make sure you test as much as needed.
70
+	 *
71
+	 * @param File $phpcsFile The current file being scanned.
72
+	 * @param int                  $stackPtr  The position of the current token
73
+	 *                                        in the stack passed in $tokens.
74
+	 *
75
+	 * @return void
76
+	 */
77
+	public function process(File $phpcsFile, $stackPtr )
78
+	{
79
+		// We are only interested if this is the first open tag.
80
+		if ($stackPtr !== 0) {
81
+			if ($phpcsFile->findPrevious(T_OPEN_TAG, ($stackPtr - 1)) !== false) {
82
+				return;
83
+			}
84
+		}
85 85
 
86
-        $tokens = $phpcsFile->getTokens();
87
-        $fileStartString = $tokens[0]['content'];
88
-        foreach ($this->getBomDefinitions() as $bomName => $expectedBomHex) {
89
-            $bomByteLength = strlen($expectedBomHex) / 2;
90
-            $fileStartHex = bin2hex(substr($fileStartString, 0, $bomByteLength));
91
-            if ($fileStartHex === $expectedBomHex) {
92
-                $error = "File contains a $bomName byte order mark (BOM).";
93
-                $phpcsFile->addError($error, $stackPtr);
94
-                break;
95
-            }
96
-        }
97
-    }//end process()
86
+		$tokens = $phpcsFile->getTokens();
87
+		$fileStartString = $tokens[0]['content'];
88
+		foreach ($this->getBomDefinitions() as $bomName => $expectedBomHex) {
89
+			$bomByteLength = strlen($expectedBomHex) / 2;
90
+			$fileStartHex = bin2hex(substr($fileStartString, 0, $bomByteLength));
91
+			if ($fileStartHex === $expectedBomHex) {
92
+				$error = "File contains a $bomName byte order mark (BOM).";
93
+				$phpcsFile->addError($error, $stackPtr);
94
+				break;
95
+			}
96
+		}
97
+	}//end process()
98 98
 }
Please login to merge, or discard this patch.
build/CodeIgniter/Sniffs/WhiteSpace/ElseOnNewLineSniff.php 1 patch
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -33,48 +33,48 @@
 block discarded – undo
33 33
 class ElseOnNewLineSniff implements Sniff
34 34
 {
35 35
 
36
-    /**
37
-     * Returns an array of tokens this test wants to listen for.
38
-     *
39
-     * @return array
40
-     */
41
-    public function register()
42
-    {
43
-        return array(
44
-            T_ELSE,
45
-            T_ELSEIF,
46
-        );
47
-    }//end register()
36
+	/**
37
+	 * Returns an array of tokens this test wants to listen for.
38
+	 *
39
+	 * @return array
40
+	 */
41
+	public function register()
42
+	{
43
+		return array(
44
+			T_ELSE,
45
+			T_ELSEIF,
46
+		);
47
+	}//end register()
48 48
 
49 49
 
50
-    /**
51
-     * Processes this test, when one of its tokens is encountered.
52
-     *
53
-     * @param File $phpcsFile The current file being scanned.
54
-     * @param int                  $stackPtr  The position of the current token
55
-     *                                        in the stack passed in $tokens.
56
-     *
57
-     * @return void
58
-     */
59
-    public function process(File $phpcsFile, $stackPtr)
60
-    {
61
-        $tokens = $phpcsFile->getTokens();
50
+	/**
51
+	 * Processes this test, when one of its tokens is encountered.
52
+	 *
53
+	 * @param File $phpcsFile The current file being scanned.
54
+	 * @param int                  $stackPtr  The position of the current token
55
+	 *                                        in the stack passed in $tokens.
56
+	 *
57
+	 * @return void
58
+	 */
59
+	public function process(File $phpcsFile, $stackPtr)
60
+	{
61
+		$tokens = $phpcsFile->getTokens();
62 62
 
63
-        $else_token = $tokens[$stackPtr];
64
-        $previous_non_blank_token_ptr = $phpcsFile->findPrevious(array(T_WHITESPACE), $stackPtr - 1, null, true);
63
+		$else_token = $tokens[$stackPtr];
64
+		$previous_non_blank_token_ptr = $phpcsFile->findPrevious(array(T_WHITESPACE), $stackPtr - 1, null, true);
65 65
 
66
-        if (false === $previous_non_blank_token_ptr) {
67
-        	// else is no preceded with any symbol, but it is not the responsibility of this sniff.
68
-        	return;
69
-        }
66
+		if (false === $previous_non_blank_token_ptr) {
67
+			// else is no preceded with any symbol, but it is not the responsibility of this sniff.
68
+			return;
69
+		}
70 70
 
71
-        $previous_non_blank_token = $tokens[$previous_non_blank_token_ptr];
72
-        if ($previous_non_blank_token['line'] === $else_token['line']) {
73
-            $error = '"' . $else_token['content'] . '" should be on a new line.';
74
-            $phpcsFile->addError($error, $stackPtr);
75
-        }
71
+		$previous_non_blank_token = $tokens[$previous_non_blank_token_ptr];
72
+		if ($previous_non_blank_token['line'] === $else_token['line']) {
73
+			$error = '"' . $else_token['content'] . '" should be on a new line.';
74
+			$phpcsFile->addError($error, $stackPtr);
75
+		}
76 76
 
77
-    }//end process()
77
+	}//end process()
78 78
 
79 79
 
80 80
 }//end class
Please login to merge, or discard this patch.
CodeIgniter/Sniffs/WhiteSpace/DisallowWitheSpaceAroundPhpTagsSniff.php 1 patch
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -34,60 +34,60 @@
 block discarded – undo
34 34
 class DisallowWitheSpaceAroundPhpTagsSniff implements Sniff
35 35
 {
36 36
 
37
-    /**
38
-     * Returns an array of tokens this test wants to listen for.
39
-     *
40
-     * @return array
41
-     */
42
-    public function register()
43
-    {
44
-        return array(
45
-                T_OPEN_TAG,
46
-                T_CLOSE_TAG
47
-               );
37
+	/**
38
+	 * Returns an array of tokens this test wants to listen for.
39
+	 *
40
+	 * @return array
41
+	 */
42
+	public function register()
43
+	{
44
+		return array(
45
+				T_OPEN_TAG,
46
+				T_CLOSE_TAG
47
+			   );
48 48
 
49
-    }//end register()
49
+	}//end register()
50 50
 
51 51
 
52
-    /**
53
-     * Processes this test, when one of its tokens is encountered.
54
-     *
55
-     * @param File $phpcsFile The current file being scanned.
56
-     * @param int                  $stackPtr  The position of the current token
57
-     *                                        in the stack passed in $tokens.
58
-     *
59
-     * @return void
60
-     */
61
-    public function process(File $phpcsFile, $stackPtr)
62
-    {
63
-        $tokens = $phpcsFile->getTokens();
52
+	/**
53
+	 * Processes this test, when one of its tokens is encountered.
54
+	 *
55
+	 * @param File $phpcsFile The current file being scanned.
56
+	 * @param int                  $stackPtr  The position of the current token
57
+	 *                                        in the stack passed in $tokens.
58
+	 *
59
+	 * @return void
60
+	 */
61
+	public function process(File $phpcsFile, $stackPtr)
62
+	{
63
+		$tokens = $phpcsFile->getTokens();
64 64
 
65
-        $php_tag_token = $tokens[$stackPtr];
66
-        $php_tag_code = $php_tag_token['code'];
65
+		$php_tag_token = $tokens[$stackPtr];
66
+		$php_tag_code = $php_tag_token['code'];
67 67
 
68
-        if (T_OPEN_TAG === $php_tag_code) {
69
-            // opening php tag should be the first token.
70
-            // any whitespace beofre an opening php tag is tokenized
71
-            // as T_INLINE_HTML, so no need to check the content of the token.
72
-            $isFirst = 0 === $stackPtr;
73
-            if ( ! $isFirst) {
74
-                $error = 'Any char before the opening PHP tag is prohibited. Please remove newline or indentation before the opening PHP tag.';
75
-                $phpcsFile->addError($error, $stackPtr);
76
-            }
77
-        } else {
78
-            // if (T_CLOSE_TAG === $php_tag_code)
79
-            // closing php tag should be the last token
80
-            // and it must not contain any whitespace.
81
-            $php_tag_string = $php_tag_token['content'];
82
-            $isLast = count($tokens) - 1 === $stackPtr;
83
-            // both of the two closing php tags contains 2 chars exactly.
84
-            $containsEndTagOnly = strlen($php_tag_string) > 2;
85
-            if ( ! $isLast || ! $containsEndTagOnly ) {
86
-                $error = 'Any char after the closing PHP tag is prohibited. Please removes newline or spaces after the closing PHP tag.';
87
-                $phpcsFile->addError($error, $stackPtr);
88
-            }
89
-        }
90
-    }//end process()
68
+		if (T_OPEN_TAG === $php_tag_code) {
69
+			// opening php tag should be the first token.
70
+			// any whitespace beofre an opening php tag is tokenized
71
+			// as T_INLINE_HTML, so no need to check the content of the token.
72
+			$isFirst = 0 === $stackPtr;
73
+			if ( ! $isFirst) {
74
+				$error = 'Any char before the opening PHP tag is prohibited. Please remove newline or indentation before the opening PHP tag.';
75
+				$phpcsFile->addError($error, $stackPtr);
76
+			}
77
+		} else {
78
+			// if (T_CLOSE_TAG === $php_tag_code)
79
+			// closing php tag should be the last token
80
+			// and it must not contain any whitespace.
81
+			$php_tag_string = $php_tag_token['content'];
82
+			$isLast = count($tokens) - 1 === $stackPtr;
83
+			// both of the two closing php tags contains 2 chars exactly.
84
+			$containsEndTagOnly = strlen($php_tag_string) > 2;
85
+			if ( ! $isLast || ! $containsEndTagOnly ) {
86
+				$error = 'Any char after the closing PHP tag is prohibited. Please removes newline or spaces after the closing PHP tag.';
87
+				$phpcsFile->addError($error, $stackPtr);
88
+			}
89
+		}
90
+	}//end process()
91 91
 
92 92
 
93 93
 }//end class
Please login to merge, or discard this patch.
build/CodeIgniter/Sniffs/WhiteSpace/LogicalNotSpacingSniff.php 1 patch
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -33,41 +33,41 @@
 block discarded – undo
33 33
 class LogicalNotSpacingSniff implements Sniff
34 34
 {
35 35
 
36
-    /**
37
-     * Returns an array of tokens this test wants to listen for.
38
-     *
39
-     * @return array
40
-     */
41
-    public function register()
42
-    {
43
-        return array(
44
-            T_BOOLEAN_NOT,
45
-        );
46
-    }//end register()
36
+	/**
37
+	 * Returns an array of tokens this test wants to listen for.
38
+	 *
39
+	 * @return array
40
+	 */
41
+	public function register()
42
+	{
43
+		return array(
44
+			T_BOOLEAN_NOT,
45
+		);
46
+	}//end register()
47 47
 
48 48
 
49
-    /**
50
-     * Processes this test, when one of its tokens is encountered.
51
-     *
52
-     * @param File $phpcsFile The current file being scanned.
53
-     * @param int                  $stackPtr  The position of the current token
54
-     *                                        in the stack passed in $tokens.
55
-     *
56
-     * @return void
57
-     */
58
-    public function process(File $phpcsFile, $stackPtr)
59
-    {
60
-        $tokens = $phpcsFile->getTokens();
49
+	/**
50
+	 * Processes this test, when one of its tokens is encountered.
51
+	 *
52
+	 * @param File $phpcsFile The current file being scanned.
53
+	 * @param int                  $stackPtr  The position of the current token
54
+	 *                                        in the stack passed in $tokens.
55
+	 *
56
+	 * @return void
57
+	 */
58
+	public function process(File $phpcsFile, $stackPtr)
59
+	{
60
+		$tokens = $phpcsFile->getTokens();
61 61
 
62
-        $operator_token = $tokens[$stackPtr];
62
+		$operator_token = $tokens[$stackPtr];
63 63
 
64
-        $previous_token = $tokens[$stackPtr - 1];
65
-        $next_token = $tokens[$stackPtr + 1];
66
-        if (T_WHITESPACE !== $previous_token['code'] || T_WHITESPACE !== $next_token['code']) {
67
-            $error = 'Logical operator ! should always be preceded and followed with a whitespace.';
68
-            $phpcsFile->addError($error, $stackPtr);
69
-        }
70
-    }//end process()
64
+		$previous_token = $tokens[$stackPtr - 1];
65
+		$next_token = $tokens[$stackPtr + 1];
66
+		if (T_WHITESPACE !== $previous_token['code'] || T_WHITESPACE !== $next_token['code']) {
67
+			$error = 'Logical operator ! should always be preceded and followed with a whitespace.';
68
+			$phpcsFile->addError($error, $stackPtr);
69
+		}
70
+	}//end process()
71 71
 
72 72
 
73 73
 }//end class
Please login to merge, or discard this patch.
build/CodeIgniter/Sniffs/WhiteSpace/DisallowSpaceIndentSniff.php 1 patch
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -33,53 +33,53 @@
 block discarded – undo
33 33
 class DisallowSpaceIndentSniff implements Sniff
34 34
 {
35 35
 
36
-    /**
37
-     * A list of tokenizers this sniff supports.
38
-     *
39
-     * @var array
40
-     */
41
-    public $supportedTokenizers = array(
42
-                                   'PHP',
43
-                                   'JS',
44
-                                   'CSS',
45
-                                  );
36
+	/**
37
+	 * A list of tokenizers this sniff supports.
38
+	 *
39
+	 * @var array
40
+	 */
41
+	public $supportedTokenizers = array(
42
+								   'PHP',
43
+								   'JS',
44
+								   'CSS',
45
+								  );
46 46
 
47 47
 
48
-    /**
49
-     * Returns an array of tokens this test wants to listen for.
50
-     *
51
-     * @return array
52
-     */
53
-    public function register()
54
-    {
55
-        return array(T_WHITESPACE);
56
-    }//end register()
48
+	/**
49
+	 * Returns an array of tokens this test wants to listen for.
50
+	 *
51
+	 * @return array
52
+	 */
53
+	public function register()
54
+	{
55
+		return array(T_WHITESPACE);
56
+	}//end register()
57 57
 
58 58
 
59
-    /**
60
-     * Processes this test, when one of its tokens is encountered.
61
-     *
62
-     * @param File $phpcsFile All the tokens found in the document.
63
-     * @param int                  $stackPtr  The position of the current token
64
-     *                                        in the stack passed in $tokens.
65
-     *
66
-     * @return void
67
-     */
68
-    public function process(File $phpcsFile, $stackPtr)
69
-    {
70
-        $tokens = $phpcsFile->getTokens();
59
+	/**
60
+	 * Processes this test, when one of its tokens is encountered.
61
+	 *
62
+	 * @param File $phpcsFile All the tokens found in the document.
63
+	 * @param int                  $stackPtr  The position of the current token
64
+	 *                                        in the stack passed in $tokens.
65
+	 *
66
+	 * @return void
67
+	 */
68
+	public function process(File $phpcsFile, $stackPtr)
69
+	{
70
+		$tokens = $phpcsFile->getTokens();
71 71
 
72
-        // Make sure this is whitespace used for indentation.
73
-        $line = $tokens[$stackPtr]['line'];
74
-        if ($stackPtr > 0 && $tokens[($stackPtr - 1)]['line'] === $line) {
75
-            return;
76
-        }
72
+		// Make sure this is whitespace used for indentation.
73
+		$line = $tokens[$stackPtr]['line'];
74
+		if ($stackPtr > 0 && $tokens[($stackPtr - 1)]['line'] === $line) {
75
+			return;
76
+		}
77 77
 
78
-        if (strpos($tokens[$stackPtr]['content'], " ") !== false) {
79
-            $error = 'Tabs must be used to indent lines; spaces are not allowed for code indentation';
80
-            $phpcsFile->addError($error, $stackPtr, 'SpacesUsedForIndentation');
81
-        }
82
-    }//end process()
78
+		if (strpos($tokens[$stackPtr]['content'], " ") !== false) {
79
+			$error = 'Tabs must be used to indent lines; spaces are not allowed for code indentation';
80
+			$phpcsFile->addError($error, $stackPtr, 'SpacesUsedForIndentation');
81
+		}
82
+	}//end process()
83 83
 
84 84
 
85 85
 }//end class
Please login to merge, or discard this patch.
build/CodeIgniter/Sniffs/Strings/DoubleQuoteUsageSniff.php 1 patch
Indentation   +123 added lines, -123 removed lines patch added patch discarded remove patch
@@ -327,137 +327,137 @@
 block discarded – undo
327 327
  */
328 328
 class DoubleQuoteUsageSniff extends VariableUsageSniff
329 329
 {
330
-    /**
331
-     * Returns an array of tokens this test wants to listen for.
332
-     *
333
-     * @return array
334
-     */
335
-    public function register()
336
-    {
337
-        return array(
338
-            T_DOUBLE_QUOTED_STRING,
339
-            T_CONSTANT_ENCAPSED_STRING,
340
-        );
341
-    }//end register()
330
+	/**
331
+	 * Returns an array of tokens this test wants to listen for.
332
+	 *
333
+	 * @return array
334
+	 */
335
+	public function register()
336
+	{
337
+		return array(
338
+			T_DOUBLE_QUOTED_STRING,
339
+			T_CONSTANT_ENCAPSED_STRING,
340
+		);
341
+	}//end register()
342 342
 
343
-    /**
344
-     * Processes this test, when one of its tokens is encountered.
345
-     *
346
-     * @param File $phpcsFile The current file being scanned.
347
-     * @param int                  $stackPtr  The position of the current token
348
-     *                                        in the stack passed in $tokens.
349
-     *
350
-     * @return void
351
-     */
352
-    public function process(File $phpcsFile, $stackPtr)
353
-    {
354
-        // no variable are in the string from here
355
-        $tokens = $phpcsFile->getTokens();
356
-        $qtString = $tokens[$stackPtr]['content'];
357
-        // makes sure that it is about a double quote string,
358
-        // since variables are not parsed out of double quoted string
359
-        $open_qt_str = substr($qtString, 0, 1);
343
+	/**
344
+	 * Processes this test, when one of its tokens is encountered.
345
+	 *
346
+	 * @param File $phpcsFile The current file being scanned.
347
+	 * @param int                  $stackPtr  The position of the current token
348
+	 *                                        in the stack passed in $tokens.
349
+	 *
350
+	 * @return void
351
+	 */
352
+	public function process(File $phpcsFile, $stackPtr)
353
+	{
354
+		// no variable are in the string from here
355
+		$tokens = $phpcsFile->getTokens();
356
+		$qtString = $tokens[$stackPtr]['content'];
357
+		// makes sure that it is about a double quote string,
358
+		// since variables are not parsed out of double quoted string
359
+		$open_qt_str = substr($qtString, 0, 1);
360 360
 
361
-        // clean the enclosing quotes
362
-        $qtString = substr($qtString, 1, strlen($qtString) - 1 - 1);
361
+		// clean the enclosing quotes
362
+		$qtString = substr($qtString, 1, strlen($qtString) - 1 - 1);
363 363
 
364
-        if (0 === strcmp($open_qt_str, '"')) {
365
-            $this->processDoubleQuotedString($phpcsFile, $stackPtr, $qtString);
366
-        } else if (0 === strcmp($open_qt_str, "'")) {
367
-            $this->processSingleQuotedString($phpcsFile, $stackPtr, $qtString);
368
-        }
369
-    }//end process()
364
+		if (0 === strcmp($open_qt_str, '"')) {
365
+			$this->processDoubleQuotedString($phpcsFile, $stackPtr, $qtString);
366
+		} else if (0 === strcmp($open_qt_str, "'")) {
367
+			$this->processSingleQuotedString($phpcsFile, $stackPtr, $qtString);
368
+		}
369
+	}//end process()
370 370
 
371 371
 
372
-    /**
373
-     * Processes this test, when the token encountered is a double-quoted string.
374
-     *
375
-     * @param File $phpcsFile The current file being scanned.
376
-     * @param int                  $stackPtr  The position of the current token
377
-     *                                        in the stack passed in $tokens.
378
-     * @param string               $qtString  The double-quoted string content,
379
-     *                                        i.e. without quotes.
380
-     *
381
-     * @return void
382
-     */
383
-    protected function processDoubleQuotedString (File $phpcsFile, $stackPtr, $qtString)
384
-    {
385
-        // so there should be at least a single quote or a special char
386
-        // if there are the 2 kinds of quote and no special char, then add a warning
387
-        $has_variable = parent::processDoubleQuotedString($phpcsFile, $stackPtr, '"'.$qtString.'"');
388
-        $has_specific_sequence = $this->_hasSpecificSequence($qtString);
389
-        $dbl_qt_at = strpos($qtString, '"');
390
-        $smpl_qt_at = strpos($qtString, "'");
391
-        if (false === $has_variable && false === $has_specific_sequence
392
-            && false === $smpl_qt_at
393
-        ) {
394
-            $error = 'Single-quoted strings should be used unless it contains variables, special chars like \n or single quotes.';
395
-            $phpcsFile->addError($error, $stackPtr);
396
-        } else if (false !== $smpl_qt_at && false !== $dbl_qt_at
397
-            && false === $has_variable && false === $has_specific_sequence
398
-        ) {
399
-            $warning = 'It is encouraged to use a single-quoted string, since it doesn\'t contain any variable nor special char though it mixes single and double quotes.';
400
-            $phpcsFile->addWarning($warning, $stackPtr);
401
-        }
402
-    }//end processDoubleQuotedString()
372
+	/**
373
+	 * Processes this test, when the token encountered is a double-quoted string.
374
+	 *
375
+	 * @param File $phpcsFile The current file being scanned.
376
+	 * @param int                  $stackPtr  The position of the current token
377
+	 *                                        in the stack passed in $tokens.
378
+	 * @param string               $qtString  The double-quoted string content,
379
+	 *                                        i.e. without quotes.
380
+	 *
381
+	 * @return void
382
+	 */
383
+	protected function processDoubleQuotedString (File $phpcsFile, $stackPtr, $qtString)
384
+	{
385
+		// so there should be at least a single quote or a special char
386
+		// if there are the 2 kinds of quote and no special char, then add a warning
387
+		$has_variable = parent::processDoubleQuotedString($phpcsFile, $stackPtr, '"'.$qtString.'"');
388
+		$has_specific_sequence = $this->_hasSpecificSequence($qtString);
389
+		$dbl_qt_at = strpos($qtString, '"');
390
+		$smpl_qt_at = strpos($qtString, "'");
391
+		if (false === $has_variable && false === $has_specific_sequence
392
+			&& false === $smpl_qt_at
393
+		) {
394
+			$error = 'Single-quoted strings should be used unless it contains variables, special chars like \n or single quotes.';
395
+			$phpcsFile->addError($error, $stackPtr);
396
+		} else if (false !== $smpl_qt_at && false !== $dbl_qt_at
397
+			&& false === $has_variable && false === $has_specific_sequence
398
+		) {
399
+			$warning = 'It is encouraged to use a single-quoted string, since it doesn\'t contain any variable nor special char though it mixes single and double quotes.';
400
+			$phpcsFile->addWarning($warning, $stackPtr);
401
+		}
402
+	}//end processDoubleQuotedString()
403 403
 
404 404
 
405
-    /**
406
-     * Processes this test, when the token encountered is a single-quoted string.
407
-     *
408
-     * @param File $phpcsFile The current file being scanned.
409
-     * @param int                  $stackPtr  The position of the current token
410
-     *                                        in the stack passed in $tokens.
411
-     * @param string               $qtString  The single-quoted string content,
412
-     *                                        i.e. without quotes.
413
-     *
414
-     * @return void
415
-     */
416
-    protected function processSingleQuotedString (File $phpcsFile, $stackPtr, $qtString)
417
-    {
418
-        // if there is single quotes without additional double quotes,
419
-        // then user is allowed to use double quote to avoid having to
420
-        // escape single quotes. Don't add the warning, if an error was
421
-        // already added, because a variable was found in a single-quoted
422
-        // string.
423
-        $has_variable = parent::processSingleQuotedString($phpcsFile, $stackPtr, "'".$qtString."'");
424
-        $dbl_qt_at = strpos($qtString, '"');
425
-        $smpl_qt_at = strpos($qtString, "'");
426
-        if (false === $has_variable && false !== $smpl_qt_at && false === $dbl_qt_at) {
427
-            $warning = 'You may also use double-quoted strings if the string contains single quotes, so you do not have to use escape characters.';
428
-            $phpcsFile->addWarning($warning, $stackPtr);
429
-        }
430
-    }//end processSingleQuotedString()
405
+	/**
406
+	 * Processes this test, when the token encountered is a single-quoted string.
407
+	 *
408
+	 * @param File $phpcsFile The current file being scanned.
409
+	 * @param int                  $stackPtr  The position of the current token
410
+	 *                                        in the stack passed in $tokens.
411
+	 * @param string               $qtString  The single-quoted string content,
412
+	 *                                        i.e. without quotes.
413
+	 *
414
+	 * @return void
415
+	 */
416
+	protected function processSingleQuotedString (File $phpcsFile, $stackPtr, $qtString)
417
+	{
418
+		// if there is single quotes without additional double quotes,
419
+		// then user is allowed to use double quote to avoid having to
420
+		// escape single quotes. Don't add the warning, if an error was
421
+		// already added, because a variable was found in a single-quoted
422
+		// string.
423
+		$has_variable = parent::processSingleQuotedString($phpcsFile, $stackPtr, "'".$qtString."'");
424
+		$dbl_qt_at = strpos($qtString, '"');
425
+		$smpl_qt_at = strpos($qtString, "'");
426
+		if (false === $has_variable && false !== $smpl_qt_at && false === $dbl_qt_at) {
427
+			$warning = 'You may also use double-quoted strings if the string contains single quotes, so you do not have to use escape characters.';
428
+			$phpcsFile->addWarning($warning, $stackPtr);
429
+		}
430
+	}//end processSingleQuotedString()
431 431
 
432
-    /**
433
-     * Return TRUE, if a sequence of chars that is parsed in a specific way
434
-     * in double-quoted strings is found, FALSE otherwise.
435
-     *
436
-     * @param string $string String in which sequence of special chars will
437
-     * be researched.
438
-     *
439
-     * @return TRUE, if a sequence of chars that is parsed in a specific way
440
-     * in double-quoted strings is found, FALSE otherwise.
441
-     *
442
-     * @link http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.double
443
-     */
444
-    private function _hasSpecificSequence($string)
445
-    {
446
-        $hasSpecificSequence = FALSE;
447
-        $specialMeaningStrs = array('\n', '\r', '\t', '\v', '\f');
448
-        foreach ($specialMeaningStrs as $splStr) {
449
-            if (FALSE !== strpos($string, $splStr)) {
450
-                $hasSpecificSequence = TRUE;
451
-            }
452
-        }
453
-        $specialMeaningPtrns = array('\[0-7]{1,3}', '\x[0-9A-Fa-f]{1,2}');
454
-        foreach ($specialMeaningPtrns as $splPtrn) {
455
-            if (1 === preg_match("/{$splPtrn}/", $string)) {
456
-                $hasSpecificSequence = TRUE;
457
-            }
458
-        }
459
-        return $hasSpecificSequence;
460
-    }//end _hasSpecificSequence()
432
+	/**
433
+	 * Return TRUE, if a sequence of chars that is parsed in a specific way
434
+	 * in double-quoted strings is found, FALSE otherwise.
435
+	 *
436
+	 * @param string $string String in which sequence of special chars will
437
+	 * be researched.
438
+	 *
439
+	 * @return TRUE, if a sequence of chars that is parsed in a specific way
440
+	 * in double-quoted strings is found, FALSE otherwise.
441
+	 *
442
+	 * @link http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.double
443
+	 */
444
+	private function _hasSpecificSequence($string)
445
+	{
446
+		$hasSpecificSequence = FALSE;
447
+		$specialMeaningStrs = array('\n', '\r', '\t', '\v', '\f');
448
+		foreach ($specialMeaningStrs as $splStr) {
449
+			if (FALSE !== strpos($string, $splStr)) {
450
+				$hasSpecificSequence = TRUE;
451
+			}
452
+		}
453
+		$specialMeaningPtrns = array('\[0-7]{1,3}', '\x[0-9A-Fa-f]{1,2}');
454
+		foreach ($specialMeaningPtrns as $splPtrn) {
455
+			if (1 === preg_match("/{$splPtrn}/", $string)) {
456
+				$hasSpecificSequence = TRUE;
457
+			}
458
+		}
459
+		return $hasSpecificSequence;
460
+	}//end _hasSpecificSequence()
461 461
 
462 462
 }//end class
463 463
 
Please login to merge, or discard this patch.
build/CodeIgniter/Sniffs/Commenting/InlineCommentSniff.php 1 patch
Indentation   +149 added lines, -149 removed lines patch added patch discarded remove patch
@@ -32,155 +32,155 @@
 block discarded – undo
32 32
 
33 33
 class InlineCommentSniff implements Sniff
34 34
 {
35
-    /**
36
-     * @var int Limit defining long comments.
37
-     * Long comments count $longCommentLimit or more lines.
38
-     */
39
-    public $longCommentLimit = 5;
40
-
41
-    /**
42
-     * Returns an array of tokens this test wants to listen for.
43
-     *
44
-     * @return array
45
-     */
46
-    public function register()
47
-    {
48
-        return array(
49
-            T_COMMENT
50
-        );
51
-    }//end register()
52
-
53
-    /**
54
-     * Processes this test, when one of its tokens is encountered.
55
-     *
56
-     * @param File $phpcsFile The current file being scanned.
57
-     * @param int                  $stackPtr  The position of the current token
58
-     *                                        in the stack passed in $tokens.
59
-     *
60
-     * @return void
61
-     */
62
-    public function process(File $phpcsFile, $stackPtr)
63
-    {
64
-        $tokens = $phpcsFile->getTokens();
65
-
66
-        // keep testing only if it's about the first comment of the block
67
-        $previousCommentPtr = $phpcsFile->findPrevious($tokens[$stackPtr]['code'], $stackPtr - 1);
68
-        if ($tokens[$previousCommentPtr]['line'] !== $tokens[$stackPtr]['line'] - 1) {
69
-            if (TRUE !== $this->_checkCommentStyle($phpcsFile, $stackPtr)) {
70
-                return;
71
-            }
72
-
73
-            $commentLines = $this->_getCommentBlock($phpcsFile, $stackPtr);
74
-
75
-            if (count($commentLines) >= $this->longCommentLimit) {
76
-                $this->_checkBlankLinesAroundLongComment($phpcsFile, $commentLines);
77
-            }
78
-        }
79
-    }//end process()
80
-
81
-
82
-    /**
83
-     * Add error to $phpcsFile, if comment pointed by $stackPtr doesn't start
84
-     * with '//'.
85
-     *
86
-     * @param File $phpcsFile The current file being scanned.
87
-     * @param int                  $stackPtr  The position of the current token
88
-     *                                        that has to be a comment.
89
-     *
90
-     * @return bool TRUE if the content of the token pointed by $stackPtr starts
91
-     *              with //, FALSE if an error was added to $phpcsFile.
92
-     */
93
-    private function _checkCommentStyle(File $phpcsFile, $stackPtr)
94
-    {
95
-        $tokens = $phpcsFile->getTokens();
96
-        if ($tokens[$stackPtr]['content']{0} === '#') {
97
-            $error  = 'Perl-style comments are not allowed; use "// Comment" or DocBlock comments instead';
98
-            $phpcsFile->addError($error, $stackPtr, 'WrongStyle');
99
-            return FALSE;
100
-        } else if (substr($tokens[$stackPtr]['content'], 0, 2) === '/*'
101
-            || $tokens[$stackPtr]['content']{0} === '*'
102
-        ) {
103
-            $error  = 'Multi lines comments are not allowed; use "// Comment" DocBlock comments instead';
104
-            $phpcsFile->addError($error, $stackPtr, 'WrongStyle');
105
-            return FALSE;
106
-        } else if (substr($tokens[$stackPtr]['content'], 0, 2) !== '//') {
107
-            $error  = 'Use single line or DocBlock comments within code';
108
-            $phpcsFile->addError($error, $stackPtr, 'WrongStyle');
109
-            return FALSE;
110
-        }
111
-        return TRUE;
112
-    }//_checkCommentStyle()
113
-
114
-
115
-    /**
116
-     * Gather into an array all comment lines to which $stackPtr belongs.
117
-     *
118
-     * @param File $phpcsFile The current file being scanned.
119
-     * @param int                  $stackPtr  Pointer to the first comment line.
120
-     *
121
-     * @return type array Pointers to tokens making up the comment block.
122
-     */
123
-    private function _getCommentBlock(File $phpcsFile, $stackPtr)
124
-    {
125
-        $tokens = $phpcsFile->getTokens();
126
-        $commentLines = array($stackPtr);
127
-        $nextComment  = $stackPtr;
128
-        $lastLine     = $tokens[$stackPtr]['line'];
129
-
130
-        while (($nextComment = $phpcsFile->findNext($tokens[$stackPtr]['code'], ($nextComment + 1), null, false)) !== false) {
131
-            if (($tokens[$nextComment]['line'] - 1) !== $lastLine) {
132
-                // Not part of the block.
133
-                break;
134
-            }
135
-
136
-            $lastLine       = $tokens[$nextComment]['line'];
137
-            $commentLines[] = $nextComment;
138
-        }
139
-
140
-        return $commentLines;
141
-    }//_getCommentBlock()
142
-
143
-
144
-    /**
145
-     * Add errors to $phpcsFile, if $commentLines isn't enclosed with blank lines.
146
-     *
147
-     * @param File $phpcsFile    The current file being scanned.
148
-     * @param array                $commentLines Lines of the comment block being checked.
149
-     *
150
-     * @return bool TRUE if $commentLines is enclosed with at least a blank line
151
-     * before and after, FALSE otherwise.
152
-     */
153
-    private function _checkBlankLinesAroundLongComment(File $phpcsFile, array $commentLines)
154
-    {
155
-        $hasBlankLinesAround = TRUE;
156
-        $tokens = $phpcsFile->getTokens();
157
-
158
-        // check blank line before the long comment
159
-        $firstCommentPtr = reset($commentLines);
160
-        $firstPreviousSpacePtr = $firstCommentPtr - 1;
161
-        while (T_WHITESPACE === $tokens[$firstPreviousSpacePtr]['code'] && $firstPreviousSpacePtr > 0) {
162
-            $firstPreviousSpacePtr--;
163
-        }
164
-        if ($tokens[$firstPreviousSpacePtr]['line'] >= $tokens[$firstCommentPtr]['line'] - 1) {
165
-            $error  = "Please add a blank line before comments counting more than {$this->longCommentLimit} lines.";
166
-            $phpcsFile->addError($error, $firstCommentPtr, 'LongCommentWithoutSpacing');
167
-            $hasBlankLinesAround = FALSE;
168
-        }
169
-
170
-        // check blank line after the long comment
171
-        $lastCommentPtr = end($commentLines);
172
-        $lastNextSpacePtr = $lastCommentPtr + 1;
173
-        while (T_WHITESPACE === $tokens[$lastNextSpacePtr]['code'] && $lastNextSpacePtr < count($tokens)) {
174
-            $lastNextSpacePtr++;
175
-        }
176
-        if ($tokens[$lastNextSpacePtr]['line'] <= $tokens[$lastCommentPtr]['line'] + 1) {
177
-            $error  = "Please add a blank line after comments counting more than {$this->longCommentLimit} lines.";
178
-            $phpcsFile->addError($error, $lastCommentPtr, 'LongCommentWithoutSpacing');
179
-            $hasBlankLinesAround = FALSE;
180
-        }
181
-
182
-        return $hasBlankLinesAround;
183
-    }//end _checkBlanksAroundLongComment()
35
+	/**
36
+	 * @var int Limit defining long comments.
37
+	 * Long comments count $longCommentLimit or more lines.
38
+	 */
39
+	public $longCommentLimit = 5;
40
+
41
+	/**
42
+	 * Returns an array of tokens this test wants to listen for.
43
+	 *
44
+	 * @return array
45
+	 */
46
+	public function register()
47
+	{
48
+		return array(
49
+			T_COMMENT
50
+		);
51
+	}//end register()
52
+
53
+	/**
54
+	 * Processes this test, when one of its tokens is encountered.
55
+	 *
56
+	 * @param File $phpcsFile The current file being scanned.
57
+	 * @param int                  $stackPtr  The position of the current token
58
+	 *                                        in the stack passed in $tokens.
59
+	 *
60
+	 * @return void
61
+	 */
62
+	public function process(File $phpcsFile, $stackPtr)
63
+	{
64
+		$tokens = $phpcsFile->getTokens();
65
+
66
+		// keep testing only if it's about the first comment of the block
67
+		$previousCommentPtr = $phpcsFile->findPrevious($tokens[$stackPtr]['code'], $stackPtr - 1);
68
+		if ($tokens[$previousCommentPtr]['line'] !== $tokens[$stackPtr]['line'] - 1) {
69
+			if (TRUE !== $this->_checkCommentStyle($phpcsFile, $stackPtr)) {
70
+				return;
71
+			}
72
+
73
+			$commentLines = $this->_getCommentBlock($phpcsFile, $stackPtr);
74
+
75
+			if (count($commentLines) >= $this->longCommentLimit) {
76
+				$this->_checkBlankLinesAroundLongComment($phpcsFile, $commentLines);
77
+			}
78
+		}
79
+	}//end process()
80
+
81
+
82
+	/**
83
+	 * Add error to $phpcsFile, if comment pointed by $stackPtr doesn't start
84
+	 * with '//'.
85
+	 *
86
+	 * @param File $phpcsFile The current file being scanned.
87
+	 * @param int                  $stackPtr  The position of the current token
88
+	 *                                        that has to be a comment.
89
+	 *
90
+	 * @return bool TRUE if the content of the token pointed by $stackPtr starts
91
+	 *              with //, FALSE if an error was added to $phpcsFile.
92
+	 */
93
+	private function _checkCommentStyle(File $phpcsFile, $stackPtr)
94
+	{
95
+		$tokens = $phpcsFile->getTokens();
96
+		if ($tokens[$stackPtr]['content']{0} === '#') {
97
+			$error  = 'Perl-style comments are not allowed; use "// Comment" or DocBlock comments instead';
98
+			$phpcsFile->addError($error, $stackPtr, 'WrongStyle');
99
+			return FALSE;
100
+		} else if (substr($tokens[$stackPtr]['content'], 0, 2) === '/*'
101
+			|| $tokens[$stackPtr]['content']{0} === '*'
102
+		) {
103
+			$error  = 'Multi lines comments are not allowed; use "// Comment" DocBlock comments instead';
104
+			$phpcsFile->addError($error, $stackPtr, 'WrongStyle');
105
+			return FALSE;
106
+		} else if (substr($tokens[$stackPtr]['content'], 0, 2) !== '//') {
107
+			$error  = 'Use single line or DocBlock comments within code';
108
+			$phpcsFile->addError($error, $stackPtr, 'WrongStyle');
109
+			return FALSE;
110
+		}
111
+		return TRUE;
112
+	}//_checkCommentStyle()
113
+
114
+
115
+	/**
116
+	 * Gather into an array all comment lines to which $stackPtr belongs.
117
+	 *
118
+	 * @param File $phpcsFile The current file being scanned.
119
+	 * @param int                  $stackPtr  Pointer to the first comment line.
120
+	 *
121
+	 * @return type array Pointers to tokens making up the comment block.
122
+	 */
123
+	private function _getCommentBlock(File $phpcsFile, $stackPtr)
124
+	{
125
+		$tokens = $phpcsFile->getTokens();
126
+		$commentLines = array($stackPtr);
127
+		$nextComment  = $stackPtr;
128
+		$lastLine     = $tokens[$stackPtr]['line'];
129
+
130
+		while (($nextComment = $phpcsFile->findNext($tokens[$stackPtr]['code'], ($nextComment + 1), null, false)) !== false) {
131
+			if (($tokens[$nextComment]['line'] - 1) !== $lastLine) {
132
+				// Not part of the block.
133
+				break;
134
+			}
135
+
136
+			$lastLine       = $tokens[$nextComment]['line'];
137
+			$commentLines[] = $nextComment;
138
+		}
139
+
140
+		return $commentLines;
141
+	}//_getCommentBlock()
142
+
143
+
144
+	/**
145
+	 * Add errors to $phpcsFile, if $commentLines isn't enclosed with blank lines.
146
+	 *
147
+	 * @param File $phpcsFile    The current file being scanned.
148
+	 * @param array                $commentLines Lines of the comment block being checked.
149
+	 *
150
+	 * @return bool TRUE if $commentLines is enclosed with at least a blank line
151
+	 * before and after, FALSE otherwise.
152
+	 */
153
+	private function _checkBlankLinesAroundLongComment(File $phpcsFile, array $commentLines)
154
+	{
155
+		$hasBlankLinesAround = TRUE;
156
+		$tokens = $phpcsFile->getTokens();
157
+
158
+		// check blank line before the long comment
159
+		$firstCommentPtr = reset($commentLines);
160
+		$firstPreviousSpacePtr = $firstCommentPtr - 1;
161
+		while (T_WHITESPACE === $tokens[$firstPreviousSpacePtr]['code'] && $firstPreviousSpacePtr > 0) {
162
+			$firstPreviousSpacePtr--;
163
+		}
164
+		if ($tokens[$firstPreviousSpacePtr]['line'] >= $tokens[$firstCommentPtr]['line'] - 1) {
165
+			$error  = "Please add a blank line before comments counting more than {$this->longCommentLimit} lines.";
166
+			$phpcsFile->addError($error, $firstCommentPtr, 'LongCommentWithoutSpacing');
167
+			$hasBlankLinesAround = FALSE;
168
+		}
169
+
170
+		// check blank line after the long comment
171
+		$lastCommentPtr = end($commentLines);
172
+		$lastNextSpacePtr = $lastCommentPtr + 1;
173
+		while (T_WHITESPACE === $tokens[$lastNextSpacePtr]['code'] && $lastNextSpacePtr < count($tokens)) {
174
+			$lastNextSpacePtr++;
175
+		}
176
+		if ($tokens[$lastNextSpacePtr]['line'] <= $tokens[$lastCommentPtr]['line'] + 1) {
177
+			$error  = "Please add a blank line after comments counting more than {$this->longCommentLimit} lines.";
178
+			$phpcsFile->addError($error, $lastCommentPtr, 'LongCommentWithoutSpacing');
179
+			$hasBlankLinesAround = FALSE;
180
+		}
181
+
182
+		return $hasBlankLinesAround;
183
+	}//end _checkBlanksAroundLongComment()
184 184
 
185 185
 }//end class
186 186
 
Please login to merge, or discard this patch.
build/CodeIgniter/Sniffs/Operators/LogicalOperatorAndSniff.php 1 patch
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -33,47 +33,47 @@
 block discarded – undo
33 33
 class LogicalOperatorAndSniff implements Sniff
34 34
 {
35 35
 	/**
36
-     * Returns an array of tokens this test wants to listen for: symbolic and literal operators and.
37
-     *
38
-     * @return array
39
-     */
40
-    public function register()
41
-    {
42
-        return array(
43
-            T_LOGICAL_AND,
44
-        );
36
+	 * Returns an array of tokens this test wants to listen for: symbolic and literal operators and.
37
+	 *
38
+	 * @return array
39
+	 */
40
+	public function register()
41
+	{
42
+		return array(
43
+			T_LOGICAL_AND,
44
+		);
45 45
 
46
-    }//end register()
46
+	}//end register()
47 47
 
48 48
 
49
-    /**
50
-     * Processes this test, when one of its tokens is encountered.
51
-     *
52
-     * @param File $phpcsFile The current file being scanned.
53
-     * @param int                  $stackPtr  The position of the current token
54
-     *                                        in the stack passed in $tokens.
55
-     *
56
-     * @return void
57
-     */
58
-    public function process(File $phpcsFile, $stackPtr)
59
-    {
60
-        $tokens = $phpcsFile->getTokens();
49
+	/**
50
+	 * Processes this test, when one of its tokens is encountered.
51
+	 *
52
+	 * @param File $phpcsFile The current file being scanned.
53
+	 * @param int                  $stackPtr  The position of the current token
54
+	 *                                        in the stack passed in $tokens.
55
+	 *
56
+	 * @return void
57
+	 */
58
+	public function process(File $phpcsFile, $stackPtr)
59
+	{
60
+		$tokens = $phpcsFile->getTokens();
61 61
 
62
-        $operator_token = $tokens[$stackPtr];
63
-        $operator_string = $operator_token['content'];
64
-        $operator_code = $operator_token['code'];
62
+		$operator_token = $tokens[$stackPtr];
63
+		$operator_string = $operator_token['content'];
64
+		$operator_code = $operator_token['code'];
65 65
 
66
-        if ($operator_string !== strtoupper($operator_string)) {
67
-            $error_message = 'Logical operator should be in upper case;'
68
-                . ' use "' . strtoupper($operator_string)
69
-                . '" instead of "' . $operator_string . '"';
70
-            $phpcsFile->addError($error_message, $stackPtr, 'LowercaseLogicalOperator');
71
-        }
66
+		if ($operator_string !== strtoupper($operator_string)) {
67
+			$error_message = 'Logical operator should be in upper case;'
68
+				. ' use "' . strtoupper($operator_string)
69
+				. '" instead of "' . $operator_string . '"';
70
+			$phpcsFile->addError($error_message, $stackPtr, 'LowercaseLogicalOperator');
71
+		}
72 72
 
73
-        $warning_message = 'The symbolic form "&&" is preferred over the literal form "AND"';
74
-        $phpcsFile->addWarning($warning_message, $stackPtr, 'UseOfLiteralAndOperator');
73
+		$warning_message = 'The symbolic form "&&" is preferred over the literal form "AND"';
74
+		$phpcsFile->addWarning($warning_message, $stackPtr, 'UseOfLiteralAndOperator');
75 75
 
76
-    }//end process()
76
+	}//end process()
77 77
 
78 78
 
79 79
 }//end class
Please login to merge, or discard this patch.
build/CodeIgniter/Sniffs/Operators/StrictComparisonOperatorSniff.php 1 patch
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -33,47 +33,47 @@
 block discarded – undo
33 33
 
34 34
 class StrictComparisonOperatorSniff implements Sniff
35 35
 {
36
-    private static $_replacements = array(
37
-        T_IS_EQUAL     => '===',
38
-        T_IS_NOT_EQUAL => '!==',
39
-    );
36
+	private static $_replacements = array(
37
+		T_IS_EQUAL     => '===',
38
+		T_IS_NOT_EQUAL => '!==',
39
+	);
40 40
 
41
-    /**
42
-     * Returns an array of tokens this test wants to listen for.
43
-     *
44
-     * @return array
45
-     */
46
-    public function register()
47
-    {
48
-        return array(
49
-            T_IS_EQUAL,
50
-            T_IS_NOT_EQUAL,
51
-        );
52
-    }//end register()
41
+	/**
42
+	 * Returns an array of tokens this test wants to listen for.
43
+	 *
44
+	 * @return array
45
+	 */
46
+	public function register()
47
+	{
48
+		return array(
49
+			T_IS_EQUAL,
50
+			T_IS_NOT_EQUAL,
51
+		);
52
+	}//end register()
53 53
 
54 54
 
55
-    /**
56
-     * Processes this test, when one of its tokens is encountered.
57
-     *
58
-     * @param File $phpcsFile The current file being scanned.
59
-     * @param int                  $stackPtr  The position of the current token
60
-     *                                        in the stack passed in $tokens.
61
-     *
62
-     * @return void
63
-     */
64
-    public function process(File $phpcsFile, $stackPtr)
65
-    {
66
-        $tokens = $phpcsFile->getTokens();
55
+	/**
56
+	 * Processes this test, when one of its tokens is encountered.
57
+	 *
58
+	 * @param File $phpcsFile The current file being scanned.
59
+	 * @param int                  $stackPtr  The position of the current token
60
+	 *                                        in the stack passed in $tokens.
61
+	 *
62
+	 * @return void
63
+	 */
64
+	public function process(File $phpcsFile, $stackPtr)
65
+	{
66
+		$tokens = $phpcsFile->getTokens();
67 67
 
68
-        $operator_token = $tokens[$stackPtr];
69
-        $operator_string = $operator_token['content'];
70
-        $operator_code = $operator_token['code'];
68
+		$operator_token = $tokens[$stackPtr];
69
+		$operator_string = $operator_token['content'];
70
+		$operator_code = $operator_token['code'];
71 71
 
72
-        $error_message = '"==" and "!=" are prohibited; use "'
73
-            . self::$_replacements[$operator_code] . '" instead of "'
74
-            . $operator_string . '".';
75
-        $phpcsFile->addError($error_message, $stackPtr, 'NonStrictComparisonUsed');
76
-    }//end process()
72
+		$error_message = '"==" and "!=" are prohibited; use "'
73
+			. self::$_replacements[$operator_code] . '" instead of "'
74
+			. $operator_string . '".';
75
+		$phpcsFile->addError($error_message, $stackPtr, 'NonStrictComparisonUsed');
76
+	}//end process()
77 77
 
78 78
 
79 79
 }//end class
Please login to merge, or discard this patch.