GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — develop ( 699b70...879176 )
by Chris
13:23
created
Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php 3 patches
Indentation   +276 added lines, -276 removed lines patch added patch discarded remove patch
@@ -30,282 +30,282 @@
 block discarded – undo
30 30
 class Generic_Sniffs_ControlStructures_InlineControlStructureSniff implements PHP_CodeSniffer_Sniff
31 31
 {
32 32
 
33
-    /**
34
-     * A list of tokenizers this sniff supports.
35
-     *
36
-     * @var array
37
-     */
38
-    public $supportedTokenizers = array(
39
-                                   'PHP',
40
-                                   'JS',
41
-                                  );
42
-
43
-    /**
44
-     * If true, an error will be thrown; otherwise a warning.
45
-     *
46
-     * @var bool
47
-     */
48
-    public $error = true;
49
-
50
-
51
-    /**
52
-     * Returns an array of tokens this test wants to listen for.
53
-     *
54
-     * @return array
55
-     */
56
-    public function register()
57
-    {
58
-        return array(
59
-                T_IF,
60
-                T_ELSE,
61
-                T_ELSEIF,
62
-                T_FOREACH,
63
-                T_WHILE,
64
-                T_DO,
65
-                T_SWITCH,
66
-                T_FOR,
67
-               );
68
-
69
-    }//end register()
70
-
71
-
72
-    /**
73
-     * Processes this test, when one of its tokens is encountered.
74
-     *
75
-     * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
76
-     * @param int                  $stackPtr  The position of the current token in the
77
-     *                                        stack passed in $tokens.
78
-     *
79
-     * @return void
80
-     */
81
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
82
-    {
83
-        $tokens = $phpcsFile->getTokens();
84
-
85
-        if (isset($tokens[$stackPtr]['scope_opener']) === true) {
86
-            $phpcsFile->recordMetric($stackPtr, 'Control structure defined inline', 'no');
87
-            return;
88
-        }
89
-
90
-        // Ignore the ELSE in ELSE IF. We'll process the IF part later.
91
-        if ($tokens[$stackPtr]['code'] === T_ELSE) {
92
-            $next = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true);
93
-            if ($tokens[$next]['code'] === T_IF) {
94
-                return;
95
-            }
96
-        }
97
-
98
-        if ($tokens[$stackPtr]['code'] === T_WHILE) {
99
-            // This could be from a DO WHILE, which doesn't have an opening brace.
100
-            $lastContent = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
101
-            if ($tokens[$lastContent]['code'] === T_CLOSE_CURLY_BRACKET) {
102
-                $brace = $tokens[$lastContent];
103
-                if (isset($brace['scope_condition']) === true) {
104
-                    $condition = $tokens[$brace['scope_condition']];
105
-                    if ($condition['code'] === T_DO) {
106
-                        return;
107
-                    }
108
-                }
109
-            }
110
-
111
-            // In Javascript DO WHILE loops without curly braces are legal. This
112
-            // is only valid if a single statement is present between the DO and
113
-            // the WHILE. We can detect this by checking only a single semicolon
114
-            // is present between them.
115
-            if ($phpcsFile->tokenizerType === 'JS') {
116
-                $lastDo        = $phpcsFile->findPrevious(T_DO, ($stackPtr - 1));
117
-                $lastSemicolon = $phpcsFile->findPrevious(T_SEMICOLON, ($stackPtr - 1));
118
-                if ($lastDo !== false && $lastSemicolon !== false && $lastDo < $lastSemicolon) {
119
-                    $precedingSemicolon = $phpcsFile->findPrevious(T_SEMICOLON, ($lastSemicolon - 1));
120
-                    if ($precedingSemicolon === false || $precedingSemicolon < $lastDo) {
121
-                        return;
122
-                    }
123
-                }
124
-            }
125
-        }//end if
126
-
127
-        // This is a control structure without an opening brace,
128
-        // so it is an inline statement.
129
-        if ($this->error === true) {
130
-            $fix = $phpcsFile->addFixableError('Inline control structures are not allowed', $stackPtr, 'NotAllowed');
131
-        } else {
132
-            $fix = $phpcsFile->addFixableWarning('Inline control structures are discouraged', $stackPtr, 'Discouraged');
133
-        }
134
-
135
-        $phpcsFile->recordMetric($stackPtr, 'Control structure defined inline', 'yes');
136
-
137
-        // Stop here if we are not fixing the error.
138
-        if ($fix !== true) {
139
-            return;
140
-        }
141
-
142
-        $phpcsFile->fixer->beginChangeset();
143
-        if (isset($tokens[$stackPtr]['parenthesis_closer']) === true) {
144
-            $closer = $tokens[$stackPtr]['parenthesis_closer'];
145
-        } else {
146
-            $closer = $stackPtr;
147
-        }
148
-
149
-        if ($tokens[($closer + 1)]['code'] === T_WHITESPACE
150
-            || $tokens[($closer + 1)]['code'] === T_SEMICOLON
151
-        ) {
152
-            $phpcsFile->fixer->addContent($closer, ' {');
153
-        } else {
154
-            $phpcsFile->fixer->addContent($closer, ' { ');
155
-        }
156
-
157
-        $fixableScopeOpeners = $this->register();
158
-
159
-        $lastNonEmpty = $closer;
160
-        for ($end = ($closer + 1); $end < $phpcsFile->numTokens; $end++) {
161
-            if ($tokens[$end]['code'] === T_SEMICOLON) {
162
-                break;
163
-            }
164
-
165
-            if ($tokens[$end]['code'] === T_CLOSE_TAG) {
166
-                $end = $lastNonEmpty;
167
-                break;
168
-            }
169
-
170
-            if (in_array($tokens[$end]['code'], $fixableScopeOpeners) === true
171
-                && isset($tokens[$end]['scope_opener']) === false
172
-            ) {
173
-                // The best way to fix nested inline scopes is middle-out.
174
-                // So skip this one. It will be detected and fixed on a future loop.
175
-                $phpcsFile->fixer->rollbackChangeset();
176
-                return;
177
-            }
178
-
179
-            if (isset($tokens[$end]['scope_opener']) === true) {
180
-                $type = $tokens[$end]['code'];
181
-                $end  = $tokens[$end]['scope_closer'];
182
-                if ($type === T_DO || $type === T_IF || $type === T_ELSEIF) {
183
-                    $next = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($end + 1), null, true);
184
-                    if ($next === false) {
185
-                        break;
186
-                    }
187
-
188
-                    $nextType = $tokens[$next]['code'];
189
-
190
-                    // Let additional conditions loop and find their ending.
191
-                    if (($type === T_IF
192
-                        || $type === T_ELSEIF)
193
-                        && ($nextType === T_ELSEIF
194
-                        || $nextType === T_ELSE)
195
-                    ) {
196
-                        continue;
197
-                    }
198
-
199
-                    // Account for DO... WHILE conditions.
200
-                    if ($type === T_DO && $nextType === T_WHILE) {
201
-                        $end = $phpcsFile->findNext(T_SEMICOLON, ($next + 1));
202
-                    }
203
-                }//end if
204
-
205
-                if ($tokens[$end]['code'] !== T_END_HEREDOC
206
-                    && $tokens[$end]['code'] !== T_END_NOWDOC
207
-                ) {
208
-                    break;
209
-                }
210
-            }//end if
211
-
212
-            if (isset($tokens[$end]['parenthesis_closer']) === true) {
213
-                $end          = $tokens[$end]['parenthesis_closer'];
214
-                $lastNonEmpty = $end;
215
-                continue;
216
-            }
217
-
218
-            if ($tokens[$end]['code'] !== T_WHITESPACE) {
219
-                $lastNonEmpty = $end;
220
-            }
221
-        }//end for
222
-
223
-        if ($end === $phpcsFile->numTokens) {
224
-            $end = $lastNonEmpty;
225
-        }
226
-
227
-        $next = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($end + 1), null, true);
228
-
229
-        if ($next === false || $tokens[$next]['line'] !== $tokens[$end]['line']) {
230
-            // Looks for completely empty statements.
231
-            $next = $phpcsFile->findNext(T_WHITESPACE, ($closer + 1), ($end + 1), true);
232
-
233
-            // Account for a comment on the end of the line.
234
-            for ($endLine = $end; $endLine < $phpcsFile->numTokens; $endLine++) {
235
-                if (isset($tokens[($endLine + 1)]) === false
236
-                    || $tokens[$endLine]['line'] !== $tokens[($endLine + 1)]['line']
237
-                ) {
238
-                    break;
239
-                }
240
-            }
241
-
242
-            if ($tokens[$endLine]['code'] !== T_COMMENT) {
243
-                $endLine = $end;
244
-            }
245
-        } else {
246
-            $next    = ($end + 1);
247
-            $endLine = $end;
248
-        }
249
-
250
-        if ($next !== $end) {
251
-            if ($endLine !== $end) {
252
-                $endToken     = $endLine;
253
-                $addedContent = '';
254
-            } else {
255
-                $endToken     = $end;
256
-                $addedContent = $phpcsFile->eolChar;
257
-
258
-                if ($tokens[$end]['code'] !== T_SEMICOLON
259
-                    && $tokens[$end]['code'] !== T_CLOSE_CURLY_BRACKET
260
-                ) {
261
-                    $phpcsFile->fixer->addContent($end, '; ');
262
-                }
263
-            }
264
-
265
-            $next = $phpcsFile->findNext(T_WHITESPACE, ($endToken + 1), null, true);
266
-            if ($next !== false
267
-                && ($tokens[$next]['code'] === T_ELSE
268
-                || $tokens[$next]['code'] === T_ELSEIF)
269
-            ) {
270
-                $phpcsFile->fixer->addContentBefore($next, '} ');
271
-            } else {
272
-                $indent = '';
273
-                for ($first = $stackPtr; $first > 0; $first--) {
274
-                    if ($first === 1
275
-                        || $tokens[($first - 1)]['line'] !== $tokens[$first]['line']
276
-                    ) {
277
-                        break;
278
-                    }
279
-                }
280
-
281
-                if ($tokens[$first]['code'] === T_WHITESPACE) {
282
-                    $indent = $tokens[$first]['content'];
283
-                } else if ($tokens[$first]['code'] === T_INLINE_HTML
284
-                    || $tokens[$first]['code'] === T_OPEN_TAG
285
-                ) {
286
-                    $addedContent = '';
287
-                }
288
-
289
-                $addedContent .= $indent.'}';
290
-                if ($next !== false && $tokens[$endToken]['code'] === T_COMMENT) {
291
-                    $addedContent .= $phpcsFile->eolChar;
292
-                }
293
-
294
-                $phpcsFile->fixer->addContent($endToken, $addedContent);
295
-            }//end if
296
-        } else {
297
-            if ($endLine !== $end) {
298
-                $phpcsFile->fixer->replaceToken($end, '');
299
-                $phpcsFile->fixer->addNewlineBefore($endLine);
300
-                $phpcsFile->fixer->addContent($endLine, '}');
301
-            } else {
302
-                $phpcsFile->fixer->replaceToken($end, '}');
303
-            }
304
-        }//end if
305
-
306
-        $phpcsFile->fixer->endChangeset();
307
-
308
-    }//end process()
33
+	 /**
34
+	  * A list of tokenizers this sniff supports.
35
+	  *
36
+	  * @var array
37
+	  */
38
+	 public $supportedTokenizers = array(
39
+											  'PHP',
40
+											  'JS',
41
+											 );
42
+
43
+	 /**
44
+	  * If true, an error will be thrown; otherwise a warning.
45
+	  *
46
+	  * @var bool
47
+	  */
48
+	 public $error = true;
49
+
50
+
51
+	 /**
52
+	  * Returns an array of tokens this test wants to listen for.
53
+	  *
54
+	  * @return array
55
+	  */
56
+	 public function register()
57
+	 {
58
+		  return array(
59
+					 T_IF,
60
+					 T_ELSE,
61
+					 T_ELSEIF,
62
+					 T_FOREACH,
63
+					 T_WHILE,
64
+					 T_DO,
65
+					 T_SWITCH,
66
+					 T_FOR,
67
+					);
68
+
69
+	 }//end register()
70
+
71
+
72
+	 /**
73
+	  * Processes this test, when one of its tokens is encountered.
74
+	  *
75
+	  * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
76
+	  * @param int                  $stackPtr  The position of the current token in the
77
+	  *                                        stack passed in $tokens.
78
+	  *
79
+	  * @return void
80
+	  */
81
+	 public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
82
+	 {
83
+		  $tokens = $phpcsFile->getTokens();
84
+
85
+		  if (isset($tokens[$stackPtr]['scope_opener']) === true) {
86
+				$phpcsFile->recordMetric($stackPtr, 'Control structure defined inline', 'no');
87
+				return;
88
+		  }
89
+
90
+		  // Ignore the ELSE in ELSE IF. We'll process the IF part later.
91
+		  if ($tokens[$stackPtr]['code'] === T_ELSE) {
92
+				$next = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true);
93
+				if ($tokens[$next]['code'] === T_IF) {
94
+					 return;
95
+				}
96
+		  }
97
+
98
+		  if ($tokens[$stackPtr]['code'] === T_WHILE) {
99
+				// This could be from a DO WHILE, which doesn't have an opening brace.
100
+				$lastContent = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
101
+				if ($tokens[$lastContent]['code'] === T_CLOSE_CURLY_BRACKET) {
102
+					 $brace = $tokens[$lastContent];
103
+					 if (isset($brace['scope_condition']) === true) {
104
+						  $condition = $tokens[$brace['scope_condition']];
105
+						  if ($condition['code'] === T_DO) {
106
+								return;
107
+						  }
108
+					 }
109
+				}
110
+
111
+				// In Javascript DO WHILE loops without curly braces are legal. This
112
+				// is only valid if a single statement is present between the DO and
113
+				// the WHILE. We can detect this by checking only a single semicolon
114
+				// is present between them.
115
+				if ($phpcsFile->tokenizerType === 'JS') {
116
+					 $lastDo        = $phpcsFile->findPrevious(T_DO, ($stackPtr - 1));
117
+					 $lastSemicolon = $phpcsFile->findPrevious(T_SEMICOLON, ($stackPtr - 1));
118
+					 if ($lastDo !== false && $lastSemicolon !== false && $lastDo < $lastSemicolon) {
119
+						  $precedingSemicolon = $phpcsFile->findPrevious(T_SEMICOLON, ($lastSemicolon - 1));
120
+						  if ($precedingSemicolon === false || $precedingSemicolon < $lastDo) {
121
+								return;
122
+						  }
123
+					 }
124
+				}
125
+		  }//end if
126
+
127
+		  // This is a control structure without an opening brace,
128
+		  // so it is an inline statement.
129
+		  if ($this->error === true) {
130
+				$fix = $phpcsFile->addFixableError('Inline control structures are not allowed', $stackPtr, 'NotAllowed');
131
+		  } else {
132
+				$fix = $phpcsFile->addFixableWarning('Inline control structures are discouraged', $stackPtr, 'Discouraged');
133
+		  }
134
+
135
+		  $phpcsFile->recordMetric($stackPtr, 'Control structure defined inline', 'yes');
136
+
137
+		  // Stop here if we are not fixing the error.
138
+		  if ($fix !== true) {
139
+				return;
140
+		  }
141
+
142
+		  $phpcsFile->fixer->beginChangeset();
143
+		  if (isset($tokens[$stackPtr]['parenthesis_closer']) === true) {
144
+				$closer = $tokens[$stackPtr]['parenthesis_closer'];
145
+		  } else {
146
+				$closer = $stackPtr;
147
+		  }
148
+
149
+		  if ($tokens[($closer + 1)]['code'] === T_WHITESPACE
150
+				|| $tokens[($closer + 1)]['code'] === T_SEMICOLON
151
+		  ) {
152
+				$phpcsFile->fixer->addContent($closer, ' {');
153
+		  } else {
154
+				$phpcsFile->fixer->addContent($closer, ' { ');
155
+		  }
156
+
157
+		  $fixableScopeOpeners = $this->register();
158
+
159
+		  $lastNonEmpty = $closer;
160
+		  for ($end = ($closer + 1); $end < $phpcsFile->numTokens; $end++) {
161
+				if ($tokens[$end]['code'] === T_SEMICOLON) {
162
+					 break;
163
+				}
164
+
165
+				if ($tokens[$end]['code'] === T_CLOSE_TAG) {
166
+					 $end = $lastNonEmpty;
167
+					 break;
168
+				}
169
+
170
+				if (in_array($tokens[$end]['code'], $fixableScopeOpeners) === true
171
+					 && isset($tokens[$end]['scope_opener']) === false
172
+				) {
173
+					 // The best way to fix nested inline scopes is middle-out.
174
+					 // So skip this one. It will be detected and fixed on a future loop.
175
+					 $phpcsFile->fixer->rollbackChangeset();
176
+					 return;
177
+				}
178
+
179
+				if (isset($tokens[$end]['scope_opener']) === true) {
180
+					 $type = $tokens[$end]['code'];
181
+					 $end  = $tokens[$end]['scope_closer'];
182
+					 if ($type === T_DO || $type === T_IF || $type === T_ELSEIF) {
183
+						  $next = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($end + 1), null, true);
184
+						  if ($next === false) {
185
+								break;
186
+						  }
187
+
188
+						  $nextType = $tokens[$next]['code'];
189
+
190
+						  // Let additional conditions loop and find their ending.
191
+						  if (($type === T_IF
192
+								|| $type === T_ELSEIF)
193
+								&& ($nextType === T_ELSEIF
194
+								|| $nextType === T_ELSE)
195
+						  ) {
196
+								continue;
197
+						  }
198
+
199
+						  // Account for DO... WHILE conditions.
200
+						  if ($type === T_DO && $nextType === T_WHILE) {
201
+								$end = $phpcsFile->findNext(T_SEMICOLON, ($next + 1));
202
+						  }
203
+					 }//end if
204
+
205
+					 if ($tokens[$end]['code'] !== T_END_HEREDOC
206
+						  && $tokens[$end]['code'] !== T_END_NOWDOC
207
+					 ) {
208
+						  break;
209
+					 }
210
+				}//end if
211
+
212
+				if (isset($tokens[$end]['parenthesis_closer']) === true) {
213
+					 $end          = $tokens[$end]['parenthesis_closer'];
214
+					 $lastNonEmpty = $end;
215
+					 continue;
216
+				}
217
+
218
+				if ($tokens[$end]['code'] !== T_WHITESPACE) {
219
+					 $lastNonEmpty = $end;
220
+				}
221
+		  }//end for
222
+
223
+		  if ($end === $phpcsFile->numTokens) {
224
+				$end = $lastNonEmpty;
225
+		  }
226
+
227
+		  $next = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($end + 1), null, true);
228
+
229
+		  if ($next === false || $tokens[$next]['line'] !== $tokens[$end]['line']) {
230
+				// Looks for completely empty statements.
231
+				$next = $phpcsFile->findNext(T_WHITESPACE, ($closer + 1), ($end + 1), true);
232
+
233
+				// Account for a comment on the end of the line.
234
+				for ($endLine = $end; $endLine < $phpcsFile->numTokens; $endLine++) {
235
+					 if (isset($tokens[($endLine + 1)]) === false
236
+						  || $tokens[$endLine]['line'] !== $tokens[($endLine + 1)]['line']
237
+					 ) {
238
+						  break;
239
+					 }
240
+				}
241
+
242
+				if ($tokens[$endLine]['code'] !== T_COMMENT) {
243
+					 $endLine = $end;
244
+				}
245
+		  } else {
246
+				$next    = ($end + 1);
247
+				$endLine = $end;
248
+		  }
249
+
250
+		  if ($next !== $end) {
251
+				if ($endLine !== $end) {
252
+					 $endToken     = $endLine;
253
+					 $addedContent = '';
254
+				} else {
255
+					 $endToken     = $end;
256
+					 $addedContent = $phpcsFile->eolChar;
257
+
258
+					 if ($tokens[$end]['code'] !== T_SEMICOLON
259
+						  && $tokens[$end]['code'] !== T_CLOSE_CURLY_BRACKET
260
+					 ) {
261
+						  $phpcsFile->fixer->addContent($end, '; ');
262
+					 }
263
+				}
264
+
265
+				$next = $phpcsFile->findNext(T_WHITESPACE, ($endToken + 1), null, true);
266
+				if ($next !== false
267
+					 && ($tokens[$next]['code'] === T_ELSE
268
+					 || $tokens[$next]['code'] === T_ELSEIF)
269
+				) {
270
+					 $phpcsFile->fixer->addContentBefore($next, '} ');
271
+				} else {
272
+					 $indent = '';
273
+					 for ($first = $stackPtr; $first > 0; $first--) {
274
+						  if ($first === 1
275
+								|| $tokens[($first - 1)]['line'] !== $tokens[$first]['line']
276
+						  ) {
277
+								break;
278
+						  }
279
+					 }
280
+
281
+					 if ($tokens[$first]['code'] === T_WHITESPACE) {
282
+						  $indent = $tokens[$first]['content'];
283
+					 } else if ($tokens[$first]['code'] === T_INLINE_HTML
284
+						  || $tokens[$first]['code'] === T_OPEN_TAG
285
+					 ) {
286
+						  $addedContent = '';
287
+					 }
288
+
289
+					 $addedContent .= $indent.'}';
290
+					 if ($next !== false && $tokens[$endToken]['code'] === T_COMMENT) {
291
+						  $addedContent .= $phpcsFile->eolChar;
292
+					 }
293
+
294
+					 $phpcsFile->fixer->addContent($endToken, $addedContent);
295
+				}//end if
296
+		  } else {
297
+				if ($endLine !== $end) {
298
+					 $phpcsFile->fixer->replaceToken($end, '');
299
+					 $phpcsFile->fixer->addNewlineBefore($endLine);
300
+					 $phpcsFile->fixer->addContent($endLine, '}');
301
+				} else {
302
+					 $phpcsFile->fixer->replaceToken($end, '}');
303
+				}
304
+		  }//end if
305
+
306
+		  $phpcsFile->fixer->endChangeset();
307
+
308
+	 }//end process()
309 309
 
310 310
 
311 311
 }//end class
Please login to merge, or discard this patch.
Spacing   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -78,31 +78,31 @@  discard block
 block discarded – undo
78 78
      *
79 79
      * @return void
80 80
      */
81
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
81
+    public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr )
82 82
     {
83 83
         $tokens = $phpcsFile->getTokens();
84 84
 
85
-        if (isset($tokens[$stackPtr]['scope_opener']) === true) {
86
-            $phpcsFile->recordMetric($stackPtr, 'Control structure defined inline', 'no');
85
+        if ( isset( $tokens[ $stackPtr ][ 'scope_opener' ] ) === true ) {
86
+            $phpcsFile->recordMetric( $stackPtr, 'Control structure defined inline', 'no' );
87 87
             return;
88 88
         }
89 89
 
90 90
         // Ignore the ELSE in ELSE IF. We'll process the IF part later.
91
-        if ($tokens[$stackPtr]['code'] === T_ELSE) {
92
-            $next = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true);
93
-            if ($tokens[$next]['code'] === T_IF) {
91
+        if ( $tokens[ $stackPtr ][ 'code' ] === T_ELSE ) {
92
+            $next = $phpcsFile->findNext( T_WHITESPACE, ( $stackPtr + 1 ), null, true );
93
+            if ( $tokens[ $next ][ 'code' ] === T_IF ) {
94 94
                 return;
95 95
             }
96 96
         }
97 97
 
98
-        if ($tokens[$stackPtr]['code'] === T_WHILE) {
98
+        if ( $tokens[ $stackPtr ][ 'code' ] === T_WHILE ) {
99 99
             // This could be from a DO WHILE, which doesn't have an opening brace.
100
-            $lastContent = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
101
-            if ($tokens[$lastContent]['code'] === T_CLOSE_CURLY_BRACKET) {
102
-                $brace = $tokens[$lastContent];
103
-                if (isset($brace['scope_condition']) === true) {
104
-                    $condition = $tokens[$brace['scope_condition']];
105
-                    if ($condition['code'] === T_DO) {
100
+            $lastContent = $phpcsFile->findPrevious( T_WHITESPACE, ( $stackPtr - 1 ), null, true );
101
+            if ( $tokens[ $lastContent ][ 'code' ] === T_CLOSE_CURLY_BRACKET ) {
102
+                $brace = $tokens[ $lastContent ];
103
+                if ( isset( $brace[ 'scope_condition' ] ) === true ) {
104
+                    $condition = $tokens[ $brace[ 'scope_condition' ] ];
105
+                    if ( $condition[ 'code' ] === T_DO ) {
106 106
                         return;
107 107
                     }
108 108
                 }
@@ -112,12 +112,12 @@  discard block
 block discarded – undo
112 112
             // is only valid if a single statement is present between the DO and
113 113
             // the WHILE. We can detect this by checking only a single semicolon
114 114
             // is present between them.
115
-            if ($phpcsFile->tokenizerType === 'JS') {
116
-                $lastDo        = $phpcsFile->findPrevious(T_DO, ($stackPtr - 1));
117
-                $lastSemicolon = $phpcsFile->findPrevious(T_SEMICOLON, ($stackPtr - 1));
118
-                if ($lastDo !== false && $lastSemicolon !== false && $lastDo < $lastSemicolon) {
119
-                    $precedingSemicolon = $phpcsFile->findPrevious(T_SEMICOLON, ($lastSemicolon - 1));
120
-                    if ($precedingSemicolon === false || $precedingSemicolon < $lastDo) {
115
+            if ( $phpcsFile->tokenizerType === 'JS' ) {
116
+                $lastDo        = $phpcsFile->findPrevious( T_DO, ( $stackPtr - 1 ) );
117
+                $lastSemicolon = $phpcsFile->findPrevious( T_SEMICOLON, ( $stackPtr - 1 ) );
118
+                if ( $lastDo !== false && $lastSemicolon !== false && $lastDo < $lastSemicolon ) {
119
+                    $precedingSemicolon = $phpcsFile->findPrevious( T_SEMICOLON, ( $lastSemicolon - 1 ) );
120
+                    if ( $precedingSemicolon === false || $precedingSemicolon < $lastDo ) {
121 121
                         return;
122 122
                     }
123 123
                 }
@@ -126,49 +126,49 @@  discard block
 block discarded – undo
126 126
 
127 127
         // This is a control structure without an opening brace,
128 128
         // so it is an inline statement.
129
-        if ($this->error === true) {
130
-            $fix = $phpcsFile->addFixableError('Inline control structures are not allowed', $stackPtr, 'NotAllowed');
129
+        if ( $this->error === true ) {
130
+            $fix = $phpcsFile->addFixableError( 'Inline control structures are not allowed', $stackPtr, 'NotAllowed' );
131 131
         } else {
132
-            $fix = $phpcsFile->addFixableWarning('Inline control structures are discouraged', $stackPtr, 'Discouraged');
132
+            $fix = $phpcsFile->addFixableWarning( 'Inline control structures are discouraged', $stackPtr, 'Discouraged' );
133 133
         }
134 134
 
135
-        $phpcsFile->recordMetric($stackPtr, 'Control structure defined inline', 'yes');
135
+        $phpcsFile->recordMetric( $stackPtr, 'Control structure defined inline', 'yes' );
136 136
 
137 137
         // Stop here if we are not fixing the error.
138
-        if ($fix !== true) {
138
+        if ( $fix !== true ) {
139 139
             return;
140 140
         }
141 141
 
142 142
         $phpcsFile->fixer->beginChangeset();
143
-        if (isset($tokens[$stackPtr]['parenthesis_closer']) === true) {
144
-            $closer = $tokens[$stackPtr]['parenthesis_closer'];
143
+        if ( isset( $tokens[ $stackPtr ][ 'parenthesis_closer' ] ) === true ) {
144
+            $closer = $tokens[ $stackPtr ][ 'parenthesis_closer' ];
145 145
         } else {
146 146
             $closer = $stackPtr;
147 147
         }
148 148
 
149
-        if ($tokens[($closer + 1)]['code'] === T_WHITESPACE
150
-            || $tokens[($closer + 1)]['code'] === T_SEMICOLON
149
+        if ( $tokens[ ( $closer + 1 ) ][ 'code' ] === T_WHITESPACE
150
+            || $tokens[ ( $closer + 1 ) ][ 'code' ] === T_SEMICOLON
151 151
         ) {
152
-            $phpcsFile->fixer->addContent($closer, ' {');
152
+            $phpcsFile->fixer->addContent( $closer, ' {' );
153 153
         } else {
154
-            $phpcsFile->fixer->addContent($closer, ' { ');
154
+            $phpcsFile->fixer->addContent( $closer, ' { ' );
155 155
         }
156 156
 
157 157
         $fixableScopeOpeners = $this->register();
158 158
 
159 159
         $lastNonEmpty = $closer;
160
-        for ($end = ($closer + 1); $end < $phpcsFile->numTokens; $end++) {
161
-            if ($tokens[$end]['code'] === T_SEMICOLON) {
160
+        for ( $end = ( $closer + 1 ); $end < $phpcsFile->numTokens; $end++ ) {
161
+            if ( $tokens[ $end ][ 'code' ] === T_SEMICOLON ) {
162 162
                 break;
163 163
             }
164 164
 
165
-            if ($tokens[$end]['code'] === T_CLOSE_TAG) {
165
+            if ( $tokens[ $end ][ 'code' ] === T_CLOSE_TAG ) {
166 166
                 $end = $lastNonEmpty;
167 167
                 break;
168 168
             }
169 169
 
170
-            if (in_array($tokens[$end]['code'], $fixableScopeOpeners) === true
171
-                && isset($tokens[$end]['scope_opener']) === false
170
+            if ( in_array( $tokens[ $end ][ 'code' ], $fixableScopeOpeners ) === true
171
+                && isset( $tokens[ $end ][ 'scope_opener' ] ) === false
172 172
             ) {
173 173
                 // The best way to fix nested inline scopes is middle-out.
174 174
                 // So skip this one. It will be detected and fixed on a future loop.
@@ -176,130 +176,130 @@  discard block
 block discarded – undo
176 176
                 return;
177 177
             }
178 178
 
179
-            if (isset($tokens[$end]['scope_opener']) === true) {
180
-                $type = $tokens[$end]['code'];
181
-                $end  = $tokens[$end]['scope_closer'];
182
-                if ($type === T_DO || $type === T_IF || $type === T_ELSEIF) {
183
-                    $next = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($end + 1), null, true);
184
-                    if ($next === false) {
179
+            if ( isset( $tokens[ $end ][ 'scope_opener' ] ) === true ) {
180
+                $type = $tokens[ $end ][ 'code' ];
181
+                $end  = $tokens[ $end ][ 'scope_closer' ];
182
+                if ( $type === T_DO || $type === T_IF || $type === T_ELSEIF ) {
183
+                    $next = $phpcsFile->findNext( PHP_CodeSniffer_Tokens::$emptyTokens, ( $end + 1 ), null, true );
184
+                    if ( $next === false ) {
185 185
                         break;
186 186
                     }
187 187
 
188
-                    $nextType = $tokens[$next]['code'];
188
+                    $nextType = $tokens[ $next ][ 'code' ];
189 189
 
190 190
                     // Let additional conditions loop and find their ending.
191
-                    if (($type === T_IF
192
-                        || $type === T_ELSEIF)
193
-                        && ($nextType === T_ELSEIF
194
-                        || $nextType === T_ELSE)
191
+                    if ( ( $type === T_IF
192
+                        || $type === T_ELSEIF )
193
+                        && ( $nextType === T_ELSEIF
194
+                        || $nextType === T_ELSE )
195 195
                     ) {
196 196
                         continue;
197 197
                     }
198 198
 
199 199
                     // Account for DO... WHILE conditions.
200
-                    if ($type === T_DO && $nextType === T_WHILE) {
201
-                        $end = $phpcsFile->findNext(T_SEMICOLON, ($next + 1));
200
+                    if ( $type === T_DO && $nextType === T_WHILE ) {
201
+                        $end = $phpcsFile->findNext( T_SEMICOLON, ( $next + 1 ) );
202 202
                     }
203 203
                 }//end if
204 204
 
205
-                if ($tokens[$end]['code'] !== T_END_HEREDOC
206
-                    && $tokens[$end]['code'] !== T_END_NOWDOC
205
+                if ( $tokens[ $end ][ 'code' ] !== T_END_HEREDOC
206
+                    && $tokens[ $end ][ 'code' ] !== T_END_NOWDOC
207 207
                 ) {
208 208
                     break;
209 209
                 }
210 210
             }//end if
211 211
 
212
-            if (isset($tokens[$end]['parenthesis_closer']) === true) {
213
-                $end          = $tokens[$end]['parenthesis_closer'];
212
+            if ( isset( $tokens[ $end ][ 'parenthesis_closer' ] ) === true ) {
213
+                $end          = $tokens[ $end ][ 'parenthesis_closer' ];
214 214
                 $lastNonEmpty = $end;
215 215
                 continue;
216 216
             }
217 217
 
218
-            if ($tokens[$end]['code'] !== T_WHITESPACE) {
218
+            if ( $tokens[ $end ][ 'code' ] !== T_WHITESPACE ) {
219 219
                 $lastNonEmpty = $end;
220 220
             }
221 221
         }//end for
222 222
 
223
-        if ($end === $phpcsFile->numTokens) {
223
+        if ( $end === $phpcsFile->numTokens ) {
224 224
             $end = $lastNonEmpty;
225 225
         }
226 226
 
227
-        $next = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($end + 1), null, true);
227
+        $next = $phpcsFile->findNext( PHP_CodeSniffer_Tokens::$emptyTokens, ( $end + 1 ), null, true );
228 228
 
229
-        if ($next === false || $tokens[$next]['line'] !== $tokens[$end]['line']) {
229
+        if ( $next === false || $tokens[ $next ][ 'line' ] !== $tokens[ $end ][ 'line' ] ) {
230 230
             // Looks for completely empty statements.
231
-            $next = $phpcsFile->findNext(T_WHITESPACE, ($closer + 1), ($end + 1), true);
231
+            $next = $phpcsFile->findNext( T_WHITESPACE, ( $closer + 1 ), ( $end + 1 ), true );
232 232
 
233 233
             // Account for a comment on the end of the line.
234
-            for ($endLine = $end; $endLine < $phpcsFile->numTokens; $endLine++) {
235
-                if (isset($tokens[($endLine + 1)]) === false
236
-                    || $tokens[$endLine]['line'] !== $tokens[($endLine + 1)]['line']
234
+            for ( $endLine = $end; $endLine < $phpcsFile->numTokens; $endLine++ ) {
235
+                if ( isset( $tokens[ ( $endLine + 1 ) ] ) === false
236
+                    || $tokens[ $endLine ][ 'line' ] !== $tokens[ ( $endLine + 1 ) ][ 'line' ]
237 237
                 ) {
238 238
                     break;
239 239
                 }
240 240
             }
241 241
 
242
-            if ($tokens[$endLine]['code'] !== T_COMMENT) {
242
+            if ( $tokens[ $endLine ][ 'code' ] !== T_COMMENT ) {
243 243
                 $endLine = $end;
244 244
             }
245 245
         } else {
246
-            $next    = ($end + 1);
246
+            $next    = ( $end + 1 );
247 247
             $endLine = $end;
248 248
         }
249 249
 
250
-        if ($next !== $end) {
251
-            if ($endLine !== $end) {
250
+        if ( $next !== $end ) {
251
+            if ( $endLine !== $end ) {
252 252
                 $endToken     = $endLine;
253 253
                 $addedContent = '';
254 254
             } else {
255 255
                 $endToken     = $end;
256 256
                 $addedContent = $phpcsFile->eolChar;
257 257
 
258
-                if ($tokens[$end]['code'] !== T_SEMICOLON
259
-                    && $tokens[$end]['code'] !== T_CLOSE_CURLY_BRACKET
258
+                if ( $tokens[ $end ][ 'code' ] !== T_SEMICOLON
259
+                    && $tokens[ $end ][ 'code' ] !== T_CLOSE_CURLY_BRACKET
260 260
                 ) {
261
-                    $phpcsFile->fixer->addContent($end, '; ');
261
+                    $phpcsFile->fixer->addContent( $end, '; ' );
262 262
                 }
263 263
             }
264 264
 
265
-            $next = $phpcsFile->findNext(T_WHITESPACE, ($endToken + 1), null, true);
266
-            if ($next !== false
267
-                && ($tokens[$next]['code'] === T_ELSE
268
-                || $tokens[$next]['code'] === T_ELSEIF)
265
+            $next = $phpcsFile->findNext( T_WHITESPACE, ( $endToken + 1 ), null, true );
266
+            if ( $next !== false
267
+                && ( $tokens[ $next ][ 'code' ] === T_ELSE
268
+                || $tokens[ $next ][ 'code' ] === T_ELSEIF )
269 269
             ) {
270
-                $phpcsFile->fixer->addContentBefore($next, '} ');
270
+                $phpcsFile->fixer->addContentBefore( $next, '} ' );
271 271
             } else {
272 272
                 $indent = '';
273
-                for ($first = $stackPtr; $first > 0; $first--) {
274
-                    if ($first === 1
275
-                        || $tokens[($first - 1)]['line'] !== $tokens[$first]['line']
273
+                for ( $first = $stackPtr; $first > 0; $first-- ) {
274
+                    if ( $first === 1
275
+                        || $tokens[ ( $first - 1 ) ][ 'line' ] !== $tokens[ $first ][ 'line' ]
276 276
                     ) {
277 277
                         break;
278 278
                     }
279 279
                 }
280 280
 
281
-                if ($tokens[$first]['code'] === T_WHITESPACE) {
282
-                    $indent = $tokens[$first]['content'];
283
-                } else if ($tokens[$first]['code'] === T_INLINE_HTML
284
-                    || $tokens[$first]['code'] === T_OPEN_TAG
281
+                if ( $tokens[ $first ][ 'code' ] === T_WHITESPACE ) {
282
+                    $indent = $tokens[ $first ][ 'content' ];
283
+                } else if ( $tokens[ $first ][ 'code' ] === T_INLINE_HTML
284
+                    || $tokens[ $first ][ 'code' ] === T_OPEN_TAG
285 285
                 ) {
286 286
                     $addedContent = '';
287 287
                 }
288 288
 
289
-                $addedContent .= $indent.'}';
290
-                if ($next !== false && $tokens[$endToken]['code'] === T_COMMENT) {
289
+                $addedContent .= $indent . '}';
290
+                if ( $next !== false && $tokens[ $endToken ][ 'code' ] === T_COMMENT ) {
291 291
                     $addedContent .= $phpcsFile->eolChar;
292 292
                 }
293 293
 
294
-                $phpcsFile->fixer->addContent($endToken, $addedContent);
294
+                $phpcsFile->fixer->addContent( $endToken, $addedContent );
295 295
             }//end if
296 296
         } else {
297
-            if ($endLine !== $end) {
298
-                $phpcsFile->fixer->replaceToken($end, '');
299
-                $phpcsFile->fixer->addNewlineBefore($endLine);
300
-                $phpcsFile->fixer->addContent($endLine, '}');
297
+            if ( $endLine !== $end ) {
298
+                $phpcsFile->fixer->replaceToken( $end, '' );
299
+                $phpcsFile->fixer->addNewlineBefore( $endLine );
300
+                $phpcsFile->fixer->addContent( $endLine, '}' );
301 301
             } else {
302
-                $phpcsFile->fixer->replaceToken($end, '}');
302
+                $phpcsFile->fixer->replaceToken( $end, '}' );
303 303
             }
304 304
         }//end if
305 305
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -27,8 +27,7 @@  discard block
 block discarded – undo
27 27
  * @version   Release: @package_version@
28 28
  * @link      http://pear.php.net/package/PHP_CodeSniffer
29 29
  */
30
-class Generic_Sniffs_ControlStructures_InlineControlStructureSniff implements PHP_CodeSniffer_Sniff
31
-{
30
+class Generic_Sniffs_ControlStructures_InlineControlStructureSniff implements PHP_CodeSniffer_Sniff {
32 31
 
33 32
     /**
34 33
      * A list of tokenizers this sniff supports.
@@ -53,8 +52,7 @@  discard block
 block discarded – undo
53 52
      *
54 53
      * @return array
55 54
      */
56
-    public function register()
57
-    {
55
+    public function register() {
58 56
         return array(
59 57
                 T_IF,
60 58
                 T_ELSE,
@@ -78,8 +76,7 @@  discard block
 block discarded – undo
78 76
      *
79 77
      * @return void
80 78
      */
81
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
82
-    {
79
+    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
83 80
         $tokens = $phpcsFile->getTokens();
84 81
 
85 82
         if (isset($tokens[$stackPtr]['scope_opener']) === true) {
Please login to merge, or discard this patch.
CodeSniffer/Standards/Generic/Sniffs/Metrics/NestingLevelSniff.php 3 patches
Indentation   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -28,85 +28,85 @@
 block discarded – undo
28 28
 class Generic_Sniffs_Metrics_NestingLevelSniff implements PHP_CodeSniffer_Sniff
29 29
 {
30 30
 
31
-    /**
32
-     * A nesting level than this value will throw a warning.
33
-     *
34
-     * @var int
35
-     */
36
-    public $nestingLevel = 5;
37
-
38
-    /**
39
-     * A nesting level than this value will throw an error.
40
-     *
41
-     * @var int
42
-     */
43
-    public $absoluteNestingLevel = 10;
44
-
45
-
46
-    /**
47
-     * Returns an array of tokens this test wants to listen for.
48
-     *
49
-     * @return array
50
-     */
51
-    public function register()
52
-    {
53
-        return array(T_FUNCTION);
54
-
55
-    }//end register()
56
-
57
-
58
-    /**
59
-     * Processes this test, when one of its tokens is encountered.
60
-     *
61
-     * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
62
-     * @param int                  $stackPtr  The position of the current token
63
-     *                                        in the stack passed in $tokens.
64
-     *
65
-     * @return void
66
-     */
67
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
68
-    {
69
-        $tokens = $phpcsFile->getTokens();
70
-
71
-        // Ignore abstract methods.
72
-        if (isset($tokens[$stackPtr]['scope_opener']) === false) {
73
-            return;
74
-        }
75
-
76
-        // Detect start and end of this function definition.
77
-        $start = $tokens[$stackPtr]['scope_opener'];
78
-        $end   = $tokens[$stackPtr]['scope_closer'];
79
-
80
-        $nestingLevel = 0;
81
-
82
-        // Find the maximum nesting level of any token in the function.
83
-        for ($i = ($start + 1); $i < $end; $i++) {
84
-            $level = $tokens[$i]['level'];
85
-            if ($nestingLevel < $level) {
86
-                $nestingLevel = $level;
87
-            }
88
-        }
89
-
90
-        // We subtract the nesting level of the function itself.
91
-        $nestingLevel = ($nestingLevel - $tokens[$stackPtr]['level'] - 1);
92
-
93
-        if ($nestingLevel > $this->absoluteNestingLevel) {
94
-            $error = 'Function\'s nesting level (%s) exceeds allowed maximum of %s';
95
-            $data  = array(
96
-                      $nestingLevel,
97
-                      $this->absoluteNestingLevel,
98
-                     );
99
-            $phpcsFile->addError($error, $stackPtr, 'MaxExceeded', $data);
100
-        } else if ($nestingLevel > $this->nestingLevel) {
101
-            $warning = 'Function\'s nesting level (%s) exceeds %s; consider refactoring the function';
102
-            $data    = array(
103
-                        $nestingLevel,
104
-                        $this->nestingLevel,
105
-                       );
106
-            $phpcsFile->addWarning($warning, $stackPtr, 'TooHigh', $data);
107
-        }
108
-
109
-    }//end process()
31
+	 /**
32
+	  * A nesting level than this value will throw a warning.
33
+	  *
34
+	  * @var int
35
+	  */
36
+	 public $nestingLevel = 5;
37
+
38
+	 /**
39
+	  * A nesting level than this value will throw an error.
40
+	  *
41
+	  * @var int
42
+	  */
43
+	 public $absoluteNestingLevel = 10;
44
+
45
+
46
+	 /**
47
+	  * Returns an array of tokens this test wants to listen for.
48
+	  *
49
+	  * @return array
50
+	  */
51
+	 public function register()
52
+	 {
53
+		  return array(T_FUNCTION);
54
+
55
+	 }//end register()
56
+
57
+
58
+	 /**
59
+	  * Processes this test, when one of its tokens is encountered.
60
+	  *
61
+	  * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
62
+	  * @param int                  $stackPtr  The position of the current token
63
+	  *                                        in the stack passed in $tokens.
64
+	  *
65
+	  * @return void
66
+	  */
67
+	 public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
68
+	 {
69
+		  $tokens = $phpcsFile->getTokens();
70
+
71
+		  // Ignore abstract methods.
72
+		  if (isset($tokens[$stackPtr]['scope_opener']) === false) {
73
+				return;
74
+		  }
75
+
76
+		  // Detect start and end of this function definition.
77
+		  $start = $tokens[$stackPtr]['scope_opener'];
78
+		  $end   = $tokens[$stackPtr]['scope_closer'];
79
+
80
+		  $nestingLevel = 0;
81
+
82
+		  // Find the maximum nesting level of any token in the function.
83
+		  for ($i = ($start + 1); $i < $end; $i++) {
84
+				$level = $tokens[$i]['level'];
85
+				if ($nestingLevel < $level) {
86
+					 $nestingLevel = $level;
87
+				}
88
+		  }
89
+
90
+		  // We subtract the nesting level of the function itself.
91
+		  $nestingLevel = ($nestingLevel - $tokens[$stackPtr]['level'] - 1);
92
+
93
+		  if ($nestingLevel > $this->absoluteNestingLevel) {
94
+				$error = 'Function\'s nesting level (%s) exceeds allowed maximum of %s';
95
+				$data  = array(
96
+							 $nestingLevel,
97
+							 $this->absoluteNestingLevel,
98
+							);
99
+				$phpcsFile->addError($error, $stackPtr, 'MaxExceeded', $data);
100
+		  } else if ($nestingLevel > $this->nestingLevel) {
101
+				$warning = 'Function\'s nesting level (%s) exceeds %s; consider refactoring the function';
102
+				$data    = array(
103
+								$nestingLevel,
104
+								$this->nestingLevel,
105
+							  );
106
+				$phpcsFile->addWarning($warning, $stackPtr, 'TooHigh', $data);
107
+		  }
108
+
109
+	 }//end process()
110 110
 
111 111
 
112 112
 }//end class
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
      */
51 51
     public function register()
52 52
     {
53
-        return array(T_FUNCTION);
53
+        return array( T_FUNCTION );
54 54
 
55 55
     }//end register()
56 56
 
@@ -64,46 +64,46 @@  discard block
 block discarded – undo
64 64
      *
65 65
      * @return void
66 66
      */
67
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
67
+    public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr )
68 68
     {
69 69
         $tokens = $phpcsFile->getTokens();
70 70
 
71 71
         // Ignore abstract methods.
72
-        if (isset($tokens[$stackPtr]['scope_opener']) === false) {
72
+        if ( isset( $tokens[ $stackPtr ][ 'scope_opener' ] ) === false ) {
73 73
             return;
74 74
         }
75 75
 
76 76
         // Detect start and end of this function definition.
77
-        $start = $tokens[$stackPtr]['scope_opener'];
78
-        $end   = $tokens[$stackPtr]['scope_closer'];
77
+        $start = $tokens[ $stackPtr ][ 'scope_opener' ];
78
+        $end   = $tokens[ $stackPtr ][ 'scope_closer' ];
79 79
 
80 80
         $nestingLevel = 0;
81 81
 
82 82
         // Find the maximum nesting level of any token in the function.
83
-        for ($i = ($start + 1); $i < $end; $i++) {
84
-            $level = $tokens[$i]['level'];
85
-            if ($nestingLevel < $level) {
83
+        for ( $i = ( $start + 1 ); $i < $end; $i++ ) {
84
+            $level = $tokens[ $i ][ 'level' ];
85
+            if ( $nestingLevel < $level ) {
86 86
                 $nestingLevel = $level;
87 87
             }
88 88
         }
89 89
 
90 90
         // We subtract the nesting level of the function itself.
91
-        $nestingLevel = ($nestingLevel - $tokens[$stackPtr]['level'] - 1);
91
+        $nestingLevel = ( $nestingLevel - $tokens[ $stackPtr ][ 'level' ] - 1 );
92 92
 
93
-        if ($nestingLevel > $this->absoluteNestingLevel) {
93
+        if ( $nestingLevel > $this->absoluteNestingLevel ) {
94 94
             $error = 'Function\'s nesting level (%s) exceeds allowed maximum of %s';
95 95
             $data  = array(
96 96
                       $nestingLevel,
97 97
                       $this->absoluteNestingLevel,
98 98
                      );
99
-            $phpcsFile->addError($error, $stackPtr, 'MaxExceeded', $data);
100
-        } else if ($nestingLevel > $this->nestingLevel) {
99
+            $phpcsFile->addError( $error, $stackPtr, 'MaxExceeded', $data );
100
+        } else if ( $nestingLevel > $this->nestingLevel ) {
101 101
             $warning = 'Function\'s nesting level (%s) exceeds %s; consider refactoring the function';
102 102
             $data    = array(
103 103
                         $nestingLevel,
104 104
                         $this->nestingLevel,
105 105
                        );
106
-            $phpcsFile->addWarning($warning, $stackPtr, 'TooHigh', $data);
106
+            $phpcsFile->addWarning( $warning, $stackPtr, 'TooHigh', $data );
107 107
         }
108 108
 
109 109
     }//end process()
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -25,8 +25,7 @@  discard block
 block discarded – undo
25 25
  * @version   Release: @package_version@
26 26
  * @link      http://pear.php.net/package/PHP_CodeSniffer
27 27
  */
28
-class Generic_Sniffs_Metrics_NestingLevelSniff implements PHP_CodeSniffer_Sniff
29
-{
28
+class Generic_Sniffs_Metrics_NestingLevelSniff implements PHP_CodeSniffer_Sniff {
30 29
 
31 30
     /**
32 31
      * A nesting level than this value will throw a warning.
@@ -48,8 +47,7 @@  discard block
 block discarded – undo
48 47
      *
49 48
      * @return array
50 49
      */
51
-    public function register()
52
-    {
50
+    public function register() {
53 51
         return array(T_FUNCTION);
54 52
 
55 53
     }//end register()
@@ -64,8 +62,7 @@  discard block
 block discarded – undo
64 62
      *
65 63
      * @return void
66 64
      */
67
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
68
-    {
65
+    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
69 66
         $tokens = $phpcsFile->getTokens();
70 67
 
71 68
         // Ignore abstract methods.
Please login to merge, or discard this patch.
CodeSniffer/Standards/Generic/Sniffs/Commenting/FixmeSniff.php 3 patches
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -30,62 +30,62 @@
 block discarded – undo
30 30
 class Generic_Sniffs_Commenting_FixmeSniff implements PHP_CodeSniffer_Sniff
31 31
 {
32 32
 
33
-    /**
34
-     * A list of tokenizers this sniff supports.
35
-     *
36
-     * @var array
37
-     */
38
-    public $supportedTokenizers = array(
39
-                                   'PHP',
40
-                                   'JS',
41
-                                  );
33
+	 /**
34
+	  * A list of tokenizers this sniff supports.
35
+	  *
36
+	  * @var array
37
+	  */
38
+	 public $supportedTokenizers = array(
39
+											  'PHP',
40
+											  'JS',
41
+											 );
42 42
 
43 43
 
44
-    /**
45
-     * Returns an array of tokens this test wants to listen for.
46
-     *
47
-     * @return array
48
-     */
49
-    public function register()
50
-    {
51
-        return PHP_CodeSniffer_Tokens::$commentTokens;
44
+	 /**
45
+	  * Returns an array of tokens this test wants to listen for.
46
+	  *
47
+	  * @return array
48
+	  */
49
+	 public function register()
50
+	 {
51
+		  return PHP_CodeSniffer_Tokens::$commentTokens;
52 52
 
53
-    }//end register()
53
+	 }//end register()
54 54
 
55 55
 
56
-    /**
57
-     * Processes this sniff, when one of its tokens is encountered.
58
-     *
59
-     * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
60
-     * @param int                  $stackPtr  The position of the current token
61
-     *                                        in the stack passed in $tokens.
62
-     *
63
-     * @return void
64
-     */
65
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
66
-    {
67
-        $tokens = $phpcsFile->getTokens();
56
+	 /**
57
+	  * Processes this sniff, when one of its tokens is encountered.
58
+	  *
59
+	  * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
60
+	  * @param int                  $stackPtr  The position of the current token
61
+	  *                                        in the stack passed in $tokens.
62
+	  *
63
+	  * @return void
64
+	  */
65
+	 public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
66
+	 {
67
+		  $tokens = $phpcsFile->getTokens();
68 68
 
69
-        $content = $tokens[$stackPtr]['content'];
70
-        $matches = array();
71
-        preg_match('/(?:\A|[^\p{L}]+)fixme([^\p{L}]+(.*)|\Z)/ui', $content, $matches);
72
-        if (empty($matches) === false) {
73
-            // Clear whitespace and some common characters not required at
74
-            // the end of a fixme message to make the error more informative.
75
-            $type         = 'CommentFound';
76
-            $fixmeMessage = trim($matches[1]);
77
-            $fixmeMessage = trim($fixmeMessage, '-:[](). ');
78
-            $error        = 'Comment refers to a FIXME task';
79
-            $data         = array($fixmeMessage);
80
-            if ($fixmeMessage !== '') {
81
-                $type   = 'TaskFound';
82
-                $error .= ' "%s"';
83
-            }
69
+		  $content = $tokens[$stackPtr]['content'];
70
+		  $matches = array();
71
+		  preg_match('/(?:\A|[^\p{L}]+)fixme([^\p{L}]+(.*)|\Z)/ui', $content, $matches);
72
+		  if (empty($matches) === false) {
73
+				// Clear whitespace and some common characters not required at
74
+				// the end of a fixme message to make the error more informative.
75
+				$type         = 'CommentFound';
76
+				$fixmeMessage = trim($matches[1]);
77
+				$fixmeMessage = trim($fixmeMessage, '-:[](). ');
78
+				$error        = 'Comment refers to a FIXME task';
79
+				$data         = array($fixmeMessage);
80
+				if ($fixmeMessage !== '') {
81
+					 $type   = 'TaskFound';
82
+					 $error .= ' "%s"';
83
+				}
84 84
 
85
-            $phpcsFile->addError($error, $stackPtr, $type, $data);
86
-        }
85
+				$phpcsFile->addError($error, $stackPtr, $type, $data);
86
+		  }
87 87
 
88
-    }//end process()
88
+	 }//end process()
89 89
 
90 90
 
91 91
 }//end class
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -62,27 +62,27 @@
 block discarded – undo
62 62
      *
63 63
      * @return void
64 64
      */
65
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
65
+    public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr )
66 66
     {
67 67
         $tokens = $phpcsFile->getTokens();
68 68
 
69
-        $content = $tokens[$stackPtr]['content'];
69
+        $content = $tokens[ $stackPtr ][ 'content' ];
70 70
         $matches = array();
71
-        preg_match('/(?:\A|[^\p{L}]+)fixme([^\p{L}]+(.*)|\Z)/ui', $content, $matches);
72
-        if (empty($matches) === false) {
71
+        preg_match( '/(?:\A|[^\p{L}]+)fixme([^\p{L}]+(.*)|\Z)/ui', $content, $matches );
72
+        if ( empty( $matches ) === false ) {
73 73
             // Clear whitespace and some common characters not required at
74 74
             // the end of a fixme message to make the error more informative.
75 75
             $type         = 'CommentFound';
76
-            $fixmeMessage = trim($matches[1]);
77
-            $fixmeMessage = trim($fixmeMessage, '-:[](). ');
76
+            $fixmeMessage = trim( $matches[ 1 ] );
77
+            $fixmeMessage = trim( $fixmeMessage, '-:[](). ' );
78 78
             $error        = 'Comment refers to a FIXME task';
79
-            $data         = array($fixmeMessage);
80
-            if ($fixmeMessage !== '') {
79
+            $data         = array( $fixmeMessage );
80
+            if ( $fixmeMessage !== '' ) {
81 81
                 $type   = 'TaskFound';
82 82
                 $error .= ' "%s"';
83 83
             }
84 84
 
85
-            $phpcsFile->addError($error, $stackPtr, $type, $data);
85
+            $phpcsFile->addError( $error, $stackPtr, $type, $data );
86 86
         }
87 87
 
88 88
     }//end process()
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -27,8 +27,7 @@  discard block
 block discarded – undo
27 27
  * @version   Release: @package_version@
28 28
  * @link      http://pear.php.net/package/PHP_CodeSniffer
29 29
  */
30
-class Generic_Sniffs_Commenting_FixmeSniff implements PHP_CodeSniffer_Sniff
31
-{
30
+class Generic_Sniffs_Commenting_FixmeSniff implements PHP_CodeSniffer_Sniff {
32 31
 
33 32
     /**
34 33
      * A list of tokenizers this sniff supports.
@@ -46,8 +45,7 @@  discard block
 block discarded – undo
46 45
      *
47 46
      * @return array
48 47
      */
49
-    public function register()
50
-    {
48
+    public function register() {
51 49
         return PHP_CodeSniffer_Tokens::$commentTokens;
52 50
 
53 51
     }//end register()
@@ -62,8 +60,7 @@  discard block
 block discarded – undo
62 60
      *
63 61
      * @return void
64 62
      */
65
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
66
-    {
63
+    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
67 64
         $tokens = $phpcsFile->getTokens();
68 65
 
69 66
         $content = $tokens[$stackPtr]['content'];
Please login to merge, or discard this patch.
CodeSniffer/Standards/Generic/Sniffs/Commenting/TodoSniff.php 3 patches
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -28,62 +28,62 @@
 block discarded – undo
28 28
 class Generic_Sniffs_Commenting_TodoSniff implements PHP_CodeSniffer_Sniff
29 29
 {
30 30
 
31
-    /**
32
-     * A list of tokenizers this sniff supports.
33
-     *
34
-     * @var array
35
-     */
36
-    public $supportedTokenizers = array(
37
-                                   'PHP',
38
-                                   'JS',
39
-                                  );
31
+	 /**
32
+	  * A list of tokenizers this sniff supports.
33
+	  *
34
+	  * @var array
35
+	  */
36
+	 public $supportedTokenizers = array(
37
+											  'PHP',
38
+											  'JS',
39
+											 );
40 40
 
41 41
 
42
-    /**
43
-     * Returns an array of tokens this test wants to listen for.
44
-     *
45
-     * @return array
46
-     */
47
-    public function register()
48
-    {
49
-        return PHP_CodeSniffer_Tokens::$commentTokens;
42
+	 /**
43
+	  * Returns an array of tokens this test wants to listen for.
44
+	  *
45
+	  * @return array
46
+	  */
47
+	 public function register()
48
+	 {
49
+		  return PHP_CodeSniffer_Tokens::$commentTokens;
50 50
 
51
-    }//end register()
51
+	 }//end register()
52 52
 
53 53
 
54
-    /**
55
-     * Processes this sniff, when one of its tokens is encountered.
56
-     *
57
-     * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
58
-     * @param int                  $stackPtr  The position of the current token
59
-     *                                        in the stack passed in $tokens.
60
-     *
61
-     * @return void
62
-     */
63
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
64
-    {
65
-        $tokens = $phpcsFile->getTokens();
54
+	 /**
55
+	  * Processes this sniff, when one of its tokens is encountered.
56
+	  *
57
+	  * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
58
+	  * @param int                  $stackPtr  The position of the current token
59
+	  *                                        in the stack passed in $tokens.
60
+	  *
61
+	  * @return void
62
+	  */
63
+	 public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
64
+	 {
65
+		  $tokens = $phpcsFile->getTokens();
66 66
 
67
-        $content = $tokens[$stackPtr]['content'];
68
-        $matches = array();
69
-        preg_match('/(?:\A|[^\p{L}]+)todo([^\p{L}]+(.*)|\Z)/ui', $content, $matches);
70
-        if (empty($matches) === false) {
71
-            // Clear whitespace and some common characters not required at
72
-            // the end of a to-do message to make the warning more informative.
73
-            $type        = 'CommentFound';
74
-            $todoMessage = trim($matches[1]);
75
-            $todoMessage = trim($todoMessage, '-:[](). ');
76
-            $error       = 'Comment refers to a TODO task';
77
-            $data        = array($todoMessage);
78
-            if ($todoMessage !== '') {
79
-                $type   = 'TaskFound';
80
-                $error .= ' "%s"';
81
-            }
67
+		  $content = $tokens[$stackPtr]['content'];
68
+		  $matches = array();
69
+		  preg_match('/(?:\A|[^\p{L}]+)todo([^\p{L}]+(.*)|\Z)/ui', $content, $matches);
70
+		  if (empty($matches) === false) {
71
+				// Clear whitespace and some common characters not required at
72
+				// the end of a to-do message to make the warning more informative.
73
+				$type        = 'CommentFound';
74
+				$todoMessage = trim($matches[1]);
75
+				$todoMessage = trim($todoMessage, '-:[](). ');
76
+				$error       = 'Comment refers to a TODO task';
77
+				$data        = array($todoMessage);
78
+				if ($todoMessage !== '') {
79
+					 $type   = 'TaskFound';
80
+					 $error .= ' "%s"';
81
+				}
82 82
 
83
-            $phpcsFile->addWarning($error, $stackPtr, $type, $data);
84
-        }
83
+				$phpcsFile->addWarning($error, $stackPtr, $type, $data);
84
+		  }
85 85
 
86
-    }//end process()
86
+	 }//end process()
87 87
 
88 88
 
89 89
 }//end class
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -60,27 +60,27 @@
 block discarded – undo
60 60
      *
61 61
      * @return void
62 62
      */
63
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
63
+    public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr )
64 64
     {
65 65
         $tokens = $phpcsFile->getTokens();
66 66
 
67
-        $content = $tokens[$stackPtr]['content'];
67
+        $content = $tokens[ $stackPtr ][ 'content' ];
68 68
         $matches = array();
69
-        preg_match('/(?:\A|[^\p{L}]+)todo([^\p{L}]+(.*)|\Z)/ui', $content, $matches);
70
-        if (empty($matches) === false) {
69
+        preg_match( '/(?:\A|[^\p{L}]+)todo([^\p{L}]+(.*)|\Z)/ui', $content, $matches );
70
+        if ( empty( $matches ) === false ) {
71 71
             // Clear whitespace and some common characters not required at
72 72
             // the end of a to-do message to make the warning more informative.
73 73
             $type        = 'CommentFound';
74
-            $todoMessage = trim($matches[1]);
75
-            $todoMessage = trim($todoMessage, '-:[](). ');
74
+            $todoMessage = trim( $matches[ 1 ] );
75
+            $todoMessage = trim( $todoMessage, '-:[](). ' );
76 76
             $error       = 'Comment refers to a TODO task';
77
-            $data        = array($todoMessage);
78
-            if ($todoMessage !== '') {
77
+            $data        = array( $todoMessage );
78
+            if ( $todoMessage !== '' ) {
79 79
                 $type   = 'TaskFound';
80 80
                 $error .= ' "%s"';
81 81
             }
82 82
 
83
-            $phpcsFile->addWarning($error, $stackPtr, $type, $data);
83
+            $phpcsFile->addWarning( $error, $stackPtr, $type, $data );
84 84
         }
85 85
 
86 86
     }//end process()
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -25,8 +25,7 @@  discard block
 block discarded – undo
25 25
  * @version   Release: @package_version@
26 26
  * @link      http://pear.php.net/package/PHP_CodeSniffer
27 27
  */
28
-class Generic_Sniffs_Commenting_TodoSniff implements PHP_CodeSniffer_Sniff
29
-{
28
+class Generic_Sniffs_Commenting_TodoSniff implements PHP_CodeSniffer_Sniff {
30 29
 
31 30
     /**
32 31
      * A list of tokenizers this sniff supports.
@@ -44,8 +43,7 @@  discard block
 block discarded – undo
44 43
      *
45 44
      * @return array
46 45
      */
47
-    public function register()
48
-    {
46
+    public function register() {
49 47
         return PHP_CodeSniffer_Tokens::$commentTokens;
50 48
 
51 49
     }//end register()
@@ -60,8 +58,7 @@  discard block
 block discarded – undo
60 58
      *
61 59
      * @return void
62 60
      */
63
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
64
-    {
61
+    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
65 62
         $tokens = $phpcsFile->getTokens();
66 63
 
67 64
         $content = $tokens[$stackPtr]['content'];
Please login to merge, or discard this patch.
CodeSniffer/Standards/Generic/Sniffs/Files/EndFileNoNewlineSniff.php 3 patches
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -28,64 +28,64 @@
 block discarded – undo
28 28
 class Generic_Sniffs_Files_EndFileNoNewlineSniff implements PHP_CodeSniffer_Sniff
29 29
 {
30 30
 
31
-    /**
32
-     * A list of tokenizers this sniff supports.
33
-     *
34
-     * @var array
35
-     */
36
-    public $supportedTokenizers = array(
37
-                                   'PHP',
38
-                                   'JS',
39
-                                   'CSS',
40
-                                  );
31
+	 /**
32
+	  * A list of tokenizers this sniff supports.
33
+	  *
34
+	  * @var array
35
+	  */
36
+	 public $supportedTokenizers = array(
37
+											  'PHP',
38
+											  'JS',
39
+											  'CSS',
40
+											 );
41 41
 
42 42
 
43
-    /**
44
-     * Returns an array of tokens this test wants to listen for.
45
-     *
46
-     * @return array
47
-     */
48
-    public function register()
49
-    {
50
-        return array(T_OPEN_TAG);
43
+	 /**
44
+	  * Returns an array of tokens this test wants to listen for.
45
+	  *
46
+	  * @return array
47
+	  */
48
+	 public function register()
49
+	 {
50
+		  return array(T_OPEN_TAG);
51 51
 
52
-    }//end register()
52
+	 }//end register()
53 53
 
54 54
 
55
-    /**
56
-     * Processes this sniff, when one of its tokens is encountered.
57
-     *
58
-     * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
59
-     * @param int                  $stackPtr  The position of the current token in
60
-     *                                        the stack passed in $tokens.
61
-     *
62
-     * @return int
63
-     */
64
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
65
-    {
66
-        // Skip to the end of the file.
67
-        $tokens   = $phpcsFile->getTokens();
68
-        $stackPtr = ($phpcsFile->numTokens - 1);
55
+	 /**
56
+	  * Processes this sniff, when one of its tokens is encountered.
57
+	  *
58
+	  * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
59
+	  * @param int                  $stackPtr  The position of the current token in
60
+	  *                                        the stack passed in $tokens.
61
+	  *
62
+	  * @return int
63
+	  */
64
+	 public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
65
+	 {
66
+		  // Skip to the end of the file.
67
+		  $tokens   = $phpcsFile->getTokens();
68
+		  $stackPtr = ($phpcsFile->numTokens - 1);
69 69
 
70
-        if ($tokens[$stackPtr]['content'] === '') {
71
-            $stackPtr--;
72
-        }
70
+		  if ($tokens[$stackPtr]['content'] === '') {
71
+				$stackPtr--;
72
+		  }
73 73
 
74
-        $eolCharLen = strlen($phpcsFile->eolChar);
75
-        $lastChars  = substr($tokens[$stackPtr]['content'], ($eolCharLen * -1));
76
-        if ($lastChars === $phpcsFile->eolChar) {
77
-            $error = 'File must not end with a newline character';
78
-            $fix   = $phpcsFile->addFixableError($error, $stackPtr, 'Found');
79
-            if ($fix === true) {
80
-                $newContent = substr($tokens[$stackPtr]['content'], 0, ($eolCharLen * -1));
81
-                $phpcsFile->fixer->replaceToken($stackPtr, $newContent);
82
-            }
83
-        }
74
+		  $eolCharLen = strlen($phpcsFile->eolChar);
75
+		  $lastChars  = substr($tokens[$stackPtr]['content'], ($eolCharLen * -1));
76
+		  if ($lastChars === $phpcsFile->eolChar) {
77
+				$error = 'File must not end with a newline character';
78
+				$fix   = $phpcsFile->addFixableError($error, $stackPtr, 'Found');
79
+				if ($fix === true) {
80
+					 $newContent = substr($tokens[$stackPtr]['content'], 0, ($eolCharLen * -1));
81
+					 $phpcsFile->fixer->replaceToken($stackPtr, $newContent);
82
+				}
83
+		  }
84 84
 
85
-        // Ignore the rest of the file.
86
-        return ($phpcsFile->numTokens + 1);
85
+		  // Ignore the rest of the file.
86
+		  return ($phpcsFile->numTokens + 1);
87 87
 
88
-    }//end process()
88
+	 }//end process()
89 89
 
90 90
 
91 91
 }//end class
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
      */
48 48
     public function register()
49 49
     {
50
-        return array(T_OPEN_TAG);
50
+        return array( T_OPEN_TAG );
51 51
 
52 52
     }//end register()
53 53
 
@@ -61,29 +61,29 @@  discard block
 block discarded – undo
61 61
      *
62 62
      * @return int
63 63
      */
64
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
64
+    public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr )
65 65
     {
66 66
         // Skip to the end of the file.
67 67
         $tokens   = $phpcsFile->getTokens();
68
-        $stackPtr = ($phpcsFile->numTokens - 1);
68
+        $stackPtr = ( $phpcsFile->numTokens - 1 );
69 69
 
70
-        if ($tokens[$stackPtr]['content'] === '') {
70
+        if ( $tokens[ $stackPtr ][ 'content' ] === '' ) {
71 71
             $stackPtr--;
72 72
         }
73 73
 
74
-        $eolCharLen = strlen($phpcsFile->eolChar);
75
-        $lastChars  = substr($tokens[$stackPtr]['content'], ($eolCharLen * -1));
76
-        if ($lastChars === $phpcsFile->eolChar) {
74
+        $eolCharLen = strlen( $phpcsFile->eolChar );
75
+        $lastChars  = substr( $tokens[ $stackPtr ][ 'content' ], ( $eolCharLen * -1 ) );
76
+        if ( $lastChars === $phpcsFile->eolChar ) {
77 77
             $error = 'File must not end with a newline character';
78
-            $fix   = $phpcsFile->addFixableError($error, $stackPtr, 'Found');
79
-            if ($fix === true) {
80
-                $newContent = substr($tokens[$stackPtr]['content'], 0, ($eolCharLen * -1));
81
-                $phpcsFile->fixer->replaceToken($stackPtr, $newContent);
78
+            $fix   = $phpcsFile->addFixableError( $error, $stackPtr, 'Found' );
79
+            if ( $fix === true ) {
80
+                $newContent = substr( $tokens[ $stackPtr ][ 'content' ], 0, ( $eolCharLen * -1 ) );
81
+                $phpcsFile->fixer->replaceToken( $stackPtr, $newContent );
82 82
             }
83 83
         }
84 84
 
85 85
         // Ignore the rest of the file.
86
-        return ($phpcsFile->numTokens + 1);
86
+        return ( $phpcsFile->numTokens + 1 );
87 87
 
88 88
     }//end process()
89 89
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -25,8 +25,7 @@  discard block
 block discarded – undo
25 25
  * @version   Release: @package_version@
26 26
  * @link      http://pear.php.net/package/PHP_CodeSniffer
27 27
  */
28
-class Generic_Sniffs_Files_EndFileNoNewlineSniff implements PHP_CodeSniffer_Sniff
29
-{
28
+class Generic_Sniffs_Files_EndFileNoNewlineSniff implements PHP_CodeSniffer_Sniff {
30 29
 
31 30
     /**
32 31
      * A list of tokenizers this sniff supports.
@@ -45,8 +44,7 @@  discard block
 block discarded – undo
45 44
      *
46 45
      * @return array
47 46
      */
48
-    public function register()
49
-    {
47
+    public function register() {
50 48
         return array(T_OPEN_TAG);
51 49
 
52 50
     }//end register()
@@ -61,8 +59,7 @@  discard block
 block discarded – undo
61 59
      *
62 60
      * @return int
63 61
      */
64
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
65
-    {
62
+    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
66 63
         // Skip to the end of the file.
67 64
         $tokens   = $phpcsFile->getTokens();
68 65
         $stackPtr = ($phpcsFile->numTokens - 1);
Please login to merge, or discard this patch.
CodeSniffer/Standards/Generic/Sniffs/Files/InlineHTMLSniff.php 3 patches
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -30,41 +30,41 @@
 block discarded – undo
30 30
 {
31 31
 
32 32
 
33
-    /**
34
-     * Returns an array of tokens this test wants to listen for.
35
-     *
36
-     * @return array
37
-     */
38
-    public function register()
39
-    {
40
-        return array(T_INLINE_HTML);
33
+	 /**
34
+	  * Returns an array of tokens this test wants to listen for.
35
+	  *
36
+	  * @return array
37
+	  */
38
+	 public function register()
39
+	 {
40
+		  return array(T_INLINE_HTML);
41 41
 
42
-    }//end register()
42
+	 }//end register()
43 43
 
44 44
 
45
-    /**
46
-     * Processes this test, when one of its tokens is encountered.
47
-     *
48
-     * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
49
-     * @param int                  $stackPtr  The position of the current token in
50
-     *                                        the stack passed in $tokens.
51
-     *
52
-     * @return void
53
-     */
54
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
55
-    {
56
-        // Ignore shebang lines.
57
-        $tokens = $phpcsFile->getTokens();
58
-        if (substr($tokens[$stackPtr]['content'], 0, 2) === '#!') {
59
-            return;
60
-        }
45
+	 /**
46
+	  * Processes this test, when one of its tokens is encountered.
47
+	  *
48
+	  * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
49
+	  * @param int                  $stackPtr  The position of the current token in
50
+	  *                                        the stack passed in $tokens.
51
+	  *
52
+	  * @return void
53
+	  */
54
+	 public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
55
+	 {
56
+		  // Ignore shebang lines.
57
+		  $tokens = $phpcsFile->getTokens();
58
+		  if (substr($tokens[$stackPtr]['content'], 0, 2) === '#!') {
59
+				return;
60
+		  }
61 61
 
62
-        $error = 'PHP files must only contain PHP code';
63
-        $phpcsFile->addError($error, $stackPtr, 'Found');
62
+		  $error = 'PHP files must only contain PHP code';
63
+		  $phpcsFile->addError($error, $stackPtr, 'Found');
64 64
 
65
-        return $phpcsFile->numTokens;
65
+		  return $phpcsFile->numTokens;
66 66
 
67
-    }//end process()
67
+	 }//end process()
68 68
 
69 69
 
70 70
 }//end class
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
      */
38 38
     public function register()
39 39
     {
40
-        return array(T_INLINE_HTML);
40
+        return array( T_INLINE_HTML );
41 41
 
42 42
     }//end register()
43 43
 
@@ -51,16 +51,16 @@  discard block
 block discarded – undo
51 51
      *
52 52
      * @return void
53 53
      */
54
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
54
+    public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr )
55 55
     {
56 56
         // Ignore shebang lines.
57 57
         $tokens = $phpcsFile->getTokens();
58
-        if (substr($tokens[$stackPtr]['content'], 0, 2) === '#!') {
58
+        if ( substr( $tokens[ $stackPtr ][ 'content' ], 0, 2 ) === '#!' ) {
59 59
             return;
60 60
         }
61 61
 
62 62
         $error = 'PHP files must only contain PHP code';
63
-        $phpcsFile->addError($error, $stackPtr, 'Found');
63
+        $phpcsFile->addError( $error, $stackPtr, 'Found' );
64 64
 
65 65
         return $phpcsFile->numTokens;
66 66
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -26,8 +26,7 @@  discard block
 block discarded – undo
26 26
  * @version   Release: @package_version@
27 27
  * @link      http://pear.php.net/package/PHP_CodeSniffer
28 28
  */
29
-class Generic_Sniffs_Files_InlineHTMLSniff implements PHP_CodeSniffer_Sniff
30
-{
29
+class Generic_Sniffs_Files_InlineHTMLSniff implements PHP_CodeSniffer_Sniff {
31 30
 
32 31
 
33 32
     /**
@@ -35,8 +34,7 @@  discard block
 block discarded – undo
35 34
      *
36 35
      * @return array
37 36
      */
38
-    public function register()
39
-    {
37
+    public function register() {
40 38
         return array(T_INLINE_HTML);
41 39
 
42 40
     }//end register()
@@ -51,8 +49,7 @@  discard block
 block discarded – undo
51 49
      *
52 50
      * @return void
53 51
      */
54
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
55
-    {
52
+    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
56 53
         // Ignore shebang lines.
57 54
         $tokens = $phpcsFile->getTokens();
58 55
         if (substr($tokens[$stackPtr]['content'], 0, 2) === '#!') {
Please login to merge, or discard this patch.
CodeSniffer/Standards/Generic/Sniffs/Files/LowercasedFilenameSniff.php 3 patches
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -27,52 +27,52 @@
 block discarded – undo
27 27
 {
28 28
 
29 29
 
30
-    /**
31
-     * Returns an array of tokens this test wants to listen for.
32
-     *
33
-     * @return array
34
-     */
35
-    public function register()
36
-    {
37
-        return array(T_OPEN_TAG);
30
+	 /**
31
+	  * Returns an array of tokens this test wants to listen for.
32
+	  *
33
+	  * @return array
34
+	  */
35
+	 public function register()
36
+	 {
37
+		  return array(T_OPEN_TAG);
38 38
 
39
-    }//end register()
39
+	 }//end register()
40 40
 
41 41
 
42
-    /**
43
-     * Processes this sniff, when one of its tokens is encountered.
44
-     *
45
-     * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
46
-     * @param int                  $stackPtr  The position of the current token in
47
-     *                                        the stack passed in $tokens.
48
-     *
49
-     * @return int
50
-     */
51
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
52
-    {
53
-        $filename = $phpcsFile->getFilename();
54
-        if ($filename === 'STDIN') {
55
-            return;
56
-        }
42
+	 /**
43
+	  * Processes this sniff, when one of its tokens is encountered.
44
+	  *
45
+	  * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
46
+	  * @param int                  $stackPtr  The position of the current token in
47
+	  *                                        the stack passed in $tokens.
48
+	  *
49
+	  * @return int
50
+	  */
51
+	 public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
52
+	 {
53
+		  $filename = $phpcsFile->getFilename();
54
+		  if ($filename === 'STDIN') {
55
+				return;
56
+		  }
57 57
 
58
-        $filename          = basename($filename);
59
-        $lowercaseFilename = strtolower($filename);
60
-        if ($filename !== $lowercaseFilename) {
61
-            $data  = array(
62
-                      $filename,
63
-                      $lowercaseFilename,
64
-                     );
65
-            $error = 'Filename "%s" doesn\'t match the expected filename "%s"';
66
-            $phpcsFile->addError($error, $stackPtr, 'NotFound', $data);
67
-            $phpcsFile->recordMetric($stackPtr, 'Lowercase filename', 'no');
68
-        } else {
69
-            $phpcsFile->recordMetric($stackPtr, 'Lowercase filename', 'yes');
70
-        }
58
+		  $filename          = basename($filename);
59
+		  $lowercaseFilename = strtolower($filename);
60
+		  if ($filename !== $lowercaseFilename) {
61
+				$data  = array(
62
+							 $filename,
63
+							 $lowercaseFilename,
64
+							);
65
+				$error = 'Filename "%s" doesn\'t match the expected filename "%s"';
66
+				$phpcsFile->addError($error, $stackPtr, 'NotFound', $data);
67
+				$phpcsFile->recordMetric($stackPtr, 'Lowercase filename', 'no');
68
+		  } else {
69
+				$phpcsFile->recordMetric($stackPtr, 'Lowercase filename', 'yes');
70
+		  }
71 71
 
72
-        // Ignore the rest of the file.
73
-        return ($phpcsFile->numTokens + 1);
72
+		  // Ignore the rest of the file.
73
+		  return ($phpcsFile->numTokens + 1);
74 74
 
75
-    }//end process()
75
+	 }//end process()
76 76
 
77 77
 
78 78
 }//end class
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
      */
35 35
     public function register()
36 36
     {
37
-        return array(T_OPEN_TAG);
37
+        return array( T_OPEN_TAG );
38 38
 
39 39
     }//end register()
40 40
 
@@ -48,29 +48,29 @@  discard block
 block discarded – undo
48 48
      *
49 49
      * @return int
50 50
      */
51
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
51
+    public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr )
52 52
     {
53 53
         $filename = $phpcsFile->getFilename();
54
-        if ($filename === 'STDIN') {
54
+        if ( $filename === 'STDIN' ) {
55 55
             return;
56 56
         }
57 57
 
58
-        $filename          = basename($filename);
59
-        $lowercaseFilename = strtolower($filename);
60
-        if ($filename !== $lowercaseFilename) {
61
-            $data  = array(
58
+        $filename          = basename( $filename );
59
+        $lowercaseFilename = strtolower( $filename );
60
+        if ( $filename !== $lowercaseFilename ) {
61
+            $data = array(
62 62
                       $filename,
63 63
                       $lowercaseFilename,
64 64
                      );
65 65
             $error = 'Filename "%s" doesn\'t match the expected filename "%s"';
66
-            $phpcsFile->addError($error, $stackPtr, 'NotFound', $data);
67
-            $phpcsFile->recordMetric($stackPtr, 'Lowercase filename', 'no');
66
+            $phpcsFile->addError( $error, $stackPtr, 'NotFound', $data );
67
+            $phpcsFile->recordMetric( $stackPtr, 'Lowercase filename', 'no' );
68 68
         } else {
69
-            $phpcsFile->recordMetric($stackPtr, 'Lowercase filename', 'yes');
69
+            $phpcsFile->recordMetric( $stackPtr, 'Lowercase filename', 'yes' );
70 70
         }
71 71
 
72 72
         // Ignore the rest of the file.
73
-        return ($phpcsFile->numTokens + 1);
73
+        return ( $phpcsFile->numTokens + 1 );
74 74
 
75 75
     }//end process()
76 76
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -23,8 +23,7 @@  discard block
 block discarded – undo
23 23
  * @version   Release: @package_version@
24 24
  * @link      http://pear.php.net/package/PHP_CodeSniffer
25 25
  */
26
-class Generic_Sniffs_Files_LowercasedFilenameSniff implements PHP_CodeSniffer_Sniff
27
-{
26
+class Generic_Sniffs_Files_LowercasedFilenameSniff implements PHP_CodeSniffer_Sniff {
28 27
 
29 28
 
30 29
     /**
@@ -32,8 +31,7 @@  discard block
 block discarded – undo
32 31
      *
33 32
      * @return array
34 33
      */
35
-    public function register()
36
-    {
34
+    public function register() {
37 35
         return array(T_OPEN_TAG);
38 36
 
39 37
     }//end register()
@@ -48,8 +46,7 @@  discard block
 block discarded – undo
48 46
      *
49 47
      * @return int
50 48
      */
51
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
52
-    {
49
+    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
53 50
         $filename = $phpcsFile->getFilename();
54 51
         if ($filename === 'STDIN') {
55 52
             return;
Please login to merge, or discard this patch.
CodeSniffer/Standards/Generic/Sniffs/Files/OneInterfacePerFileSniff.php 3 patches
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -27,36 +27,36 @@
 block discarded – undo
27 27
 {
28 28
 
29 29
 
30
-    /**
31
-     * Returns an array of tokens this test wants to listen for.
32
-     *
33
-     * @return array
34
-     */
35
-    public function register()
36
-    {
37
-        return array(T_INTERFACE);
38
-
39
-    }//end register()
40
-
41
-
42
-    /**
43
-     * Processes this sniff, when one of its tokens is encountered.
44
-     *
45
-     * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
46
-     * @param int                  $stackPtr  The position of the current token in
47
-     *                                        the stack passed in $tokens.
48
-     *
49
-     * @return void
50
-     */
51
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
52
-    {
53
-        $nextInterface = $phpcsFile->findNext($this->register(), ($stackPtr + 1));
54
-        if ($nextInterface !== false) {
55
-            $error = 'Only one interface is allowed in a file';
56
-            $phpcsFile->addError($error, $nextInterface, 'MultipleFound');
57
-        }
58
-
59
-    }//end process()
30
+	 /**
31
+	  * Returns an array of tokens this test wants to listen for.
32
+	  *
33
+	  * @return array
34
+	  */
35
+	 public function register()
36
+	 {
37
+		  return array(T_INTERFACE);
38
+
39
+	 }//end register()
40
+
41
+
42
+	 /**
43
+	  * Processes this sniff, when one of its tokens is encountered.
44
+	  *
45
+	  * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
46
+	  * @param int                  $stackPtr  The position of the current token in
47
+	  *                                        the stack passed in $tokens.
48
+	  *
49
+	  * @return void
50
+	  */
51
+	 public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
52
+	 {
53
+		  $nextInterface = $phpcsFile->findNext($this->register(), ($stackPtr + 1));
54
+		  if ($nextInterface !== false) {
55
+				$error = 'Only one interface is allowed in a file';
56
+				$phpcsFile->addError($error, $nextInterface, 'MultipleFound');
57
+		  }
58
+
59
+	 }//end process()
60 60
 
61 61
 
62 62
 }//end class
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
      */
35 35
     public function register()
36 36
     {
37
-        return array(T_INTERFACE);
37
+        return array( T_INTERFACE );
38 38
 
39 39
     }//end register()
40 40
 
@@ -48,12 +48,12 @@  discard block
 block discarded – undo
48 48
      *
49 49
      * @return void
50 50
      */
51
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
51
+    public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr )
52 52
     {
53
-        $nextInterface = $phpcsFile->findNext($this->register(), ($stackPtr + 1));
54
-        if ($nextInterface !== false) {
53
+        $nextInterface = $phpcsFile->findNext( $this->register(), ( $stackPtr + 1 ) );
54
+        if ( $nextInterface !== false ) {
55 55
             $error = 'Only one interface is allowed in a file';
56
-            $phpcsFile->addError($error, $nextInterface, 'MultipleFound');
56
+            $phpcsFile->addError( $error, $nextInterface, 'MultipleFound' );
57 57
         }
58 58
 
59 59
     }//end process()
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -23,8 +23,7 @@  discard block
 block discarded – undo
23 23
  * @version   Release: @package_version@
24 24
  * @link      http://pear.php.net/package/PHP_CodeSniffer
25 25
  */
26
-class Generic_Sniffs_Files_OneInterfacePerFileSniff implements PHP_CodeSniffer_Sniff
27
-{
26
+class Generic_Sniffs_Files_OneInterfacePerFileSniff implements PHP_CodeSniffer_Sniff {
28 27
 
29 28
 
30 29
     /**
@@ -32,8 +31,7 @@  discard block
 block discarded – undo
32 31
      *
33 32
      * @return array
34 33
      */
35
-    public function register()
36
-    {
34
+    public function register() {
37 35
         return array(T_INTERFACE);
38 36
 
39 37
     }//end register()
@@ -48,8 +46,7 @@  discard block
 block discarded – undo
48 46
      *
49 47
      * @return void
50 48
      */
51
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
52
-    {
49
+    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
53 50
         $nextInterface = $phpcsFile->findNext($this->register(), ($stackPtr + 1));
54 51
         if ($nextInterface !== false) {
55 52
             $error = 'Only one interface is allowed in a file';
Please login to merge, or discard this patch.
CodeSniffer/Standards/Generic/Sniffs/Files/LineLengthSniff.php 3 patches
Indentation   +140 added lines, -140 removed lines patch added patch discarded remove patch
@@ -32,146 +32,146 @@
 block discarded – undo
32 32
 class Generic_Sniffs_Files_LineLengthSniff implements PHP_CodeSniffer_Sniff
33 33
 {
34 34
 
35
-    /**
36
-     * The limit that the length of a line should not exceed.
37
-     *
38
-     * @var int
39
-     */
40
-    public $lineLimit = 80;
41
-
42
-    /**
43
-     * The limit that the length of a line must not exceed.
44
-     *
45
-     * Set to zero (0) to disable.
46
-     *
47
-     * @var int
48
-     */
49
-    public $absoluteLineLimit = 100;
50
-
51
-
52
-    /**
53
-     * Returns an array of tokens this test wants to listen for.
54
-     *
55
-     * @return array
56
-     */
57
-    public function register()
58
-    {
59
-        return array(T_OPEN_TAG);
60
-
61
-    }//end register()
62
-
63
-
64
-    /**
65
-     * Processes this test, when one of its tokens is encountered.
66
-     *
67
-     * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
68
-     * @param int                  $stackPtr  The position of the current token in
69
-     *                                        the stack passed in $tokens.
70
-     *
71
-     * @return int
72
-     */
73
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
74
-    {
75
-        $tokens = $phpcsFile->getTokens();
76
-        for ($i = 1; $i < $phpcsFile->numTokens; $i++) {
77
-            if ($tokens[$i]['column'] === 1) {
78
-                $this->checkLineLength($phpcsFile, $tokens, $i);
79
-            }
80
-        }
81
-
82
-        $this->checkLineLength($phpcsFile, $tokens, $i);
83
-
84
-        // Ignore the rest of the file.
85
-        return ($phpcsFile->numTokens + 1);
86
-
87
-    }//end process()
88
-
89
-
90
-    /**
91
-     * Checks if a line is too long.
92
-     *
93
-     * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
94
-     * @param array                $tokens    The token stack.
95
-     * @param int                  $stackPtr  The first token on the next line.
96
-     *
97
-     * @return null|false
98
-     */
99
-    protected function checkLineLength(PHP_CodeSniffer_File $phpcsFile, $tokens, $stackPtr)
100
-    {
101
-        // The passed token is the first on the line.
102
-        $stackPtr--;
103
-
104
-        if ($tokens[$stackPtr]['column'] === 1
105
-            && $tokens[$stackPtr]['length'] === 0
106
-        ) {
107
-            // Blank line.
108
-            return;
109
-        }
110
-
111
-        if ($tokens[$stackPtr]['column'] !== 1
112
-            && $tokens[$stackPtr]['content'] === $phpcsFile->eolChar
113
-        ) {
114
-            $stackPtr--;
115
-        }
116
-
117
-        $lineLength = ($tokens[$stackPtr]['column'] + $tokens[$stackPtr]['length'] - 1);
118
-
119
-        // Record metrics for common line length groupings.
120
-        if ($lineLength <= 80) {
121
-            $phpcsFile->recordMetric($stackPtr, 'Line length', '80 or less');
122
-        } else if ($lineLength <= 120) {
123
-            $phpcsFile->recordMetric($stackPtr, 'Line length', '81-120');
124
-        } else if ($lineLength <= 150) {
125
-            $phpcsFile->recordMetric($stackPtr, 'Line length', '121-150');
126
-        } else {
127
-            $phpcsFile->recordMetric($stackPtr, 'Line length', '151 or more');
128
-        }
129
-
130
-        // If this is a long comment, check if it can be broken up onto multiple lines.
131
-        // Some comments contain unbreakable strings like URLs and so it makes sense
132
-        // to ignore the line length in these cases if the URL would be longer than the max
133
-        // line length once you indent it to the correct level.
134
-        if ($lineLength > $this->lineLimit
135
-            && ($tokens[$stackPtr]['code'] === T_COMMENT
136
-            || $tokens[$stackPtr]['code'] === T_DOC_COMMENT_STRING)
137
-        ) {
138
-            $oldLength = strlen($tokens[$stackPtr]['content']);
139
-            $newLength = strlen(ltrim($tokens[$stackPtr]['content'], "/#\t "));
140
-            $indent    = (($tokens[$stackPtr]['column'] - 1) + ($oldLength - $newLength));
141
-
142
-            $nonBreakingLength = $tokens[$stackPtr]['length'];
143
-
144
-            $space = strrpos($tokens[$stackPtr]['content'], ' ');
145
-            if ($space !== false) {
146
-                $nonBreakingLength -= ($space + 1);
147
-            }
148
-
149
-            if (($nonBreakingLength + $indent) > $this->lineLimit) {
150
-                return;
151
-            }
152
-        }
153
-
154
-        if ($this->absoluteLineLimit > 0
155
-            && $lineLength > $this->absoluteLineLimit
156
-        ) {
157
-            $data = array(
158
-                     $this->absoluteLineLimit,
159
-                     $lineLength,
160
-                    );
161
-
162
-            $error = 'Line exceeds maximum limit of %s characters; contains %s characters';
163
-            $phpcsFile->addError($error, $stackPtr, 'MaxExceeded', $data);
164
-        } else if ($lineLength > $this->lineLimit) {
165
-            $data = array(
166
-                     $this->lineLimit,
167
-                     $lineLength,
168
-                    );
169
-
170
-            $warning = 'Line exceeds %s characters; contains %s characters';
171
-            $phpcsFile->addWarning($warning, $stackPtr, 'TooLong', $data);
172
-        }
173
-
174
-    }//end checkLineLength()
35
+	 /**
36
+	  * The limit that the length of a line should not exceed.
37
+	  *
38
+	  * @var int
39
+	  */
40
+	 public $lineLimit = 80;
41
+
42
+	 /**
43
+	  * The limit that the length of a line must not exceed.
44
+	  *
45
+	  * Set to zero (0) to disable.
46
+	  *
47
+	  * @var int
48
+	  */
49
+	 public $absoluteLineLimit = 100;
50
+
51
+
52
+	 /**
53
+	  * Returns an array of tokens this test wants to listen for.
54
+	  *
55
+	  * @return array
56
+	  */
57
+	 public function register()
58
+	 {
59
+		  return array(T_OPEN_TAG);
60
+
61
+	 }//end register()
62
+
63
+
64
+	 /**
65
+	  * Processes this test, when one of its tokens is encountered.
66
+	  *
67
+	  * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
68
+	  * @param int                  $stackPtr  The position of the current token in
69
+	  *                                        the stack passed in $tokens.
70
+	  *
71
+	  * @return int
72
+	  */
73
+	 public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
74
+	 {
75
+		  $tokens = $phpcsFile->getTokens();
76
+		  for ($i = 1; $i < $phpcsFile->numTokens; $i++) {
77
+				if ($tokens[$i]['column'] === 1) {
78
+					 $this->checkLineLength($phpcsFile, $tokens, $i);
79
+				}
80
+		  }
81
+
82
+		  $this->checkLineLength($phpcsFile, $tokens, $i);
83
+
84
+		  // Ignore the rest of the file.
85
+		  return ($phpcsFile->numTokens + 1);
86
+
87
+	 }//end process()
88
+
89
+
90
+	 /**
91
+	  * Checks if a line is too long.
92
+	  *
93
+	  * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
94
+	  * @param array                $tokens    The token stack.
95
+	  * @param int                  $stackPtr  The first token on the next line.
96
+	  *
97
+	  * @return null|false
98
+	  */
99
+	 protected function checkLineLength(PHP_CodeSniffer_File $phpcsFile, $tokens, $stackPtr)
100
+	 {
101
+		  // The passed token is the first on the line.
102
+		  $stackPtr--;
103
+
104
+		  if ($tokens[$stackPtr]['column'] === 1
105
+				&& $tokens[$stackPtr]['length'] === 0
106
+		  ) {
107
+				// Blank line.
108
+				return;
109
+		  }
110
+
111
+		  if ($tokens[$stackPtr]['column'] !== 1
112
+				&& $tokens[$stackPtr]['content'] === $phpcsFile->eolChar
113
+		  ) {
114
+				$stackPtr--;
115
+		  }
116
+
117
+		  $lineLength = ($tokens[$stackPtr]['column'] + $tokens[$stackPtr]['length'] - 1);
118
+
119
+		  // Record metrics for common line length groupings.
120
+		  if ($lineLength <= 80) {
121
+				$phpcsFile->recordMetric($stackPtr, 'Line length', '80 or less');
122
+		  } else if ($lineLength <= 120) {
123
+				$phpcsFile->recordMetric($stackPtr, 'Line length', '81-120');
124
+		  } else if ($lineLength <= 150) {
125
+				$phpcsFile->recordMetric($stackPtr, 'Line length', '121-150');
126
+		  } else {
127
+				$phpcsFile->recordMetric($stackPtr, 'Line length', '151 or more');
128
+		  }
129
+
130
+		  // If this is a long comment, check if it can be broken up onto multiple lines.
131
+		  // Some comments contain unbreakable strings like URLs and so it makes sense
132
+		  // to ignore the line length in these cases if the URL would be longer than the max
133
+		  // line length once you indent it to the correct level.
134
+		  if ($lineLength > $this->lineLimit
135
+				&& ($tokens[$stackPtr]['code'] === T_COMMENT
136
+				|| $tokens[$stackPtr]['code'] === T_DOC_COMMENT_STRING)
137
+		  ) {
138
+				$oldLength = strlen($tokens[$stackPtr]['content']);
139
+				$newLength = strlen(ltrim($tokens[$stackPtr]['content'], "/#\t "));
140
+				$indent    = (($tokens[$stackPtr]['column'] - 1) + ($oldLength - $newLength));
141
+
142
+				$nonBreakingLength = $tokens[$stackPtr]['length'];
143
+
144
+				$space = strrpos($tokens[$stackPtr]['content'], ' ');
145
+				if ($space !== false) {
146
+					 $nonBreakingLength -= ($space + 1);
147
+				}
148
+
149
+				if (($nonBreakingLength + $indent) > $this->lineLimit) {
150
+					 return;
151
+				}
152
+		  }
153
+
154
+		  if ($this->absoluteLineLimit > 0
155
+				&& $lineLength > $this->absoluteLineLimit
156
+		  ) {
157
+				$data = array(
158
+							$this->absoluteLineLimit,
159
+							$lineLength,
160
+						  );
161
+
162
+				$error = 'Line exceeds maximum limit of %s characters; contains %s characters';
163
+				$phpcsFile->addError($error, $stackPtr, 'MaxExceeded', $data);
164
+		  } else if ($lineLength > $this->lineLimit) {
165
+				$data = array(
166
+							$this->lineLimit,
167
+							$lineLength,
168
+						  );
169
+
170
+				$warning = 'Line exceeds %s characters; contains %s characters';
171
+				$phpcsFile->addWarning($warning, $stackPtr, 'TooLong', $data);
172
+		  }
173
+
174
+	 }//end checkLineLength()
175 175
 
176 176
 
177 177
 }//end class
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
      */
57 57
     public function register()
58 58
     {
59
-        return array(T_OPEN_TAG);
59
+        return array( T_OPEN_TAG );
60 60
 
61 61
     }//end register()
62 62
 
@@ -70,19 +70,19 @@  discard block
 block discarded – undo
70 70
      *
71 71
      * @return int
72 72
      */
73
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
73
+    public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr )
74 74
     {
75 75
         $tokens = $phpcsFile->getTokens();
76
-        for ($i = 1; $i < $phpcsFile->numTokens; $i++) {
77
-            if ($tokens[$i]['column'] === 1) {
78
-                $this->checkLineLength($phpcsFile, $tokens, $i);
76
+        for ( $i = 1; $i < $phpcsFile->numTokens; $i++ ) {
77
+            if ( $tokens[ $i ][ 'column' ] === 1 ) {
78
+                $this->checkLineLength( $phpcsFile, $tokens, $i );
79 79
             }
80 80
         }
81 81
 
82
-        $this->checkLineLength($phpcsFile, $tokens, $i);
82
+        $this->checkLineLength( $phpcsFile, $tokens, $i );
83 83
 
84 84
         // Ignore the rest of the file.
85
-        return ($phpcsFile->numTokens + 1);
85
+        return ( $phpcsFile->numTokens + 1 );
86 86
 
87 87
     }//end process()
88 88
 
@@ -96,62 +96,62 @@  discard block
 block discarded – undo
96 96
      *
97 97
      * @return null|false
98 98
      */
99
-    protected function checkLineLength(PHP_CodeSniffer_File $phpcsFile, $tokens, $stackPtr)
99
+    protected function checkLineLength( PHP_CodeSniffer_File $phpcsFile, $tokens, $stackPtr )
100 100
     {
101 101
         // The passed token is the first on the line.
102 102
         $stackPtr--;
103 103
 
104
-        if ($tokens[$stackPtr]['column'] === 1
105
-            && $tokens[$stackPtr]['length'] === 0
104
+        if ( $tokens[ $stackPtr ][ 'column' ] === 1
105
+            && $tokens[ $stackPtr ][ 'length' ] === 0
106 106
         ) {
107 107
             // Blank line.
108 108
             return;
109 109
         }
110 110
 
111
-        if ($tokens[$stackPtr]['column'] !== 1
112
-            && $tokens[$stackPtr]['content'] === $phpcsFile->eolChar
111
+        if ( $tokens[ $stackPtr ][ 'column' ] !== 1
112
+            && $tokens[ $stackPtr ][ 'content' ] === $phpcsFile->eolChar
113 113
         ) {
114 114
             $stackPtr--;
115 115
         }
116 116
 
117
-        $lineLength = ($tokens[$stackPtr]['column'] + $tokens[$stackPtr]['length'] - 1);
117
+        $lineLength = ( $tokens[ $stackPtr ][ 'column' ] + $tokens[ $stackPtr ][ 'length' ] - 1 );
118 118
 
119 119
         // Record metrics for common line length groupings.
120
-        if ($lineLength <= 80) {
121
-            $phpcsFile->recordMetric($stackPtr, 'Line length', '80 or less');
122
-        } else if ($lineLength <= 120) {
123
-            $phpcsFile->recordMetric($stackPtr, 'Line length', '81-120');
124
-        } else if ($lineLength <= 150) {
125
-            $phpcsFile->recordMetric($stackPtr, 'Line length', '121-150');
120
+        if ( $lineLength <= 80 ) {
121
+            $phpcsFile->recordMetric( $stackPtr, 'Line length', '80 or less' );
122
+        } else if ( $lineLength <= 120 ) {
123
+            $phpcsFile->recordMetric( $stackPtr, 'Line length', '81-120' );
124
+        } else if ( $lineLength <= 150 ) {
125
+            $phpcsFile->recordMetric( $stackPtr, 'Line length', '121-150' );
126 126
         } else {
127
-            $phpcsFile->recordMetric($stackPtr, 'Line length', '151 or more');
127
+            $phpcsFile->recordMetric( $stackPtr, 'Line length', '151 or more' );
128 128
         }
129 129
 
130 130
         // If this is a long comment, check if it can be broken up onto multiple lines.
131 131
         // Some comments contain unbreakable strings like URLs and so it makes sense
132 132
         // to ignore the line length in these cases if the URL would be longer than the max
133 133
         // line length once you indent it to the correct level.
134
-        if ($lineLength > $this->lineLimit
135
-            && ($tokens[$stackPtr]['code'] === T_COMMENT
136
-            || $tokens[$stackPtr]['code'] === T_DOC_COMMENT_STRING)
134
+        if ( $lineLength > $this->lineLimit
135
+            && ( $tokens[ $stackPtr ][ 'code' ] === T_COMMENT
136
+            || $tokens[ $stackPtr ][ 'code' ] === T_DOC_COMMENT_STRING )
137 137
         ) {
138
-            $oldLength = strlen($tokens[$stackPtr]['content']);
139
-            $newLength = strlen(ltrim($tokens[$stackPtr]['content'], "/#\t "));
140
-            $indent    = (($tokens[$stackPtr]['column'] - 1) + ($oldLength - $newLength));
138
+            $oldLength = strlen( $tokens[ $stackPtr ][ 'content' ] );
139
+            $newLength = strlen( ltrim( $tokens[ $stackPtr ][ 'content' ], "/#\t " ) );
140
+            $indent    = ( ( $tokens[ $stackPtr ][ 'column' ] - 1 ) + ( $oldLength - $newLength ) );
141 141
 
142
-            $nonBreakingLength = $tokens[$stackPtr]['length'];
142
+            $nonBreakingLength = $tokens[ $stackPtr ][ 'length' ];
143 143
 
144
-            $space = strrpos($tokens[$stackPtr]['content'], ' ');
145
-            if ($space !== false) {
146
-                $nonBreakingLength -= ($space + 1);
144
+            $space = strrpos( $tokens[ $stackPtr ][ 'content' ], ' ' );
145
+            if ( $space !== false ) {
146
+                $nonBreakingLength -= ( $space + 1 );
147 147
             }
148 148
 
149
-            if (($nonBreakingLength + $indent) > $this->lineLimit) {
149
+            if ( ( $nonBreakingLength + $indent ) > $this->lineLimit ) {
150 150
                 return;
151 151
             }
152 152
         }
153 153
 
154
-        if ($this->absoluteLineLimit > 0
154
+        if ( $this->absoluteLineLimit > 0
155 155
             && $lineLength > $this->absoluteLineLimit
156 156
         ) {
157 157
             $data = array(
@@ -160,15 +160,15 @@  discard block
 block discarded – undo
160 160
                     );
161 161
 
162 162
             $error = 'Line exceeds maximum limit of %s characters; contains %s characters';
163
-            $phpcsFile->addError($error, $stackPtr, 'MaxExceeded', $data);
164
-        } else if ($lineLength > $this->lineLimit) {
163
+            $phpcsFile->addError( $error, $stackPtr, 'MaxExceeded', $data );
164
+        } else if ( $lineLength > $this->lineLimit ) {
165 165
             $data = array(
166 166
                      $this->lineLimit,
167 167
                      $lineLength,
168 168
                     );
169 169
 
170 170
             $warning = 'Line exceeds %s characters; contains %s characters';
171
-            $phpcsFile->addWarning($warning, $stackPtr, 'TooLong', $data);
171
+            $phpcsFile->addWarning( $warning, $stackPtr, 'TooLong', $data );
172 172
         }
173 173
 
174 174
     }//end checkLineLength()
Please login to merge, or discard this patch.
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -29,8 +29,7 @@  discard block
 block discarded – undo
29 29
  * @version   Release: @package_version@
30 30
  * @link      http://pear.php.net/package/PHP_CodeSniffer
31 31
  */
32
-class Generic_Sniffs_Files_LineLengthSniff implements PHP_CodeSniffer_Sniff
33
-{
32
+class Generic_Sniffs_Files_LineLengthSniff implements PHP_CodeSniffer_Sniff {
34 33
 
35 34
     /**
36 35
      * The limit that the length of a line should not exceed.
@@ -54,8 +53,7 @@  discard block
 block discarded – undo
54 53
      *
55 54
      * @return array
56 55
      */
57
-    public function register()
58
-    {
56
+    public function register() {
59 57
         return array(T_OPEN_TAG);
60 58
 
61 59
     }//end register()
@@ -70,8 +68,7 @@  discard block
 block discarded – undo
70 68
      *
71 69
      * @return int
72 70
      */
73
-    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
74
-    {
71
+    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
75 72
         $tokens = $phpcsFile->getTokens();
76 73
         for ($i = 1; $i < $phpcsFile->numTokens; $i++) {
77 74
             if ($tokens[$i]['column'] === 1) {
@@ -96,8 +93,7 @@  discard block
 block discarded – undo
96 93
      *
97 94
      * @return null|false
98 95
      */
99
-    protected function checkLineLength(PHP_CodeSniffer_File $phpcsFile, $tokens, $stackPtr)
100
-    {
96
+    protected function checkLineLength(PHP_CodeSniffer_File $phpcsFile, $tokens, $stackPtr) {
101 97
         // The passed token is the first on the line.
102 98
         $stackPtr--;
103 99
 
Please login to merge, or discard this patch.