Completed
Branch master (205409)
by Timothy
02:36
created
build/CodeIgniter/Sniffs/Commenting/InlineCommentSniff.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
     /**
42 42
      * Returns an array of tokens this test wants to listen for.
43 43
      *
44
-     * @return array
44
+     * @return integer[]
45 45
      */
46 46
     public function register()
47 47
     {
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
      * @param File $phpcsFile The current file being scanned.
119 119
      * @param int                  $stackPtr  Pointer to the first comment line.
120 120
      *
121
-     * @return type array Pointers to tokens making up the comment block.
121
+     * @return integer[] array Pointers to tokens making up the comment block.
122 122
      */
123 123
     private function _getCommentBlock(File $phpcsFile, $stackPtr)
124 124
     {
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
      * Add errors to $phpcsFile, if $commentLines isn't enclosed with blank lines.
146 146
      *
147 147
      * @param File $phpcsFile    The current file being scanned.
148
-     * @param array                $commentLines Lines of the comment block being checked.
148
+     * @param integer[]                $commentLines Lines of the comment block being checked.
149 149
      *
150 150
      * @return bool TRUE if $commentLines is enclosed with at least a blank line
151 151
      * before and after, FALSE otherwise.
Please login to merge, or discard this patch.
Braces   +26 added lines, -14 removed lines patch added patch discarded remove patch
@@ -30,8 +30,7 @@  discard block
 block discarded – undo
30 30
 use PHP_CodeSniffer\Sniffs\Sniff;
31 31
 use PHP_CodeSniffer\Files\File;
32 32
 
33
-class InlineCommentSniff implements Sniff
34
-{
33
+class InlineCommentSniff implements Sniff {
35 34
     /**
36 35
      * @var int Limit defining long comments.
37 36
      * Long comments count $longCommentLimit or more lines.
@@ -65,14 +64,17 @@  discard block
 block discarded – undo
65 64
 
66 65
         // keep testing only if it's about the first comment of the block
67 66
         $previousCommentPtr = $phpcsFile->findPrevious($tokens[$stackPtr]['code'], $stackPtr - 1);
68
-        if ($tokens[$previousCommentPtr]['line'] !== $tokens[$stackPtr]['line'] - 1) {
69
-            if (TRUE !== $this->_checkCommentStyle($phpcsFile, $stackPtr)) {
67
+        if ($tokens[$previousCommentPtr]['line'] !== $tokens[$stackPtr]['line'] - 1)
68
+        {
69
+            if (TRUE !== $this->_checkCommentStyle($phpcsFile, $stackPtr))
70
+            {
70 71
                 return;
71 72
             }
72 73
 
73 74
             $commentLines = $this->_getCommentBlock($phpcsFile, $stackPtr);
74 75
 
75
-            if (count($commentLines) >= $this->longCommentLimit) {
76
+            if (count($commentLines) >= $this->longCommentLimit)
77
+            {
76 78
                 $this->_checkBlankLinesAroundLongComment($phpcsFile, $commentLines);
77 79
             }
78 80
         }
@@ -93,17 +95,21 @@  discard block
 block discarded – undo
93 95
     private function _checkCommentStyle(File $phpcsFile, $stackPtr)
94 96
     {
95 97
         $tokens = $phpcsFile->getTokens();
96
-        if ($tokens[$stackPtr]['content']{0} === '#') {
98
+        if ($tokens[$stackPtr]['content']{0} === '#')
99
+        {
97 100
             $error  = 'Perl-style comments are not allowed; use "// Comment" or DocBlock comments instead';
98 101
             $phpcsFile->addError($error, $stackPtr, 'WrongStyle');
99 102
             return FALSE;
100
-        } else if (substr($tokens[$stackPtr]['content'], 0, 2) === '/*'
103
+        }
104
+        else if (substr($tokens[$stackPtr]['content'], 0, 2) === '/*'
101 105
             || $tokens[$stackPtr]['content']{0} === '*'
102 106
         ) {
103 107
             $error  = 'Multi lines comments are not allowed; use "// Comment" DocBlock comments instead';
104 108
             $phpcsFile->addError($error, $stackPtr, 'WrongStyle');
105 109
             return FALSE;
106
-        } else if (substr($tokens[$stackPtr]['content'], 0, 2) !== '//') {
110
+        }
111
+        else if (substr($tokens[$stackPtr]['content'], 0, 2) !== '//')
112
+        {
107 113
             $error  = 'Use single line or DocBlock comments within code';
108 114
             $phpcsFile->addError($error, $stackPtr, 'WrongStyle');
109 115
             return FALSE;
@@ -127,8 +133,10 @@  discard block
 block discarded – undo
127 133
         $nextComment  = $stackPtr;
128 134
         $lastLine     = $tokens[$stackPtr]['line'];
129 135
 
130
-        while (($nextComment = $phpcsFile->findNext($tokens[$stackPtr]['code'], ($nextComment + 1), null, false)) !== false) {
131
-            if (($tokens[$nextComment]['line'] - 1) !== $lastLine) {
136
+        while (($nextComment = $phpcsFile->findNext($tokens[$stackPtr]['code'], ($nextComment + 1), null, false)) !== false)
137
+        {
138
+            if (($tokens[$nextComment]['line'] - 1) !== $lastLine)
139
+            {
132 140
                 // Not part of the block.
133 141
                 break;
134 142
             }
@@ -158,10 +166,12 @@  discard block
 block discarded – undo
158 166
         // check blank line before the long comment
159 167
         $firstCommentPtr = reset($commentLines);
160 168
         $firstPreviousSpacePtr = $firstCommentPtr - 1;
161
-        while (T_WHITESPACE === $tokens[$firstPreviousSpacePtr]['code'] && $firstPreviousSpacePtr > 0) {
169
+        while (T_WHITESPACE === $tokens[$firstPreviousSpacePtr]['code'] && $firstPreviousSpacePtr > 0)
170
+        {
162 171
             $firstPreviousSpacePtr--;
163 172
         }
164
-        if ($tokens[$firstPreviousSpacePtr]['line'] >= $tokens[$firstCommentPtr]['line'] - 1) {
173
+        if ($tokens[$firstPreviousSpacePtr]['line'] >= $tokens[$firstCommentPtr]['line'] - 1)
174
+        {
165 175
             $error  = "Please add a blank line before comments counting more than {$this->longCommentLimit} lines.";
166 176
             $phpcsFile->addError($error, $firstCommentPtr, 'LongCommentWithoutSpacing');
167 177
             $hasBlankLinesAround = FALSE;
@@ -170,10 +180,12 @@  discard block
 block discarded – undo
170 180
         // check blank line after the long comment
171 181
         $lastCommentPtr = end($commentLines);
172 182
         $lastNextSpacePtr = $lastCommentPtr + 1;
173
-        while (T_WHITESPACE === $tokens[$lastNextSpacePtr]['code'] && $lastNextSpacePtr < count($tokens)) {
183
+        while (T_WHITESPACE === $tokens[$lastNextSpacePtr]['code'] && $lastNextSpacePtr < count($tokens))
184
+        {
174 185
             $lastNextSpacePtr++;
175 186
         }
176
-        if ($tokens[$lastNextSpacePtr]['line'] <= $tokens[$lastCommentPtr]['line'] + 1) {
187
+        if ($tokens[$lastNextSpacePtr]['line'] <= $tokens[$lastCommentPtr]['line'] + 1)
188
+        {
177 189
             $error  = "Please add a blank line after comments counting more than {$this->longCommentLimit} lines.";
178 190
             $phpcsFile->addError($error, $lastCommentPtr, 'LongCommentWithoutSpacing');
179 191
             $hasBlankLinesAround = FALSE;
Please login to merge, or discard this patch.
build/CodeIgniter/Sniffs/Files/ByteOrderMarkSniff.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
35 35
     /**
36 36
      * Returns an array of tokens this test wants to listen for.
37 37
      *
38
-     * @return array
38
+     * @return integer[]
39 39
      */
40 40
     public function register()
41 41
     {
Please login to merge, or discard this patch.
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -30,8 +30,7 @@  discard block
 block discarded – undo
30 30
 use PHP_CodeSniffer\Sniffs\Sniff;
31 31
 use PHP_CodeSniffer\Files\File;
32 32
 
33
-class ByteOrderMarkSniff implements Sniff
34
-{
33
+class ByteOrderMarkSniff implements Sniff {
35 34
     /**
36 35
      * Returns an array of tokens this test wants to listen for.
37 36
      *
@@ -77,18 +76,22 @@  discard block
 block discarded – undo
77 76
     public function process(File $phpcsFile, $stackPtr )
78 77
     {
79 78
         // 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) {
79
+        if ($stackPtr !== 0)
80
+        {
81
+            if ($phpcsFile->findPrevious(T_OPEN_TAG, ($stackPtr - 1)) !== false)
82
+            {
82 83
                 return;
83 84
             }
84 85
         }
85 86
 
86 87
         $tokens = $phpcsFile->getTokens();
87 88
         $fileStartString = $tokens[0]['content'];
88
-        foreach ($this->getBomDefinitions() as $bomName => $expectedBomHex) {
89
+        foreach ($this->getBomDefinitions() as $bomName => $expectedBomHex)
90
+        {
89 91
             $bomByteLength = strlen($expectedBomHex) / 2;
90 92
             $fileStartHex = bin2hex(substr($fileStartString, 0, $bomByteLength));
91
-            if ($fileStartHex === $expectedBomHex) {
93
+            if ($fileStartHex === $expectedBomHex)
94
+            {
92 95
                 $error = "File contains a $bomName byte order mark (BOM).";
93 96
                 $phpcsFile->addError($error, $stackPtr);
94 97
                 break;
Please login to merge, or discard this patch.
build/CodeIgniter/Sniffs/Files/Utf8EncodingSniff.php 2 patches
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
     /**
37 37
      * Returns an array of tokens this test wants to listen for.
38 38
      *
39
-     * @return array
39
+     * @return integer[]
40 40
      */
41 41
     public function register()
42 42
     {
@@ -174,6 +174,7 @@  discard block
 block discarded – undo
174 174
      *
175 175
      * @param string $str String to split.
176 176
 	 * @param int $len number of characters per chunk
177
+	 * @param string $glue
177 178
      *
178 179
      * @return array string array after splitting
179 180
      *
Please login to merge, or discard this patch.
Braces   +48 added lines, -23 removed lines patch added patch discarded remove patch
@@ -30,8 +30,7 @@  discard block
 block discarded – undo
30 30
 use PHP_CodeSniffer\Sniffs\Sniff;
31 31
 use PHP_CodeSniffer\Files\File;
32 32
 
33
-class Utf8EncodingSniff implements Sniff
34
-{
33
+class Utf8EncodingSniff implements Sniff {
35 34
 
36 35
     /**
37 36
      * Returns an array of tokens this test wants to listen for.
@@ -59,8 +58,10 @@  discard block
 block discarded – undo
59 58
     public function process(File $phpcsFile, $stackPtr)
60 59
     {
61 60
         // We are only interested if this is the first open tag.
62
-        if ($stackPtr !== 0) {
63
-            if ($phpcsFile->findPrevious(T_OPEN_TAG, ($stackPtr - 1)) !== false) {
61
+        if ($stackPtr !== 0)
62
+        {
63
+            if ($phpcsFile->findPrevious(T_OPEN_TAG, ($stackPtr - 1)) !== false)
64
+            {
64 65
                 return;
65 66
             }
66 67
         }
@@ -68,15 +69,18 @@  discard block
 block discarded – undo
68 69
         $file_path = $phpcsFile->getFilename();
69 70
         $file_name = basename($file_path);
70 71
         $file_content = file_get_contents($file_path);
71
-        if (false === mb_check_encoding($file_content, 'UTF-8')) {
72
+        if (false === mb_check_encoding($file_content, 'UTF-8'))
73
+        {
72 74
             $error = 'File "' . $file_name . '" should be saved with Unicode (UTF-8) encoding.';
73 75
             $phpcsFile->addError($error, 0);
74 76
         }
75
-        if ( ! self::_checkUtf8W3c($file_content)) {
77
+        if ( ! self::_checkUtf8W3c($file_content))
78
+        {
76 79
             $error = 'File "' . $file_name . '" should be saved with Unicode (UTF-8) encoding, but it did not successfully pass the W3C test.';
77 80
             $phpcsFile->addError($error, 0);
78 81
         }
79
-        if ( ! self::_checkUtf8Rfc3629($file_content)) {
82
+        if ( ! self::_checkUtf8Rfc3629($file_content))
83
+        {
80 84
             $error = 'File "' . $file_name . '" should be saved with Unicode (UTF-8) encoding, but it did not meet RFC3629 requirements.';
81 85
             $phpcsFile->addError($error, 0);
82 86
         }
@@ -98,7 +102,7 @@  discard block
 block discarded – undo
98 102
     {
99 103
         $content_chunks=self::mb_chunk_split($content, 4096, '');
100 104
     	foreach($content_chunks as $content_chunk)
101
-		{
105
+    	{
102 106
 			$preg_result= preg_match(
103 107
             '%^(?:
104 108
                   [\x09\x0A\x0D\x20-\x7E]            # ASCII
@@ -135,29 +139,47 @@  discard block
 block discarded – undo
135 139
     private static function _checkUtf8Rfc3629($content)
136 140
     {
137 141
         $len = strlen($content);
138
-        for ($i = 0; $i < $len; $i++) {
142
+        for ($i = 0; $i < $len; $i++)
143
+        {
139 144
             $c = ord($content[$i]);
140
-            if ($c > 128) {
141
-                if (($c >= 254)) {
145
+            if ($c > 128)
146
+            {
147
+                if (($c >= 254))
148
+                {
142 149
                     return false;
143
-                } elseif ($c >= 252) {
150
+                }
151
+                elseif ($c >= 252)
152
+                {
144 153
                     $bits=6;
145
-                } elseif ($c >= 248) {
154
+                }
155
+                elseif ($c >= 248)
156
+                {
146 157
                     $bits=5;
147
-                } elseif ($c >= 240) {
158
+                }
159
+                elseif ($c >= 240)
160
+                {
148 161
                     $bytes = 4;
149
-                } elseif ($c >= 224) {
162
+                }
163
+                elseif ($c >= 224)
164
+                {
150 165
                     $bytes = 3;
151
-                } elseif ($c >= 192) {
166
+                }
167
+                elseif ($c >= 192)
168
+                {
152 169
                     $bytes = 2;
153
-                } else {
170
+                }
171
+                else
172
+                {
154 173
                     return false;
155
-                } if (($i + $bytes) > $len) {
174
+                } if (($i + $bytes) > $len)
175
+                {
156 176
                     return false;
157
-                } while ($bytes > 1) {
177
+                } while ($bytes > 1)
178
+                {
158 179
                     $i++;
159 180
                     $b = ord($content[$i]);
160
-                    if ($b < 128 || $b > 191) {
181
+                    if ($b < 128 || $b > 191)
182
+                    {
161 183
                         return false;
162 184
                     }
163 185
                     $bytes--;
@@ -185,10 +207,12 @@  discard block
 block discarded – undo
185 207
 		$array = self::mbStringToArray ($str);
186 208
 		$n = -1;
187 209
 		$new = Array();
188
-		foreach ($array as $char) {
210
+		foreach ($array as $char)
211
+		{
189 212
 			$n++;
190 213
 			if ($n < $len) $new []= $char;
191
-			elseif ($n == $len) {
214
+			elseif ($n == $len)
215
+			{
192 216
 				$new []= $glue . $char;
193 217
 				$n = 0;
194 218
 			}
@@ -209,7 +233,8 @@  discard block
 block discarded – undo
209 233
 		if (empty($str)) return false;
210 234
 		$len = mb_strlen($str);
211 235
 		$array = array();
212
-		for ($i = 0; $i < $len; $i++) {
236
+		for ($i = 0; $i < $len; $i++)
237
+		{
213 238
 			$array[] = mb_substr($str, $i, 1);
214 239
 		}
215 240
 		return $array;
Please login to merge, or discard this patch.
build/CodeIgniter/Sniffs/Operators/LogicalOperatorAndSniff.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
35 35
 	/**
36 36
      * Returns an array of tokens this test wants to listen for: symbolic and literal operators and.
37 37
      *
38
-     * @return array
38
+     * @return integer[]
39 39
      */
40 40
     public function register()
41 41
     {
Please login to merge, or discard this patch.
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -30,8 +30,7 @@  discard block
 block discarded – undo
30 30
 use PHP_CodeSniffer\Sniffs\Sniff;
31 31
 use PHP_CodeSniffer\Files\File;
32 32
 
33
-class LogicalOperatorAndSniff implements Sniff
34
-{
33
+class LogicalOperatorAndSniff implements Sniff {
35 34
 	/**
36 35
      * Returns an array of tokens this test wants to listen for: symbolic and literal operators and.
37 36
      *
@@ -63,7 +62,8 @@  discard block
 block discarded – undo
63 62
         $operator_string = $operator_token['content'];
64 63
         $operator_code = $operator_token['code'];
65 64
 
66
-        if ($operator_string !== strtoupper($operator_string)) {
65
+        if ($operator_string !== strtoupper($operator_string))
66
+        {
67 67
             $error_message = 'Logical operator should be in upper case;'
68 68
                 . ' use "' . strtoupper($operator_string)
69 69
                 . '" instead of "' . $operator_string . '"';
Please login to merge, or discard this patch.
build/CodeIgniter/Sniffs/Operators/UppercaseLogicalOperatorOrSniff.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
35 35
     /**
36 36
      * Returns an array of tokens this test wants to listen for: literal and symbolic operators or.
37 37
      *
38
-     * @return array
38
+     * @return integer[]
39 39
      */
40 40
     public function register()
41 41
     {
Please login to merge, or discard this patch.
Braces   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -30,8 +30,7 @@  discard block
 block discarded – undo
30 30
 use PHP_CodeSniffer\Sniffs\Sniff;
31 31
 use PHP_CodeSniffer\Files\File;
32 32
 
33
-class UppercaseLogicalOperatorOrSniff implements Sniff
34
-{
33
+class UppercaseLogicalOperatorOrSniff implements Sniff {
35 34
     /**
36 35
      * Returns an array of tokens this test wants to listen for: literal and symbolic operators or.
37 36
      *
@@ -64,13 +63,15 @@  discard block
 block discarded – undo
64 63
         $operator_string = $operator_token['content'];
65 64
         $operator_code = $operator_token['code'];
66 65
 
67
-        if ($operator_code == T_BOOLEAN_OR) {
66
+        if ($operator_code == T_BOOLEAN_OR)
67
+        {
68 68
             $error_message = 'Logical operator "' . $operator_string
69 69
                 . '" is prohibited; use "OR" instead';
70 70
             $phpcsFile->addError($error_message, $stackPtr, 'UseOf||InsteadOfOR');
71 71
         }
72 72
         // it is literal, if it is not symbolic
73
-        else if ($operator_string !== strtoupper($operator_string)) {
73
+        else if ($operator_string !== strtoupper($operator_string))
74
+        {
74 75
             $error_message = 'Logical operator should be in upper case;'
75 76
                 . ' use "' . strtoupper($operator_string)
76 77
                 . '" instead of "' . $operator_string . '"';
Please login to merge, or discard this patch.
build/CodeIgniter/Sniffs/Strings/DoubleQuoteUsageSniff.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	 * @param string               $dblQtString The double-quoted string content,
88 88
 	 *                                          i.e. without quotes.
89 89
 	 *
90
-	 * @return void
90
+	 * @return boolean
91 91
 	 */
92 92
 	protected function processDoubleQuotedString (File $phpcsFile, $stackPtr, $dblQtString)
93 93
 	{
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 	 * @param string               $sglQtString The single-quoted string content,
135 135
 	 *                                          i.e. without quotes.
136 136
 	 *
137
-	 * @return void
137
+	 * @return boolean
138 138
 	 */
139 139
 	protected function processSingleQuotedString (File $phpcsFile, $stackPtr, $sglQtString)
140 140
 	{
Please login to merge, or discard this patch.
Braces   +95 added lines, -46 removed lines patch added patch discarded remove patch
@@ -35,8 +35,7 @@  discard block
 block discarded – undo
35 35
  * @license   http://thomas.ernest.fr/developement/php_cs/licence GNU General Public License
36 36
  * @link      http://pear.php.net/package/PHP_CodeSniffer
37 37
  */
38
-class VariableUsageSniff implements Sniff
39
-{
38
+class VariableUsageSniff implements Sniff {
40 39
 	/**
41 40
 	 * Returns an array of tokens this test wants to listen for.
42 41
 	 *
@@ -70,9 +69,12 @@  discard block
 block discarded – undo
70 69
 		// makes sure that it is about a double quote string,
71 70
 		// since variables are not parsed out of double quoted string
72 71
 		$openDblQtStr = substr($string, 0, 1);
73
-		if (0 === strcmp($openDblQtStr, '"')) {
72
+		if (0 === strcmp($openDblQtStr, '"'))
73
+		{
74 74
 			$this->processDoubleQuotedString($phpcsFile, $stackPtr, $string);
75
-		} else if (0 === strcmp($openDblQtStr, "'")) {
75
+		}
76
+		else if (0 === strcmp($openDblQtStr, "'"))
77
+		{
76 78
 			$this->processSingleQuotedString($phpcsFile, $stackPtr, $string);
77 79
 		}
78 80
 	}//end process()
@@ -95,25 +97,34 @@  discard block
 block discarded – undo
95 97
 		$strTokens = token_get_all('<?php '.$dblQtString);
96 98
 		$strPtr = 1; // skip php opening tag added by ourselves
97 99
 		$requireDblQuotes = FALSE;
98
-		while ($strPtr < count($strTokens)) {
100
+		while ($strPtr < count($strTokens))
101
+		{
99 102
 			$strToken = $strTokens[$strPtr];
100
-			if (is_array($strToken)) {
101
-				if (in_array($strToken[0], array(T_DOLLAR_OPEN_CURLY_BRACES, T_CURLY_OPEN))) {
103
+			if (is_array($strToken))
104
+			{
105
+				if (in_array($strToken[0], array(T_DOLLAR_OPEN_CURLY_BRACES, T_CURLY_OPEN)))
106
+				{
102 107
 					$strPtr++;
103
-					try {
108
+					try
109
+					{
104 110
 						$this->_parseVariable($strTokens, $strPtr);
105
-					} catch (Exception $err) {
111
+					}
112
+					catch (Exception $err)
113
+					{
106 114
 						$error = 'There is no variable, object nor array between curly braces. Please use the escape char for $ or {.';
107 115
 						$phpcsFile->addError($error, $stackPtr);
108 116
 					}
109 117
 					$variableFound = TRUE;
110
-					if ('}' !== $strTokens[$strPtr]) {
118
+					if ('}' !== $strTokens[$strPtr])
119
+					{
111 120
 						$error = 'There is no matching closing curly brace.';
112 121
 						$phpcsFile->addError($error, $stackPtr);
113 122
 					}
114 123
 					// don't move forward, since it will be done in the main loop
115 124
 					// $strPtr++;
116
-				} else if (T_VARIABLE === $strToken[0]) {
125
+				}
126
+				else if (T_VARIABLE === $strToken[0])
127
+				{
117 128
 					$variableFound = TRUE;
118 129
 					$error = "Variable {$strToken[1]} in double-quoted strings should be enclosed with curly braces. Please consider {{$strToken[1]}}";
119 130
 					$phpcsFile->addError($error, $stackPtr);
@@ -141,10 +152,13 @@  discard block
 block discarded – undo
141 152
 		$variableFound = FALSE;
142 153
 		$strTokens = token_get_all('<?php '.$sglQtString);
143 154
 		$strPtr = 1; // skip php opening tag added by ourselves
144
-		while ($strPtr < count($strTokens)) {
155
+		while ($strPtr < count($strTokens))
156
+		{
145 157
 			$strToken = $strTokens[$strPtr];
146
-			if (is_array($strToken)) {
147
-				if (T_VARIABLE === $strToken[0]) {
158
+			if (is_array($strToken))
159
+			{
160
+				if (T_VARIABLE === $strToken[0])
161
+				{
148 162
 					$error = "Variables like {$strToken[1]} should be in double-quoted strings only.";
149 163
 					$phpcsFile->addError($error, $stackPtr);
150 164
 				}
@@ -173,25 +187,34 @@  discard block
 block discarded – undo
173 187
 	 */
174 188
 	private function _parseVariable ($strTokens, &$strPtr)
175 189
 	{
176
-		if ( ! in_array($strTokens[$strPtr][0], array(T_VARIABLE, T_STRING_VARNAME))) {
190
+		if ( ! in_array($strTokens[$strPtr][0], array(T_VARIABLE, T_STRING_VARNAME)))
191
+		{
177 192
 			throw new Exception ('Expected variable name.');
178 193
 		}
179 194
 		$var = $strTokens[$strPtr][1];
180 195
 		$strPtr++;
181 196
 		$startStrPtr = $strPtr;
182
-		try {
197
+		try
198
+		{
183 199
 			$attr = $this->_parseObjectAttribute($strTokens, $strPtr);
184 200
 			return array ('obj' => $var, 'attr' => $attr);
185
-		} catch (Exception $err) {
186
-			if ($strPtr !== $startStrPtr) {
201
+		}
202
+		catch (Exception $err)
203
+		{
204
+			if ($strPtr !== $startStrPtr)
205
+			{
187 206
 				throw $err;
188 207
 			}
189 208
 		}
190
-		try {
209
+		try
210
+		{
191 211
 			$idx = $this->_parseArrayIndexes($strTokens, $strPtr);
192 212
 			return array ('arr' => $var, 'idx' => $idx);
193
-		} catch (Exception $err) {
194
-			if ($strPtr !== $startStrPtr) {
213
+		}
214
+		catch (Exception $err)
215
+		{
216
+			if ($strPtr !== $startStrPtr)
217
+			{
195 218
 				throw $err;
196 219
 			}
197 220
 		}
@@ -217,29 +240,39 @@  discard block
 block discarded – undo
217 240
 	 */
218 241
 	private function _parseObjectAttribute ($strTokens, &$strPtr)
219 242
 	{
220
-		if (T_OBJECT_OPERATOR !== $strTokens[$strPtr][0]) {
243
+		if (T_OBJECT_OPERATOR !== $strTokens[$strPtr][0])
244
+		{
221 245
 			throw new Exception ('Expected ->.');
222 246
 		}
223 247
 		$strPtr++;
224
-		if (T_STRING !== $strTokens[$strPtr][0]) {
248
+		if (T_STRING !== $strTokens[$strPtr][0])
249
+		{
225 250
 			throw new Exception ('Expected an object attribute.');
226 251
 		}
227 252
 		$attr = $strTokens[$strPtr][1];
228 253
 		$strPtr++;
229 254
 		$startStrPtr = $strPtr;
230
-		try {
255
+		try
256
+		{
231 257
 			$sub_attr = $this->_parseObjectAttribute($strTokens, $strPtr);
232 258
 			return array ('obj' => $attr, 'attr' => $sub_attr);
233
-		} catch (Exception $err) {
234
-			if ($strPtr !== $startStrPtr) {
259
+		}
260
+		catch (Exception $err)
261
+		{
262
+			if ($strPtr !== $startStrPtr)
263
+			{
235 264
 				throw $err;
236 265
 			}
237 266
 		}
238
-		try {
267
+		try
268
+		{
239 269
 			$idx = $this->_parseArrayIndexes($strTokens, $strPtr);
240 270
 			return array ('arr' => $attr, 'idx' => $idx);
241
-		} catch (Exception $err) {
242
-			if ($strPtr !== $startStrPtr) {
271
+		}
272
+		catch (Exception $err)
273
+		{
274
+			if ($strPtr !== $startStrPtr)
275
+			{
243 276
 				throw $err;
244 277
 			}
245 278
 		}
@@ -263,13 +296,18 @@  discard block
 block discarded – undo
263 296
 	private function _parseArrayIndexes ($strTokens, &$strPtr)
264 297
 	{
265 298
 		$indexes = array($this->_parseArrayIndex($strTokens, $strPtr));
266
-		try {
267
-			while (1) {
299
+		try
300
+		{
301
+			while (1)
302
+			{
268 303
 				$startStrPtr = $strPtr;
269 304
 				$indexes [] = $this->_parseArrayIndex($strTokens, $strPtr);
270 305
 			}
271
-		} catch (Exception $err) {
272
-			if (0 !== ($strPtr - $startStrPtr)) {
306
+		}
307
+		catch (Exception $err)
308
+		{
309
+			if (0 !== ($strPtr - $startStrPtr))
310
+			{
273 311
 				throw $err;
274 312
 			}
275 313
 			return $indexes;
@@ -292,16 +330,19 @@  discard block
 block discarded – undo
292 330
 	 */
293 331
 	private function _parseArrayIndex ($strTokens, &$strPtr)
294 332
 	{
295
-		if ('[' !== $strTokens[$strPtr]) {
333
+		if ('[' !== $strTokens[$strPtr])
334
+		{
296 335
 			throw new Exception ('Expected [.');
297 336
 		}
298 337
 		$strPtr++;
299
-		if (! in_array($strTokens[$strPtr][0], array(T_CONSTANT_ENCAPSED_STRING, T_LNUMBER))) {
338
+		if (! in_array($strTokens[$strPtr][0], array(T_CONSTANT_ENCAPSED_STRING, T_LNUMBER)))
339
+		{
300 340
 			throw new Exception ('Expected an array index.');
301 341
 		}
302 342
 		$index = $strTokens[$strPtr][1];
303 343
 		$strPtr++;
304
-		if (']' !== $strTokens[$strPtr]) {
344
+		if (']' !== $strTokens[$strPtr])
345
+		{
305 346
 			throw new Exception ('Expected ].');
306 347
 		}
307 348
 		$strPtr++;
@@ -325,8 +366,7 @@  discard block
 block discarded – undo
325 366
  * @license   http://thomas.ernest.fr/developement/php_cs/licence GNU General Public License
326 367
  * @link      http://pear.php.net/package/PHP_CodeSniffer
327 368
  */
328
-class DoubleQuoteUsageSniff extends VariableUsageSniff
329
-{
369
+class DoubleQuoteUsageSniff extends VariableUsageSniff {
330 370
     /**
331 371
      * Returns an array of tokens this test wants to listen for.
332 372
      *
@@ -361,9 +401,12 @@  discard block
 block discarded – undo
361 401
         // clean the enclosing quotes
362 402
         $qtString = substr($qtString, 1, strlen($qtString) - 1 - 1);
363 403
 
364
-        if (0 === strcmp($open_qt_str, '"')) {
404
+        if (0 === strcmp($open_qt_str, '"'))
405
+        {
365 406
             $this->processDoubleQuotedString($phpcsFile, $stackPtr, $qtString);
366
-        } else if (0 === strcmp($open_qt_str, "'")) {
407
+        }
408
+        else if (0 === strcmp($open_qt_str, "'"))
409
+        {
367 410
             $this->processSingleQuotedString($phpcsFile, $stackPtr, $qtString);
368 411
         }
369 412
     }//end process()
@@ -393,7 +436,8 @@  discard block
 block discarded – undo
393 436
         ) {
394 437
             $error = 'Single-quoted strings should be used unless it contains variables, special chars like \n or single quotes.';
395 438
             $phpcsFile->addError($error, $stackPtr);
396
-        } else if (false !== $smpl_qt_at && false !== $dbl_qt_at
439
+        }
440
+        else if (false !== $smpl_qt_at && false !== $dbl_qt_at
397 441
             && false === $has_variable && false === $has_specific_sequence
398 442
         ) {
399 443
             $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.';
@@ -423,7 +467,8 @@  discard block
 block discarded – undo
423 467
         $has_variable = parent::processSingleQuotedString($phpcsFile, $stackPtr, "'".$qtString."'");
424 468
         $dbl_qt_at = strpos($qtString, '"');
425 469
         $smpl_qt_at = strpos($qtString, "'");
426
-        if (false === $has_variable && false !== $smpl_qt_at && false === $dbl_qt_at) {
470
+        if (false === $has_variable && false !== $smpl_qt_at && false === $dbl_qt_at)
471
+        {
427 472
             $warning = 'You may also use double-quoted strings if the string contains single quotes, so you do not have to use escape characters.';
428 473
             $phpcsFile->addWarning($warning, $stackPtr);
429 474
         }
@@ -445,14 +490,18 @@  discard block
 block discarded – undo
445 490
     {
446 491
         $hasSpecificSequence = FALSE;
447 492
         $specialMeaningStrs = array('\n', '\r', '\t', '\v', '\f');
448
-        foreach ($specialMeaningStrs as $splStr) {
449
-            if (FALSE !== strpos($string, $splStr)) {
493
+        foreach ($specialMeaningStrs as $splStr)
494
+        {
495
+            if (FALSE !== strpos($string, $splStr))
496
+            {
450 497
                 $hasSpecificSequence = TRUE;
451 498
             }
452 499
         }
453 500
         $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)) {
501
+        foreach ($specialMeaningPtrns as $splPtrn)
502
+        {
503
+            if (1 === preg_match("/{$splPtrn}/", $string))
504
+            {
456 505
                 $hasSpecificSequence = TRUE;
457 506
             }
458 507
         }
Please login to merge, or discard this patch.
build/CodeIgniter/Sniffs/WhiteSpace/LogicalNotSpacingSniff.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@
 block discarded – undo
36 36
     /**
37 37
      * Returns an array of tokens this test wants to listen for.
38 38
      *
39
-     * @return array
39
+     * @return string[]
40 40
      */
41 41
     public function register()
42 42
     {
Please login to merge, or discard this patch.
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -30,8 +30,7 @@  discard block
 block discarded – undo
30 30
 use PHP_CodeSniffer\Sniffs\Sniff;
31 31
 use PHP_CodeSniffer\Files\File;
32 32
 
33
-class LogicalNotSpacingSniff implements Sniff
34
-{
33
+class LogicalNotSpacingSniff implements Sniff {
35 34
 
36 35
     /**
37 36
      * Returns an array of tokens this test wants to listen for.
@@ -63,7 +62,8 @@  discard block
 block discarded – undo
63 62
 
64 63
         $previous_token = $tokens[$stackPtr - 1];
65 64
         $next_token = $tokens[$stackPtr + 1];
66
-        if (T_WHITESPACE !== $previous_token['code'] || T_WHITESPACE !== $next_token['code']) {
65
+        if (T_WHITESPACE !== $previous_token['code'] || T_WHITESPACE !== $next_token['code'])
66
+        {
67 67
             $error = 'Logical operator ! should always be preceded and followed with a whitespace.';
68 68
             $phpcsFile->addError($error, $stackPtr);
69 69
         }
Please login to merge, or discard this patch.
build/CodeIgniter/UnusedSniffs/Files/ClosingLocationCommentSniff.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
     /**
51 51
      * Returns an array of tokens this test wants to listen for.
52 52
      *
53
-     * @return array
53
+     * @return integer[]
54 54
      */
55 55
     public function register()
56 56
     {
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
      * application root. Parent directory of the application root are allowed
135 135
      * but not mandatory.
136 136
      *
137
-     * @return string|bool The relative path from $appRoot to $filePath, or
137
+     * @return false|string The relative path from $appRoot to $filePath, or
138 138
      * false if $appRoot cannot be found in $filePath.
139 139
      */
140 140
     private static function _getLocationPath ($filePath, $appRoot)
Please login to merge, or discard this patch.
Braces   +27 added lines, -14 removed lines patch added patch discarded remove patch
@@ -43,8 +43,7 @@  discard block
 block discarded – undo
43 43
 use PHP_CodeSniffer\Files\File;
44 44
 use PHP_CodeSniffer\Util\Common;
45 45
 
46
-class ClosingLocationCommentSniff extends AbstractClosingCommentSniff
47
-{
46
+class ClosingLocationCommentSniff extends AbstractClosingCommentSniff {
48 47
     public $applicationRoot = '/application/';
49 48
 
50 49
     /**
@@ -73,8 +72,10 @@  discard block
 block discarded – undo
73 72
     public function process(File $phpcsFile, $stackPtr)
74 73
     {
75 74
         // We are only interested if this is the first open tag.
76
-        if ($stackPtr !== 0) {
77
-            if ($phpcsFile->findPrevious(T_OPEN_TAG, ($stackPtr - 1)) !== false) {
75
+        if ($stackPtr !== 0)
76
+        {
77
+            if ($phpcsFile->findPrevious(T_OPEN_TAG, ($stackPtr - 1)) !== false)
78
+            {
78 79
                 return;
79 80
             }
80 81
         }
@@ -84,7 +85,8 @@  discard block
 block discarded – undo
84 85
         // removes the application root from the beginning of the file path
85 86
         $locationPath = self::_getLocationPath($filePath, $this->_getAppRoot());
86 87
         // add an error, if application root doesn't exist in current file path
87
-        if (false === $locationPath) {
88
+        if (false === $locationPath)
89
+        {
88 90
             $error = 'Unable to find "' . $this->_getAppRoot() . '" in file path "' . $filePath . '". Please set your project\'s application root.';
89 91
             $phpcsFile->addError($error, count($tokens) - 1);
90 92
             return;
@@ -101,21 +103,28 @@  discard block
 block discarded – undo
101 103
         ) {
102 104
             $token = $tokens[$currentToken];
103 105
             $tokenCode = $token['code'];
104
-            if (T_COMMENT === $tokenCode) {
106
+            if (T_COMMENT === $tokenCode)
107
+            {
105 108
                 $commentString = self::_getCommentContent($token['content']);
106
-                if (0 === strcmp($commentString, $commentTemplate)) {
109
+                if (0 === strcmp($commentString, $commentTemplate))
110
+                {
107 111
                     $hasClosingLocationComment = true;
108 112
                 }
109
-            } else if (T_WHITESPACE === $tokenCode) {
113
+            }
114
+            else if (T_WHITESPACE === $tokenCode)
115
+            {
110 116
                 // Whitespaces are allowed between the closing file comment,
111 117
                 //other comments and end of file
112
-            } else {
118
+            }
119
+            else
120
+            {
113 121
                 $isNotAWhitespaceOrAComment = true;
114 122
             }
115 123
             $currentToken--;
116 124
         }
117 125
 
118
-        if ( ! $hasClosingLocationComment) {
126
+        if ( ! $hasClosingLocationComment)
127
+        {
119 128
             $error = 'No comment block marks the end of file instead of the closing PHP tag. Please add a comment block containing only "' . $commentTemplate . '".';
120 129
             $phpcsFile->addError($error, $currentToken);
121 130
         }
@@ -142,14 +151,17 @@  discard block
 block discarded – undo
142 151
         // removes the path to application root
143 152
         // from the beginning of the file path
144 153
         $appRootAt = strpos($filePath, $appRoot);
145
-        if (false === $appRootAt) {
154
+        if (false === $appRootAt)
155
+        {
146 156
             return false;
147 157
         }
148 158
         $localPath = substr($filePath, $appRootAt + strlen($appRoot));
149 159
         // ensures the location path to be a relative path starting with "./".
150
-        if ( ! self::_stringStartsWith($localPath, './')) {
160
+        if ( ! self::_stringStartsWith($localPath, './'))
161
+        {
151 162
             $localPath = './' . $localPath;
152
-        } else if ( ! self::_stringStartsWith($localPath, '.')
163
+        }
164
+        else if ( ! self::_stringStartsWith($localPath, '.')
153 165
             && self::_stringStartsWith($localPath, '/')
154 166
         ) {
155 167
             $localPath = '.' . $localPath;
@@ -172,7 +184,8 @@  discard block
 block discarded – undo
172 184
     private function _getAppRoot()
173 185
     {
174 186
         $appRoot = Common::getConfigData('ci_application_root');
175
-        if (null === $appRoot) {
187
+        if (null === $appRoot)
188
+        {
176 189
             $appRoot = $this->applicationRoot;
177 190
         }
178 191
         return $appRoot;
Please login to merge, or discard this patch.
RoboFile.php 1 patch
Doc Comments   +5 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,6 +2,10 @@  discard block
 block discarded – undo
2 2
 if ( ! function_exists('glob_recursive'))
3 3
 {
4 4
 	// Does not support flag GLOB_BRACE
5
+
6
+	/**
7
+	 * @param string $pattern
8
+	 */
5 9
 	function glob_recursive($pattern, $flags = 0)
6 10
 	{
7 11
 		$files = glob($pattern, $flags);
@@ -320,7 +324,7 @@  discard block
 block discarded – undo
320 324
 	 * Shortcut for joining an array of command arguments
321 325
 	 * and then running it
322 326
 	 *
323
-	 * @param array $cmd_parts - command arguments
327
+	 * @param string[] $cmd_parts - command arguments
324 328
 	 * @param string $join_on - what to join the command arguments with
325 329
 	 */
326 330
 	protected function _run(array $cmd_parts, $join_on = ' ')
Please login to merge, or discard this patch.