Completed
Pull Request — develop (#1492)
by
unknown
16:55 queued 12s
created
wpcs/WordPress/Sniffs/PHP/StrictInArraySniff.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -81,20 +81,20 @@
 block discarded – undo
81 81
 		}
82 82
 
83 83
 		// We're only interested in the third parameter.
84
-		if ( false === isset( $parameters[3] ) || 'true' !== strtolower( $parameters[3]['raw'] ) ) {
84
+		if ( false === isset( $parameters[ 3 ] ) || 'true' !== strtolower( $parameters[ 3 ][ 'raw' ] ) ) {
85 85
 			$errorcode = 'MissingTrueStrict';
86 86
 
87 87
 			/*
88 88
 			 * Use a different error code when `false` is found to allow for excluding
89 89
 			 * the warning as this will be a conscious choice made by the dev.
90 90
 			 */
91
-			if ( isset( $parameters[3] ) && 'false' === strtolower( $parameters[3]['raw'] ) ) {
91
+			if ( isset( $parameters[ 3 ] ) && 'false' === strtolower( $parameters[ 3 ][ 'raw' ] ) ) {
92 92
 				$errorcode = 'FoundNonStrictFalse';
93 93
 			}
94 94
 
95 95
 			$this->phpcsFile->addWarning(
96 96
 				'Not using strict comparison for %s; supply true for third argument.',
97
-				( isset( $parameters[3]['start'] ) ? $parameters[3]['start'] : $parameters[1]['start'] ),
97
+				( isset( $parameters[ 3 ][ 'start' ] ) ? $parameters[ 3 ][ 'start' ] : $parameters[ 1 ][ 'start' ] ),
98 98
 				$errorcode,
99 99
 				array( $matched_content )
100 100
 			);
Please login to merge, or discard this patch.
wpcs/WordPress/Sniffs/DB/DirectDatabaseQuerySniff.php 2 patches
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	public function process_token( $stackPtr ) {
115 115
 
116 116
 		// Check for $wpdb variable.
117
-		if ( '$wpdb' !== $this->tokens[ $stackPtr ]['content'] ) {
117
+		if ( '$wpdb' !== $this->tokens[ $stackPtr ][ 'content' ] ) {
118 118
 			return;
119 119
 		}
120 120
 
@@ -124,11 +124,11 @@  discard block
 block discarded – undo
124 124
 		}
125 125
 
126 126
 		$methodPtr = $this->phpcsFile->findNext( array( \T_WHITESPACE ), ( $is_object_call + 1 ), null, true, null, true );
127
-		$method    = $this->tokens[ $methodPtr ]['content'];
127
+		$method    = $this->tokens[ $methodPtr ][ 'content' ];
128 128
 
129 129
 		$this->mergeFunctionLists();
130 130
 
131
-		if ( ! isset( $this->methods['all'][ $method ] ) ) {
131
+		if ( ! isset( $this->methods[ 'all' ][ $method ] ) ) {
132 132
 			return;
133 133
 		}
134 134
 
@@ -136,12 +136,12 @@  discard block
 block discarded – undo
136 136
 		$endOfLineComment = '';
137 137
 		for ( $i = ( $endOfStatement + 1 ); $i < $this->phpcsFile->numTokens; $i++ ) {
138 138
 
139
-			if ( $this->tokens[ $i ]['line'] !== $this->tokens[ $endOfStatement ]['line'] ) {
139
+			if ( $this->tokens[ $i ][ 'line' ] !== $this->tokens[ $endOfStatement ][ 'line' ] ) {
140 140
 				break;
141 141
 			}
142 142
 
143
-			if ( \T_COMMENT === $this->tokens[ $i ]['code'] ) {
144
-				$endOfLineComment .= $this->tokens[ $i ]['content'];
143
+			if ( \T_COMMENT === $this->tokens[ $i ][ 'code' ] ) {
144
+				$endOfLineComment .= $this->tokens[ $i ][ 'content' ];
145 145
 			}
146 146
 		}
147 147
 
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 				break;
158 158
 			}
159 159
 
160
-			if ( preg_match( '#\b(?:ALTER|CREATE|DROP)\b#i', $this->tokens[ $_pos ]['content'] ) > 0 ) {
160
+			if ( preg_match( '#\b(?:ALTER|CREATE|DROP)\b#i', $this->tokens[ $_pos ][ 'content' ] ) > 0 ) {
161 161
 				$this->phpcsFile->addWarning( 'Attempting a database schema change is discouraged.', $_pos, 'SchemaChange' );
162 162
 			}
163 163
 		}
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 			$this->phpcsFile->addWarning( 'Usage of a direct database call is discouraged.', $stackPtr, 'DirectQuery' );
168 168
 		}
169 169
 
170
-		if ( ! isset( $this->methods['cachable'][ $method ] ) ) {
170
+		if ( ! isset( $this->methods[ 'cachable' ][ $method ] ) ) {
171 171
 			return $endOfStatement;
172 172
 		}
173 173
 
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 		if ( preg_match( '/cache\s+(?:ok|pass|clear|whitelist)/i', $endOfLineComment ) ) {
178 178
 			$whitelisted_cache = true;
179 179
 		}
180
-		if ( ! $whitelisted_cache && ! empty( $this->tokens[ $stackPtr ]['conditions'] ) ) {
180
+		if ( ! $whitelisted_cache && ! empty( $this->tokens[ $stackPtr ][ 'conditions' ] ) ) {
181 181
 			$scope_function = $this->phpcsFile->getCondition( $stackPtr, \T_FUNCTION );
182 182
 
183 183
 			if ( false === $scope_function ) {
@@ -185,23 +185,23 @@  discard block
 block discarded – undo
185 185
 			}
186 186
 
187 187
 			if ( false !== $scope_function ) {
188
-				$scopeStart = $this->tokens[ $scope_function ]['scope_opener'];
189
-				$scopeEnd   = $this->tokens[ $scope_function ]['scope_closer'];
188
+				$scopeStart = $this->tokens[ $scope_function ][ 'scope_opener' ];
189
+				$scopeEnd   = $this->tokens[ $scope_function ][ 'scope_closer' ];
190 190
 
191 191
 				for ( $i = ( $scopeStart + 1 ); $i < $scopeEnd; $i++ ) {
192
-					if ( \T_STRING === $this->tokens[ $i ]['code'] ) {
192
+					if ( \T_STRING === $this->tokens[ $i ][ 'code' ] ) {
193 193
 
194
-						if ( isset( $this->cacheDeleteFunctions[ $this->tokens[ $i ]['content'] ] ) ) {
194
+						if ( isset( $this->cacheDeleteFunctions[ $this->tokens[ $i ][ 'content' ] ] ) ) {
195 195
 
196 196
 							if ( \in_array( $method, array( 'query', 'update', 'replace', 'delete' ), true ) ) {
197 197
 								$cached = true;
198 198
 								break;
199 199
 							}
200
-						} elseif ( isset( $this->cacheGetFunctions[ $this->tokens[ $i ]['content'] ] ) ) {
200
+						} elseif ( isset( $this->cacheGetFunctions[ $this->tokens[ $i ][ 'content' ] ] ) ) {
201 201
 
202 202
 							$wp_cache_get = true;
203 203
 
204
-						} elseif ( isset( $this->cacheSetFunctions[ $this->tokens[ $i ]['content'] ] ) ) {
204
+						} elseif ( isset( $this->cacheSetFunctions[ $this->tokens[ $i ][ 'content' ] ] ) ) {
205 205
 
206 206
 							if ( $wp_cache_get ) {
207 207
 								$cached = true;
@@ -229,35 +229,35 @@  discard block
 block discarded – undo
229 229
 	 * @return void
230 230
 	 */
231 231
 	protected function mergeFunctionLists() {
232
-		if ( ! isset( $this->methods['all'] ) ) {
233
-			$this->methods['all'] = array_merge( $this->methods['cachable'], $this->methods['noncachable'] );
232
+		if ( ! isset( $this->methods[ 'all' ] ) ) {
233
+			$this->methods[ 'all' ] = array_merge( $this->methods[ 'cachable' ], $this->methods[ 'noncachable' ] );
234 234
 		}
235 235
 
236
-		if ( $this->customCacheGetFunctions !== $this->addedCustomFunctions['cacheget'] ) {
236
+		if ( $this->customCacheGetFunctions !== $this->addedCustomFunctions[ 'cacheget' ] ) {
237 237
 			$this->cacheGetFunctions = $this->merge_custom_array(
238 238
 				$this->customCacheGetFunctions,
239 239
 				$this->cacheGetFunctions
240 240
 			);
241 241
 
242
-			$this->addedCustomFunctions['cacheget'] = $this->customCacheGetFunctions;
242
+			$this->addedCustomFunctions[ 'cacheget' ] = $this->customCacheGetFunctions;
243 243
 		}
244 244
 
245
-		if ( $this->customCacheSetFunctions !== $this->addedCustomFunctions['cacheset'] ) {
245
+		if ( $this->customCacheSetFunctions !== $this->addedCustomFunctions[ 'cacheset' ] ) {
246 246
 			$this->cacheSetFunctions = $this->merge_custom_array(
247 247
 				$this->customCacheSetFunctions,
248 248
 				$this->cacheSetFunctions
249 249
 			);
250 250
 
251
-			$this->addedCustomFunctions['cacheset'] = $this->customCacheSetFunctions;
251
+			$this->addedCustomFunctions[ 'cacheset' ] = $this->customCacheSetFunctions;
252 252
 		}
253 253
 
254
-		if ( $this->customCacheDeleteFunctions !== $this->addedCustomFunctions['cachedelete'] ) {
254
+		if ( $this->customCacheDeleteFunctions !== $this->addedCustomFunctions[ 'cachedelete' ] ) {
255 255
 			$this->cacheDeleteFunctions = $this->merge_custom_array(
256 256
 				$this->customCacheDeleteFunctions,
257 257
 				$this->cacheDeleteFunctions
258 258
 			);
259 259
 
260
-			$this->addedCustomFunctions['cachedelete'] = $this->customCacheDeleteFunctions;
260
+			$this->addedCustomFunctions[ 'cachedelete' ] = $this->customCacheDeleteFunctions;
261 261
 		}
262 262
 	}
263 263
 
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@
 block discarded – undo
29 29
 	/**
30 30
 	 * Returns an array of tokens this test wants to listen for.
31 31
 	 *
32
-	 * @return array
32
+	 * @return integer[]
33 33
 	 */
34 34
 	public function register() {
35 35
 		return array(
Please login to merge, or discard this patch.
wpcs/WordPress/Sniffs/DB/PreparedSQLPlaceholdersSniff.php 2 patches
Spacing   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 			return;
180 180
 		}
181 181
 
182
-		$query                    = $parameters[1];
182
+		$query                    = $parameters[ 1 ];
183 183
 		$text_string_tokens_found = false;
184 184
 		$variable_found           = false;
185 185
 		$sql_wildcard_found       = false;
@@ -191,51 +191,51 @@  discard block
 block discarded – undo
191 191
 			'adjustment_count' => 0,
192 192
 		);
193 193
 
194
-		for ( $i = $query['start']; $i <= $query['end']; $i++ ) {
194
+		for ( $i = $query[ 'start' ]; $i <= $query[ 'end' ]; $i++ ) {
195 195
 			// Skip over groups of tokens if they are part of an inline function call.
196 196
 			if ( isset( $skip_from, $skip_to ) && $i >= $skip_from && $i < $skip_to ) {
197 197
 				$i = $skip_to;
198 198
 				continue;
199 199
 			}
200 200
 
201
-			if ( ! isset( Tokens::$textStringTokens[ $this->tokens[ $i ]['code'] ] ) ) {
202
-				if ( \T_VARIABLE === $this->tokens[ $i ]['code'] ) {
203
-					if ( '$wpdb' !== $this->tokens[ $i ]['content'] ) {
201
+			if ( ! isset( Tokens::$textStringTokens[ $this->tokens[ $i ][ 'code' ] ] ) ) {
202
+				if ( \T_VARIABLE === $this->tokens[ $i ][ 'code' ] ) {
203
+					if ( '$wpdb' !== $this->tokens[ $i ][ 'content' ] ) {
204 204
 						$variable_found = true;
205 205
 					}
206 206
 					continue;
207 207
 				}
208 208
 
209 209
 				// Detect a specific pattern for variable replacements in combination with `IN`.
210
-				if ( \T_STRING === $this->tokens[ $i ]['code'] ) {
210
+				if ( \T_STRING === $this->tokens[ $i ][ 'code' ] ) {
211 211
 
212
-					if ( 'sprintf' === strtolower( $this->tokens[ $i ]['content'] ) ) {
212
+					if ( 'sprintf' === strtolower( $this->tokens[ $i ][ 'content' ] ) ) {
213 213
 						$sprintf_parameters = $this->get_function_call_parameters( $i );
214 214
 
215 215
 						if ( ! empty( $sprintf_parameters ) ) {
216
-							$skip_from  = ( $sprintf_parameters[1]['end'] + 1 );
216
+							$skip_from  = ( $sprintf_parameters[ 1 ][ 'end' ] + 1 );
217 217
 							$last_param = end( $sprintf_parameters );
218
-							$skip_to    = ( $last_param['end'] + 1 );
218
+							$skip_to    = ( $last_param[ 'end' ] + 1 );
219 219
 
220
-							$valid_in_clauses['implode_fill']     += $this->analyse_sprintf( $sprintf_parameters );
221
-							$valid_in_clauses['adjustment_count'] += ( \count( $sprintf_parameters ) - 1 );
220
+							$valid_in_clauses[ 'implode_fill' ]     += $this->analyse_sprintf( $sprintf_parameters );
221
+							$valid_in_clauses[ 'adjustment_count' ] += ( \count( $sprintf_parameters ) - 1 );
222 222
 						}
223 223
 						unset( $sprintf_parameters, $last_param );
224 224
 
225
-					} elseif ( 'implode' === strtolower( $this->tokens[ $i ]['content'] ) ) {
225
+					} elseif ( 'implode' === strtolower( $this->tokens[ $i ][ 'content' ] ) ) {
226 226
 						$prev = $this->phpcsFile->findPrevious(
227 227
 							Tokens::$textStringTokens,
228 228
 							( $i - 1 ),
229
-							$query['start']
229
+							$query[ 'start' ]
230 230
 						);
231 231
 
232
-						$prev_content = $this->strip_quotes( $this->tokens[ $prev ]['content'] );
233
-						$regex_quote  = $this->get_regex_quote_snippet( $prev_content, $this->tokens[ $prev ]['content'] );
232
+						$prev_content = $this->strip_quotes( $this->tokens[ $prev ][ 'content' ] );
233
+						$regex_quote  = $this->get_regex_quote_snippet( $prev_content, $this->tokens[ $prev ][ 'content' ] );
234 234
 
235 235
 						// Only examine the implode if preceded by an ` IN (`.
236 236
 						if ( preg_match( '`\s+IN\s*\(\s*(' . $regex_quote . ')?$`i', $prev_content, $match ) > 0 ) {
237 237
 
238
-							if ( isset( $match[1] ) && $regex_quote !== $this->regex_quote ) {
238
+							if ( isset( $match[ 1 ] ) && $regex_quote !== $this->regex_quote ) {
239 239
 								$this->phpcsFile->addError(
240 240
 									'Dynamic placeholder generation should not have surrounding quotes.',
241 241
 									$i,
@@ -244,15 +244,15 @@  discard block
 block discarded – undo
244 244
 							}
245 245
 
246 246
 							if ( $this->analyse_implode( $i ) === true ) {
247
-								++$valid_in_clauses['uses_in'];
248
-								++$valid_in_clauses['implode_fill'];
247
+								++$valid_in_clauses[ 'uses_in' ];
248
+								++$valid_in_clauses[ 'implode_fill' ];
249 249
 
250 250
 								$next = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $i + 1 ), null, true );
251
-								if ( \T_OPEN_PARENTHESIS === $this->tokens[ $next ]['code']
252
-									&& isset( $this->tokens[ $next ]['parenthesis_closer'] )
251
+								if ( \T_OPEN_PARENTHESIS === $this->tokens[ $next ][ 'code' ]
252
+									&& isset( $this->tokens[ $next ][ 'parenthesis_closer' ] )
253 253
 								) {
254 254
 									$skip_from = ( $i + 1 );
255
-									$skip_to   = ( $this->tokens[ $next ]['parenthesis_closer'] + 1 );
255
+									$skip_to   = ( $this->tokens[ $next ][ 'parenthesis_closer' ] + 1 );
256 256
 								}
257 257
 							}
258 258
 						}
@@ -264,16 +264,16 @@  discard block
 block discarded – undo
264 264
 			}
265 265
 
266 266
 			$text_string_tokens_found = true;
267
-			$content                  = $this->tokens[ $i ]['content'];
267
+			$content                  = $this->tokens[ $i ][ 'content' ];
268 268
 
269 269
 			$regex_quote = $this->regex_quote;
270
-			if ( isset( Tokens::$stringTokens[ $this->tokens[ $i ]['code'] ] ) ) {
270
+			if ( isset( Tokens::$stringTokens[ $this->tokens[ $i ][ 'code' ] ] ) ) {
271 271
 				$content     = $this->strip_quotes( $content );
272
-				$regex_quote = $this->get_regex_quote_snippet( $content, $this->tokens[ $i ]['content'] );
272
+				$regex_quote = $this->get_regex_quote_snippet( $content, $this->tokens[ $i ][ 'content' ] );
273 273
 			}
274 274
 
275
-			if ( \T_DOUBLE_QUOTED_STRING === $this->tokens[ $i ]['code']
276
-				|| \T_HEREDOC === $this->tokens[ $i ]['code']
275
+			if ( \T_DOUBLE_QUOTED_STRING === $this->tokens[ $i ][ 'code' ]
276
+				|| \T_HEREDOC === $this->tokens[ $i ][ 'code' ]
277 277
 			) {
278 278
 				// Only interested in actual query text, so strip out variables.
279 279
 				$stripped_content = $this->strip_interpolated_variables( $content );
@@ -305,23 +305,23 @@  discard block
 block discarded – undo
305 305
 			$regex = '`\s+LIKE\s*(?:(' . $regex_quote . ')(?!%s(?:\1|$))(?P<content>.*?)(?:\1|$)|(?:concat\((?![^\)]*%s[^\)]*\))(?P<concat>[^\)]*))\))`i';
306 306
 			if ( preg_match_all( $regex, $content, $matches ) > 0 ) {
307 307
 				$walk = array();
308
-				if ( ! empty( $matches['content'] ) ) {
309
-					$matches['content'] = array_filter( $matches['content'] );
310
-					if ( ! empty( $matches['content'] ) ) {
311
-						$walk[] = 'content';
308
+				if ( ! empty( $matches[ 'content' ] ) ) {
309
+					$matches[ 'content' ] = array_filter( $matches[ 'content' ] );
310
+					if ( ! empty( $matches[ 'content' ] ) ) {
311
+						$walk[ ] = 'content';
312 312
 					}
313 313
 				}
314
-				if ( ! empty( $matches['concat'] ) ) {
315
-					$matches['concat'] = array_filter( $matches['concat'] );
316
-					if ( ! empty( $matches['concat'] ) ) {
317
-						$walk[] = 'concat';
314
+				if ( ! empty( $matches[ 'concat' ] ) ) {
315
+					$matches[ 'concat' ] = array_filter( $matches[ 'concat' ] );
316
+					if ( ! empty( $matches[ 'concat' ] ) ) {
317
+						$walk[ ] = 'concat';
318 318
 					}
319 319
 				}
320 320
 
321 321
 				if ( ! empty( $walk ) ) {
322 322
 					foreach ( $walk as $match_key ) {
323 323
 						foreach ( $matches[ $match_key ] as $index => $match ) {
324
-							$data = array( $matches[0][ $index ] );
324
+							$data = array( $matches[ 0 ][ $index ] );
325 325
 
326 326
 							// Both a `%` as well as a `_` are wildcards in SQL.
327 327
 							if ( strpos( $match, '%' ) === false && strpos( $match, '_' ) === false ) {
@@ -370,8 +370,8 @@  discard block
 block discarded – undo
370 370
 			 * Analyse the query for unsupported placeholders.
371 371
 			 */
372 372
 			if ( preg_match_all( self::UNSUPPORTED_PLACEHOLDER_REGEX, $content, $matches ) > 0 ) {
373
-				if ( ! empty( $matches[0] ) ) {
374
-					foreach ( $matches[0] as $match ) {
373
+				if ( ! empty( $matches[ 0 ] ) ) {
374
+					foreach ( $matches[ 0 ] as $match ) {
375 375
 						if ( '%' === $match ) {
376 376
 							$this->phpcsFile->addError(
377 377
 								'Found unescaped literal "%%" character.',
@@ -397,8 +397,8 @@  discard block
 block discarded – undo
397 397
 			 */
398 398
 			$regex = '`(' . $regex_quote . ')%[dfFs]\1`';
399 399
 			if ( preg_match_all( $regex, $content, $matches ) > 0 ) {
400
-				if ( ! empty( $matches[0] ) ) {
401
-					foreach ( $matches[0] as $match ) {
400
+				if ( ! empty( $matches[ 0 ] ) ) {
401
+					foreach ( $matches[ 0 ] as $match ) {
402 402
 						$this->phpcsFile->addError(
403 403
 							'Simple placeholders should not be quoted in the query string in $wpdb->prepare(). Found: %s.',
404 404
 							$i,
@@ -415,8 +415,8 @@  discard block
 block discarded – undo
415 415
 			 */
416 416
 			$regex = '`(?<!' . $regex_quote . ')' . self::PREPARE_PLACEHOLDER_REGEX . '(?!' . $regex_quote . ')`x';
417 417
 			if ( preg_match_all( $regex, $content, $matches ) > 0 ) {
418
-				if ( ! empty( $matches[0] ) ) {
419
-					foreach ( $matches[0] as $match ) {
418
+				if ( ! empty( $matches[ 0 ] ) ) {
419
+					foreach ( $matches[ 0 ] as $match ) {
420 420
 						if ( preg_match( '`%[dfFs]`', $match ) !== 1 ) {
421 421
 							$this->phpcsFile->addWarning(
422 422
 								'Complex placeholders used for values in the query string in $wpdb->prepare() will NOT be quoted automagically. Found: %s.',
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
 			 */
436 436
 			$found_in = preg_match_all( '`\s+IN\s*\(\s*%s\s*\)`i', $content, $matches );
437 437
 			if ( $found_in > 0 ) {
438
-				$valid_in_clauses['uses_in'] += $found_in;
438
+				$valid_in_clauses[ 'uses_in' ] += $found_in;
439 439
 			}
440 440
 			unset( $found_in );
441 441
 		}
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
 						'UnnecessaryPrepare'
466 466
 					);
467 467
 				}
468
-			} elseif ( false === $count_diff_whitelisted && 0 === $valid_in_clauses['uses_in'] ) {
468
+			} elseif ( false === $count_diff_whitelisted && 0 === $valid_in_clauses[ 'uses_in' ] ) {
469 469
 				$this->phpcsFile->addWarning(
470 470
 					'Replacement variables found, but no valid placeholders found in the query.',
471 471
 					$i,
@@ -494,28 +494,28 @@  discard block
 block discarded – undo
494 494
 		array_shift( $replacements ); // Remove the query.
495 495
 
496 496
 		// The parameters may have been passed as an array in parameter 2.
497
-		if ( isset( $parameters[2] ) && 2 === $total_parameters ) {
497
+		if ( isset( $parameters[ 2 ] ) && 2 === $total_parameters ) {
498 498
 			$next = $this->phpcsFile->findNext(
499 499
 				Tokens::$emptyTokens,
500
-				$parameters[2]['start'],
501
-				( $parameters[2]['end'] + 1 ),
500
+				$parameters[ 2 ][ 'start' ],
501
+				( $parameters[ 2 ][ 'end' ] + 1 ),
502 502
 				true
503 503
 			);
504 504
 
505 505
 			if ( false !== $next
506
-				&& ( \T_ARRAY === $this->tokens[ $next ]['code']
507
-					|| \T_OPEN_SHORT_ARRAY === $this->tokens[ $next ]['code'] )
506
+				&& ( \T_ARRAY === $this->tokens[ $next ][ 'code' ]
507
+					|| \T_OPEN_SHORT_ARRAY === $this->tokens[ $next ][ 'code' ] )
508 508
 			) {
509 509
 				$replacements = $this->get_function_call_parameters( $next );
510 510
 			}
511 511
 		}
512 512
 
513 513
 		$total_replacements  = \count( $replacements );
514
-		$total_placeholders -= $valid_in_clauses['adjustment_count'];
514
+		$total_placeholders -= $valid_in_clauses[ 'adjustment_count' ];
515 515
 
516 516
 		// Bow out when `IN` clauses have been used which appear to be correct.
517
-		if ( $valid_in_clauses['uses_in'] > 0
518
-			&& $valid_in_clauses['uses_in'] === $valid_in_clauses['implode_fill']
517
+		if ( $valid_in_clauses[ 'uses_in' ] > 0
518
+			&& $valid_in_clauses[ 'uses_in' ] === $valid_in_clauses[ 'implode_fill' ]
519 519
 			&& 1 === $total_replacements
520 520
 		) {
521 521
 			return;
@@ -553,7 +553,7 @@  discard block
 block discarded – undo
553 553
 		$regex_quote = $this->regex_quote;
554 554
 
555 555
 		if ( $original_content !== $stripped_content ) {
556
-			$quote_style = $original_content[0];
556
+			$quote_style = $original_content[ 0 ];
557 557
 
558 558
 			if ( '"' === $quote_style ) {
559 559
 				$regex_quote = '\\\\"|\'';
@@ -581,21 +581,21 @@  discard block
 block discarded – undo
581 581
 	protected function analyse_sprintf( $sprintf_params ) {
582 582
 		$found = 0;
583 583
 
584
-		unset( $sprintf_params[1] );
584
+		unset( $sprintf_params[ 1 ] );
585 585
 
586 586
 		foreach ( $sprintf_params as $sprintf_param ) {
587
-			if ( strpos( strtolower( $sprintf_param['raw'] ), 'implode' ) === false ) {
587
+			if ( strpos( strtolower( $sprintf_param[ 'raw' ] ), 'implode' ) === false ) {
588 588
 				continue;
589 589
 			}
590 590
 
591 591
 			$implode = $this->phpcsFile->findNext(
592 592
 				Tokens::$emptyTokens,
593
-				$sprintf_param['start'],
594
-				$sprintf_param['end'],
593
+				$sprintf_param[ 'start' ],
594
+				$sprintf_param[ 'end' ],
595 595
 				true
596 596
 			);
597
-			if ( \T_STRING === $this->tokens[ $implode ]['code']
598
-				&& 'implode' === strtolower( $this->tokens[ $implode ]['content'] )
597
+			if ( \T_STRING === $this->tokens[ $implode ][ 'code' ]
598
+				&& 'implode' === strtolower( $this->tokens[ $implode ][ 'content' ] )
599 599
 			) {
600 600
 				if ( $this->analyse_implode( $implode ) === true ) {
601 601
 					++$found;
@@ -628,23 +628,23 @@  discard block
 block discarded – undo
628 628
 			return false;
629 629
 		}
630 630
 
631
-		if ( preg_match( '`^(["\']), ?\1$`', $implode_params[1]['raw'] ) !== 1 ) {
631
+		if ( preg_match( '`^(["\']), ?\1$`', $implode_params[ 1 ][ 'raw' ] ) !== 1 ) {
632 632
 			return false;
633 633
 		}
634 634
 
635
-		if ( strpos( strtolower( $implode_params[2]['raw'] ), 'array_fill' ) === false ) {
635
+		if ( strpos( strtolower( $implode_params[ 2 ][ 'raw' ] ), 'array_fill' ) === false ) {
636 636
 			return false;
637 637
 		}
638 638
 
639 639
 		$array_fill = $this->phpcsFile->findNext(
640 640
 			Tokens::$emptyTokens,
641
-			$implode_params[2]['start'],
642
-			$implode_params[2]['end'],
641
+			$implode_params[ 2 ][ 'start' ],
642
+			$implode_params[ 2 ][ 'end' ],
643 643
 			true
644 644
 		);
645 645
 
646
-		if ( \T_STRING !== $this->tokens[ $array_fill ]['code']
647
-			|| 'array_fill' !== strtolower( $this->tokens[ $array_fill ]['content'] )
646
+		if ( \T_STRING !== $this->tokens[ $array_fill ][ 'code' ]
647
+			|| 'array_fill' !== strtolower( $this->tokens[ $array_fill ][ 'content' ] )
648 648
 		) {
649 649
 			return false;
650 650
 		}
@@ -655,7 +655,7 @@  discard block
 block discarded – undo
655 655
 			return false;
656 656
 		}
657 657
 
658
-		return (bool) preg_match( '`^(["\'])%[dfFs]\1$`', $array_fill_params[3]['raw'] );
658
+		return (bool)preg_match( '`^(["\'])%[dfFs]\1$`', $array_fill_params[ 3 ][ 'raw' ] );
659 659
 	}
660 660
 
661 661
 }
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -150,7 +150,7 @@
 block discarded – undo
150 150
 	 *
151 151
 	 * @since 0.14.0
152 152
 	 *
153
-	 * @return array
153
+	 * @return integer[]
154 154
 	 */
155 155
 	public function register() {
156 156
 		return array(
Please login to merge, or discard this patch.
wpcs/WordPress/Sniffs/DB/PreparedSQLSniff.php 2 patches
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -132,17 +132,17 @@  discard block
 block discarded – undo
132 132
 
133 133
 		for ( $this->i; $this->i < $this->end; $this->i++ ) {
134 134
 
135
-			if ( isset( $this->ignored_tokens[ $this->tokens[ $this->i ]['code'] ] ) ) {
135
+			if ( isset( $this->ignored_tokens[ $this->tokens[ $this->i ][ 'code' ] ] ) ) {
136 136
 				continue;
137 137
 			}
138 138
 
139
-			if ( \T_DOUBLE_QUOTED_STRING === $this->tokens[ $this->i ]['code']
140
-				|| \T_HEREDOC === $this->tokens[ $this->i ]['code']
139
+			if ( \T_DOUBLE_QUOTED_STRING === $this->tokens[ $this->i ][ 'code' ]
140
+				|| \T_HEREDOC === $this->tokens[ $this->i ][ 'code' ]
141 141
 			) {
142 142
 
143 143
 				$bad_variables = array_filter(
144
-					$this->get_interpolated_variables( $this->tokens[ $this->i ]['content'] ),
145
-					function ( $symbol ) {
144
+					$this->get_interpolated_variables( $this->tokens[ $this->i ][ 'content' ] ),
145
+					function( $symbol ) {
146 146
 						return ( 'wpdb' !== $symbol );
147 147
 					}
148 148
 				);
@@ -154,15 +154,15 @@  discard block
 block discarded – undo
154 154
 						'InterpolatedNotPrepared',
155 155
 						array(
156 156
 							$bad_variable,
157
-							$this->tokens[ $this->i ]['content'],
157
+							$this->tokens[ $this->i ][ 'content' ],
158 158
 						)
159 159
 					);
160 160
 				}
161 161
 				continue;
162 162
 			}
163 163
 
164
-			if ( \T_VARIABLE === $this->tokens[ $this->i ]['code'] ) {
165
-				if ( '$wpdb' === $this->tokens[ $this->i ]['content'] ) {
164
+			if ( \T_VARIABLE === $this->tokens[ $this->i ][ 'code' ] ) {
165
+				if ( '$wpdb' === $this->tokens[ $this->i ][ 'content' ] ) {
166 166
 					$this->is_wpdb_method_call( $this->i, $this->methods );
167 167
 					continue;
168 168
 				}
@@ -172,25 +172,25 @@  discard block
 block discarded – undo
172 172
 				}
173 173
 			}
174 174
 
175
-			if ( \T_STRING === $this->tokens[ $this->i ]['code'] ) {
175
+			if ( \T_STRING === $this->tokens[ $this->i ][ 'code' ] ) {
176 176
 
177 177
 				if (
178
-					isset( $this->SQLEscapingFunctions[ $this->tokens[ $this->i ]['content'] ] )
179
-					|| isset( $this->SQLAutoEscapedFunctions[ $this->tokens[ $this->i ]['content'] ] )
178
+					isset( $this->SQLEscapingFunctions[ $this->tokens[ $this->i ][ 'content' ] ] )
179
+					|| isset( $this->SQLAutoEscapedFunctions[ $this->tokens[ $this->i ][ 'content' ] ] )
180 180
 				) {
181 181
 
182 182
 					// Find the opening parenthesis.
183 183
 					$opening_paren = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $this->i + 1 ), null, true, null, true );
184 184
 
185 185
 					if ( false !== $opening_paren
186
-						&& \T_OPEN_PARENTHESIS === $this->tokens[ $opening_paren ]['code']
187
-						&& isset( $this->tokens[ $opening_paren ]['parenthesis_closer'] )
186
+						&& \T_OPEN_PARENTHESIS === $this->tokens[ $opening_paren ][ 'code' ]
187
+						&& isset( $this->tokens[ $opening_paren ][ 'parenthesis_closer' ] )
188 188
 					) {
189 189
 						// Skip past the end of the function.
190
-						$this->i = $this->tokens[ $opening_paren ]['parenthesis_closer'];
190
+						$this->i = $this->tokens[ $opening_paren ][ 'parenthesis_closer' ];
191 191
 						continue;
192 192
 					}
193
-				} elseif ( isset( $this->formattingFunctions[ $this->tokens[ $this->i ]['content'] ] ) ) {
193
+				} elseif ( isset( $this->formattingFunctions[ $this->tokens[ $this->i ][ 'content' ] ] ) ) {
194 194
 					continue;
195 195
 				}
196 196
 			}
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 				'Use placeholders and $wpdb->prepare(); found %s',
200 200
 				$this->i,
201 201
 				'NotPrepared',
202
-				array( $this->tokens[ $this->i ]['content'] )
202
+				array( $this->tokens[ $this->i ][ 'content' ] )
203 203
 			);
204 204
 		}
205 205
 
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -98,7 +98,7 @@
 block discarded – undo
98 98
 	 *
99 99
 	 * @since 0.8.0
100 100
 	 *
101
-	 * @return array
101
+	 * @return integer[]
102 102
 	 */
103 103
 	public function register() {
104 104
 
Please login to merge, or discard this patch.
wpcs/WordPress/Sniffs/CodeAnalysis/AssignmentInConditionSniff.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -93,18 +93,18 @@  discard block
 block discarded – undo
93 93
 		$token = $this->tokens[ $stackPtr ];
94 94
 
95 95
 		// Find the condition opener/closer.
96
-		if ( \T_FOR === $token['code'] ) {
97
-			if ( isset( $token['parenthesis_opener'], $token['parenthesis_closer'] ) === false ) {
96
+		if ( \T_FOR === $token[ 'code' ] ) {
97
+			if ( isset( $token[ 'parenthesis_opener' ], $token[ 'parenthesis_closer' ] ) === false ) {
98 98
 				return;
99 99
 			}
100 100
 
101
-			$semicolon = $this->phpcsFile->findNext( \T_SEMICOLON, ( $token['parenthesis_opener'] + 1 ), $token['parenthesis_closer'] );
101
+			$semicolon = $this->phpcsFile->findNext( \T_SEMICOLON, ( $token[ 'parenthesis_opener' ] + 1 ), $token[ 'parenthesis_closer' ] );
102 102
 			if ( false === $semicolon ) {
103 103
 				return;
104 104
 			}
105 105
 
106 106
 			$opener    = $semicolon;
107
-			$semicolon = $this->phpcsFile->findNext( \T_SEMICOLON, ( $opener + 1 ), $token['parenthesis_closer'] );
107
+			$semicolon = $this->phpcsFile->findNext( \T_SEMICOLON, ( $opener + 1 ), $token[ 'parenthesis_closer' ] );
108 108
 			if ( false === $semicolon ) {
109 109
 				return;
110 110
 			}
@@ -112,15 +112,15 @@  discard block
 block discarded – undo
112 112
 			$closer = $semicolon;
113 113
 			unset( $semicolon );
114 114
 
115
-		} elseif ( \T_CASE === $token['code'] ) {
116
-			if ( isset( $token['scope_opener'] ) === false ) {
115
+		} elseif ( \T_CASE === $token[ 'code' ] ) {
116
+			if ( isset( $token[ 'scope_opener' ] ) === false ) {
117 117
 				return;
118 118
 			}
119 119
 
120 120
 			$opener = $stackPtr;
121
-			$closer = $token['scope_opener'];
121
+			$closer = $token[ 'scope_opener' ];
122 122
 
123
-		} elseif ( \T_INLINE_THEN === $token['code'] ) {
123
+		} elseif ( \T_INLINE_THEN === $token[ 'code' ] ) {
124 124
 			// Check if the condition for the ternary is bracketed.
125 125
 			$prev = $this->phpcsFile->findPrevious( Tokens::$emptyTokens, ( $stackPtr - 1 ), null, true );
126 126
 			if ( false === $prev ) {
@@ -128,16 +128,16 @@  discard block
 block discarded – undo
128 128
 				return;
129 129
 			}
130 130
 
131
-			if ( \T_CLOSE_PARENTHESIS === $this->tokens[ $prev ]['code'] ) {
132
-				if ( ! isset( $this->tokens[ $prev ]['parenthesis_opener'] ) ) {
131
+			if ( \T_CLOSE_PARENTHESIS === $this->tokens[ $prev ][ 'code' ] ) {
132
+				if ( ! isset( $this->tokens[ $prev ][ 'parenthesis_opener' ] ) ) {
133 133
 					return;
134 134
 				}
135 135
 
136
-				$opener = $this->tokens[ $prev ]['parenthesis_opener'];
136
+				$opener = $this->tokens[ $prev ][ 'parenthesis_opener' ];
137 137
 				$closer = $prev;
138
-			} elseif ( isset( $token['nested_parenthesis'] ) ) {
139
-				$closer = end( $token['nested_parenthesis'] );
140
-				$opener = key( $token['nested_parenthesis'] );
138
+			} elseif ( isset( $token[ 'nested_parenthesis' ] ) ) {
139
+				$closer = end( $token[ 'nested_parenthesis' ] );
140
+				$opener = key( $token[ 'nested_parenthesis' ] );
141 141
 
142 142
 				$next_statement_closer = $this->phpcsFile->findEndOfStatement( $stackPtr, array( \T_COLON, \T_CLOSE_PARENTHESIS, \T_CLOSE_SQUARE_BRACKET ) );
143 143
 				if ( false !== $next_statement_closer && $next_statement_closer < $closer ) {
@@ -159,12 +159,12 @@  discard block
 block discarded – undo
159 159
 				return;
160 160
 			}
161 161
 		} else {
162
-			if ( isset( $token['parenthesis_opener'], $token['parenthesis_closer'] ) === false ) {
162
+			if ( isset( $token[ 'parenthesis_opener' ], $token[ 'parenthesis_closer' ] ) === false ) {
163 163
 				return;
164 164
 			}
165 165
 
166
-			$opener = $token['parenthesis_opener'];
167
-			$closer = $token['parenthesis_closer'];
166
+			$opener = $token[ 'parenthesis_opener' ];
167
+			$closer = $token[ 'parenthesis_closer' ];
168 168
 		}
169 169
 
170 170
 		$startPos = $opener;
@@ -188,29 +188,29 @@  discard block
 block discarded – undo
188 188
 			}
189 189
 
190 190
 			for ( $i = $hasAssignment; $i > $conditionStart; $i-- ) {
191
-				if ( isset( Tokens::$emptyTokens[ $this->tokens[ $i ]['code'] ] ) ) {
191
+				if ( isset( Tokens::$emptyTokens[ $this->tokens[ $i ][ 'code' ] ] ) ) {
192 192
 					continue;
193 193
 				}
194 194
 
195 195
 				// If this is a variable or array, we've seen all we need to see.
196
-				if ( \T_VARIABLE === $this->tokens[ $i ]['code']
197
-					|| \T_CLOSE_SQUARE_BRACKET === $this->tokens[ $i ]['code']
196
+				if ( \T_VARIABLE === $this->tokens[ $i ][ 'code' ]
197
+					|| \T_CLOSE_SQUARE_BRACKET === $this->tokens[ $i ][ 'code' ]
198 198
 				) {
199 199
 					$hasVariable = true;
200 200
 					break;
201 201
 				}
202 202
 
203 203
 				// If this is a function call or something, we are OK.
204
-				if ( \T_CLOSE_PARENTHESIS === $this->tokens[ $i ]['code'] ) {
204
+				if ( \T_CLOSE_PARENTHESIS === $this->tokens[ $i ][ 'code' ] ) {
205 205
 					break;
206 206
 				}
207 207
 			}
208 208
 
209 209
 			if ( true === $hasVariable ) {
210 210
 				$errorCode = 'Found';
211
-				if ( \T_WHILE === $token['code'] ) {
211
+				if ( \T_WHILE === $token[ 'code' ] ) {
212 212
 					$errorCode = 'FoundInWhileCondition';
213
-				} elseif ( \T_INLINE_THEN === $token['code'] ) {
213
+				} elseif ( \T_INLINE_THEN === $token[ 'code' ] ) {
214 214
 					$errorCode = 'FoundInTernaryCondition';
215 215
 				}
216 216
 
Please login to merge, or discard this patch.
wpcs/WordPress/Sniffs/CodeAnalysis/EmptyStatementSniff.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	 */
53 53
 	public function process_token( $stackPtr ) {
54 54
 
55
-		switch ( $this->tokens[ $stackPtr ]['type'] ) {
55
+		switch ( $this->tokens[ $stackPtr ][ 'type' ] ) {
56 56
 			/*
57 57
 			 * Detect `something();;`.
58 58
 			 */
@@ -65,18 +65,18 @@  discard block
 block discarded – undo
65 65
 				);
66 66
 
67 67
 				if ( false === $prevNonEmpty
68
-					|| ( \T_SEMICOLON !== $this->tokens[ $prevNonEmpty ]['code']
69
-						&& \T_OPEN_TAG !== $this->tokens[ $prevNonEmpty ]['code']
70
-						&& \T_OPEN_TAG_WITH_ECHO !== $this->tokens[ $prevNonEmpty ]['code'] )
68
+					|| ( \T_SEMICOLON !== $this->tokens[ $prevNonEmpty ][ 'code' ]
69
+						&& \T_OPEN_TAG !== $this->tokens[ $prevNonEmpty ][ 'code' ]
70
+						&& \T_OPEN_TAG_WITH_ECHO !== $this->tokens[ $prevNonEmpty ][ 'code' ] )
71 71
 				) {
72 72
 					return;
73 73
 				}
74 74
 
75
-				if ( isset( $this->tokens[ $stackPtr ]['nested_parenthesis'] ) ) {
76
-					$nested      = $this->tokens[ $stackPtr ]['nested_parenthesis'];
75
+				if ( isset( $this->tokens[ $stackPtr ][ 'nested_parenthesis' ] ) ) {
76
+					$nested      = $this->tokens[ $stackPtr ][ 'nested_parenthesis' ];
77 77
 					$last_closer = array_pop( $nested );
78
-					if ( isset( $this->tokens[ $last_closer ]['parenthesis_owner'] )
79
-						&& \T_FOR === $this->tokens[ $this->tokens[ $last_closer ]['parenthesis_owner'] ]['code']
78
+					if ( isset( $this->tokens[ $last_closer ][ 'parenthesis_owner' ] )
79
+						&& \T_FOR === $this->tokens[ $this->tokens[ $last_closer ][ 'parenthesis_owner' ] ][ 'code' ]
80 80
 					) {
81 81
 						// Empty for() condition.
82 82
 						return;
@@ -91,8 +91,8 @@  discard block
 block discarded – undo
91 91
 				if ( true === $fix ) {
92 92
 					$this->phpcsFile->fixer->beginChangeset();
93 93
 
94
-					if ( \T_OPEN_TAG === $this->tokens[ $prevNonEmpty ]['code']
95
-						|| \T_OPEN_TAG_WITH_ECHO === $this->tokens[ $prevNonEmpty ]['code']
94
+					if ( \T_OPEN_TAG === $this->tokens[ $prevNonEmpty ][ 'code' ]
95
+						|| \T_OPEN_TAG_WITH_ECHO === $this->tokens[ $prevNonEmpty ][ 'code' ]
96 96
 					) {
97 97
 						/*
98 98
 						 * Check for superfluous whitespace after the semi-colon which will be
@@ -100,15 +100,15 @@  discard block
 block discarded – undo
100 100
 						 * either a space or a new line and in case of a new line, the indentation
101 101
 						 * should be done via tabs, so spaces can be safely removed.
102 102
 						 */
103
-						if ( \T_WHITESPACE === $this->tokens[ ( $stackPtr + 1 ) ]['code'] ) {
104
-							$replacement = str_replace( ' ', '', $this->tokens[ ( $stackPtr + 1 ) ]['content'] );
103
+						if ( \T_WHITESPACE === $this->tokens[ ( $stackPtr + 1 ) ][ 'code' ] ) {
104
+							$replacement = str_replace( ' ', '', $this->tokens[ ( $stackPtr + 1 ) ][ 'content' ] );
105 105
 							$this->phpcsFile->fixer->replaceToken( ( $stackPtr + 1 ), $replacement );
106 106
 						}
107 107
 					}
108 108
 
109 109
 					for ( $i = $stackPtr; $i > $prevNonEmpty; $i-- ) {
110
-						if ( \T_SEMICOLON !== $this->tokens[ $i ]['code']
111
-							&& \T_WHITESPACE !== $this->tokens[ $i ]['code']
110
+						if ( \T_SEMICOLON !== $this->tokens[ $i ][ 'code' ]
111
+							&& \T_WHITESPACE !== $this->tokens[ $i ][ 'code' ]
112 112
 						) {
113 113
 							break;
114 114
 						}
@@ -131,8 +131,8 @@  discard block
 block discarded – undo
131 131
 				);
132 132
 
133 133
 				if ( false === $prevNonEmpty
134
-					|| ( \T_OPEN_TAG !== $this->tokens[ $prevNonEmpty ]['code']
135
-						&& \T_OPEN_TAG_WITH_ECHO !== $this->tokens[ $prevNonEmpty ]['code'] )
134
+					|| ( \T_OPEN_TAG !== $this->tokens[ $prevNonEmpty ][ 'code' ]
135
+						&& \T_OPEN_TAG_WITH_ECHO !== $this->tokens[ $prevNonEmpty ][ 'code' ] )
136 136
 				) {
137 137
 					return;
138 138
 				}
Please login to merge, or discard this patch.
wpcs/WordPress/Sniffs/Utils/I18nTextDomainFixerSniff.php 1 patch
Spacing   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -239,14 +239,14 @@  discard block
 block discarded – undo
239 239
 	 * @return array
240 240
 	 */
241 241
 	public function register() {
242
-		$headers                  = array_map(
242
+		$headers = array_map(
243 243
 			'preg_quote',
244 244
 			array_keys( $this->theme_headers ),
245 245
 			array_fill( 0, \count( $this->theme_headers ), '`' )
246 246
 		);
247 247
 		$this->theme_header_regex = sprintf( $this->header_regex_template, implode( '|', $headers ) );
248 248
 
249
-		$headers                   = array_map(
249
+		$headers = array_map(
250 250
 			'preg_quote',
251 251
 			array_keys( $this->plugin_headers ),
252 252
 			array_fill( 0, \count( $this->plugin_headers ), '`' )
@@ -255,8 +255,8 @@  discard block
 block discarded – undo
255 255
 
256 256
 		$targets = parent::register();
257 257
 
258
-		$targets[] = \T_DOC_COMMENT_OPEN_TAG;
259
-		$targets[] = \T_COMMENT;
258
+		$targets[ ] = \T_DOC_COMMENT_OPEN_TAG;
259
+		$targets[ ] = \T_COMMENT;
260 260
 
261 261
 		return $targets;
262 262
 	}
@@ -335,8 +335,8 @@  discard block
 block discarded – undo
335 335
 			}
336 336
 		}
337 337
 
338
-		if ( \T_DOC_COMMENT_OPEN_TAG === $this->tokens[ $stackPtr ]['code']
339
-			|| \T_COMMENT === $this->tokens[ $stackPtr ]['code']
338
+		if ( \T_DOC_COMMENT_OPEN_TAG === $this->tokens[ $stackPtr ][ 'code' ]
339
+			|| \T_COMMENT === $this->tokens[ $stackPtr ][ 'code' ]
340 340
 		) {
341 341
 			// Examine for plugin/theme file header.
342 342
 			return $this->process_comments( $stackPtr );
@@ -371,22 +371,22 @@  discard block
 block discarded – undo
371 371
 				$fix = $this->phpcsFile->addFixableError( $error_msg, $stackPtr, $error_code );
372 372
 
373 373
 				if ( true === $fix ) {
374
-					$start_previous = $parameters[ ( $target_param - 1 ) ]['start'];
375
-					$end_previous   = $parameters[ ( $target_param - 1 ) ]['end'];
376
-					if ( \T_WHITESPACE === $this->tokens[ $start_previous ]['code']
377
-						&& $this->tokens[ $start_previous ]['content'] === $this->phpcsFile->eolChar
374
+					$start_previous = $parameters[ ( $target_param - 1 ) ][ 'start' ];
375
+					$end_previous   = $parameters[ ( $target_param - 1 ) ][ 'end' ];
376
+					if ( \T_WHITESPACE === $this->tokens[ $start_previous ][ 'code' ]
377
+						&& $this->tokens[ $start_previous ][ 'content' ] === $this->phpcsFile->eolChar
378 378
 					) {
379 379
 						// Replicate the new line + indentation of the previous item.
380 380
 						$replacement = ',';
381 381
 						for ( $i = $start_previous; $i <= $end_previous; $i++ ) {
382
-							if ( \T_WHITESPACE !== $this->tokens[ $i ]['code'] ) {
382
+							if ( \T_WHITESPACE !== $this->tokens[ $i ][ 'code' ] ) {
383 383
 								break;
384 384
 							}
385 385
 
386
-							if ( isset( $this->tokens[ $i ]['orig_content'] ) ) {
387
-								$replacement .= $this->tokens[ $i ]['orig_content'];
386
+							if ( isset( $this->tokens[ $i ][ 'orig_content' ] ) ) {
387
+								$replacement .= $this->tokens[ $i ][ 'orig_content' ];
388 388
 							} else {
389
-								$replacement .= $this->tokens[ $i ]['content'];
389
+								$replacement .= $this->tokens[ $i ][ 'content' ];
390 390
 							}
391 391
 						}
392 392
 
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
 						$replacement = ", '{$this->new_text_domain}'";
396 396
 					}
397 397
 
398
-					if ( \T_WHITESPACE === $this->tokens[ $end_previous ]['code'] ) {
398
+					if ( \T_WHITESPACE === $this->tokens[ $end_previous ][ 'code' ] ) {
399 399
 						$this->phpcsFile->fixer->addContentBefore( $end_previous, $replacement );
400 400
 					} else {
401 401
 						$this->phpcsFile->fixer->addContent( $end_previous, $replacement );
@@ -413,16 +413,16 @@  discard block
 block discarded – undo
413 413
 		}
414 414
 
415 415
 		// Target parameter found. Let's examine it.
416
-		$domain_param_start = $parameters[ $target_param ]['start'];
417
-		$domain_param_end   = $parameters[ $target_param ]['end'];
416
+		$domain_param_start = $parameters[ $target_param ][ 'start' ];
417
+		$domain_param_end   = $parameters[ $target_param ][ 'end' ];
418 418
 		$domain_token       = null;
419 419
 
420 420
 		for ( $i = $domain_param_start; $i <= $domain_param_end; $i++ ) {
421
-			if ( isset( Tokens::$emptyTokens[ $this->tokens[ $i ]['code'] ] ) ) {
421
+			if ( isset( Tokens::$emptyTokens[ $this->tokens[ $i ][ 'code' ] ] ) ) {
422 422
 				continue;
423 423
 			}
424 424
 
425
-			if ( \T_CONSTANT_ENCAPSED_STRING !== $this->tokens[ $i ]['code'] ) {
425
+			if ( \T_CONSTANT_ENCAPSED_STRING !== $this->tokens[ $i ][ 'code' ] ) {
426 426
 				// Unexpected token found, not our concern. This is handled by the I18n sniff.
427 427
 				return;
428 428
 			}
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 		}
437 437
 
438 438
 		// If we're still here, this means only one T_CONSTANT_ENCAPSED_STRING was found.
439
-		$old_domain = $this->strip_quotes( $this->tokens[ $domain_token ]['content'] );
439
+		$old_domain = $this->strip_quotes( $this->tokens[ $domain_token ][ 'content' ] );
440 440
 
441 441
 		if ( ! \in_array( $old_domain, $this->old_text_domain, true ) ) {
442 442
 			// Not a text domain targetted for replacement, ignore.
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
 		);
452 452
 
453 453
 		if ( true === $fix ) {
454
-			$replacement = str_replace( $old_domain, $this->new_text_domain, $this->tokens[ $domain_token ]['content'] );
454
+			$replacement = str_replace( $old_domain, $this->new_text_domain, $this->tokens[ $domain_token ][ 'content' ] );
455 455
 			$this->phpcsFile->fixer->replaceToken( $domain_token, $replacement );
456 456
 		}
457 457
 	}
@@ -478,8 +478,8 @@  discard block
 block discarded – undo
478 478
 		}
479 479
 
480 480
 		$opener = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true );
481
-		if ( \T_OPEN_PARENTHESIS !== $this->tokens[ $opener ]['code']
482
-			|| isset( $this->tokens[ $opener ]['parenthesis_closer'] ) === false
481
+		if ( \T_OPEN_PARENTHESIS !== $this->tokens[ $opener ][ 'code' ]
482
+			|| isset( $this->tokens[ $opener ][ 'parenthesis_closer' ] ) === false
483 483
 		) {
484 484
 			// Parse error or live coding.
485 485
 			return;
@@ -487,21 +487,21 @@  discard block
 block discarded – undo
487 487
 
488 488
 		$fix = $this->phpcsFile->addFixableError( 'Missing $domain arg', $stackPtr, 'MissingArgDomain' );
489 489
 		if ( true === $fix ) {
490
-			$closer      = $this->tokens[ $opener ]['parenthesis_closer'];
490
+			$closer      = $this->tokens[ $opener ][ 'parenthesis_closer' ];
491 491
 			$replacement = " '{$this->new_text_domain}' ";
492 492
 
493
-			if ( $this->tokens[ $opener ]['line'] !== $this->tokens[ $closer ]['line'] ) {
493
+			if ( $this->tokens[ $opener ][ 'line' ] !== $this->tokens[ $closer ][ 'line' ] ) {
494 494
 				$replacement = trim( $replacement );
495 495
 				$addBefore   = ( $closer - 1 );
496
-				if ( \T_WHITESPACE === $this->tokens[ ( $closer - 1 ) ]['code']
497
-					&& $this->tokens[ $closer - 1 ]['line'] === $this->tokens[ $closer ]['line']
496
+				if ( \T_WHITESPACE === $this->tokens[ ( $closer - 1 ) ][ 'code' ]
497
+					&& $this->tokens[ $closer - 1 ][ 'line' ] === $this->tokens[ $closer ][ 'line' ]
498 498
 				) {
499
-					if ( isset( $this->tokens[ ( $closer - 1 ) ]['orig_content'] ) ) {
500
-						$replacement = $this->tokens[ ( $closer - 1 ) ]['orig_content']
499
+					if ( isset( $this->tokens[ ( $closer - 1 ) ][ 'orig_content' ] ) ) {
500
+						$replacement = $this->tokens[ ( $closer - 1 ) ][ 'orig_content' ]
501 501
 							. "\t"
502 502
 							. $replacement;
503 503
 					} else {
504
-						$replacement = $this->tokens[ ( $closer - 1 ) ]['content']
504
+						$replacement = $this->tokens[ ( $closer - 1 ) ][ 'content' ]
505 505
 							. str_repeat( ' ', $this->tab_width )
506 506
 							. $replacement;
507 507
 					}
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
 
517 517
 				$this->phpcsFile->fixer->addContentBefore( $addBefore, $replacement );
518 518
 
519
-			} elseif ( \T_WHITESPACE === $this->tokens[ ( $closer - 1 ) ]['code'] ) {
519
+			} elseif ( \T_WHITESPACE === $this->tokens[ ( $closer - 1 ) ][ 'code' ] ) {
520 520
 				$this->phpcsFile->fixer->replaceToken( ( $closer - 1 ), $replacement );
521 521
 			} else {
522 522
 				$this->phpcsFile->fixer->addContentBefore( $closer, $replacement );
@@ -570,45 +570,45 @@  discard block
 block discarded – undo
570 570
 			'last_header_matches'   => array(),
571 571
 		);
572 572
 
573
-		if ( \T_COMMENT === $this->tokens[ $stackPtr ]['code'] ) {
573
+		if ( \T_COMMENT === $this->tokens[ $stackPtr ][ 'code' ] ) {
574 574
 			$block_comment = false;
575
-			if ( substr( $this->tokens[ $stackPtr ]['content'], 0, 2 ) === '/*' ) {
575
+			if ( substr( $this->tokens[ $stackPtr ][ 'content' ], 0, 2 ) === '/*' ) {
576 576
 				$block_comment = true;
577 577
 			}
578 578
 
579 579
 			$current = $stackPtr;
580 580
 			do {
581
-				if ( false === $comment_details['text_domain_ptr']
582
-					|| false === $comment_details['required_header_found']
583
-					|| $comment_details['headers_found'] < 3
581
+				if ( false === $comment_details[ 'text_domain_ptr' ]
582
+					|| false === $comment_details[ 'required_header_found' ]
583
+					|| $comment_details[ 'headers_found' ] < 3
584 584
 				) {
585 585
 					$comment_details = $this->examine_comment_line( $current, $regex, $headers, $comment_details );
586 586
 				}
587 587
 
588
-				if ( true === $block_comment && substr( $this->tokens[ $current ]['content'], -2 ) === '*/' ) {
588
+				if ( true === $block_comment && substr( $this->tokens[ $current ][ 'content' ], -2 ) === '*/' ) {
589 589
 					++$current;
590 590
 					break;
591 591
 				}
592 592
 
593 593
 				++$current;
594
-			} while ( isset( $this->tokens[ $current ] ) && \T_COMMENT === $this->tokens[ $current ]['code'] );
594
+			} while ( isset( $this->tokens[ $current ] ) && \T_COMMENT === $this->tokens[ $current ][ 'code' ] );
595 595
 
596 596
 			$skip_to = $current;
597 597
 
598 598
 		} else {
599
-			if ( ! isset( $this->tokens[ $stackPtr ]['comment_closer'] ) ) {
599
+			if ( ! isset( $this->tokens[ $stackPtr ][ 'comment_closer' ] ) ) {
600 600
 				return;
601 601
 			}
602 602
 
603
-			$closer  = $this->tokens[ $stackPtr ]['comment_closer'];
603
+			$closer  = $this->tokens[ $stackPtr ][ 'comment_closer' ];
604 604
 			$current = $stackPtr;
605 605
 
606 606
 			while ( ( $current = $this->phpcsFile->findNext( \T_DOC_COMMENT_STRING, ( $current + 1 ), $closer ) ) !== false ) {
607 607
 				$comment_details = $this->examine_comment_line( $current, $regex, $headers, $comment_details );
608 608
 
609
-				if ( false !== $comment_details['text_domain_ptr']
610
-					&& true === $comment_details['required_header_found']
611
-					&& $comment_details['headers_found'] >= 3
609
+				if ( false !== $comment_details[ 'text_domain_ptr' ]
610
+					&& true === $comment_details[ 'required_header_found' ]
611
+					&& $comment_details[ 'headers_found' ] >= 3
612 612
 				) {
613 613
 					// No need to look at the rest of the docblock.
614 614
 					break;
@@ -619,13 +619,13 @@  discard block
 block discarded – undo
619 619
 		}
620 620
 
621 621
 		// So, was this the plugin/theme header ?
622
-		if ( true === $comment_details['required_header_found']
623
-			&& $comment_details['headers_found'] >= 3
622
+		if ( true === $comment_details[ 'required_header_found' ]
623
+			&& $comment_details[ 'headers_found' ] >= 3
624 624
 		) {
625 625
 			$this->header_found = true;
626 626
 
627
-			$text_domain_ptr   = $comment_details['text_domain_ptr'];
628
-			$text_domain_found = $comment_details['text_domain_found'];
627
+			$text_domain_ptr   = $comment_details[ 'text_domain_ptr' ];
628
+			$text_domain_found = $comment_details[ 'text_domain_found' ];
629 629
 
630 630
 			if ( false !== $text_domain_ptr ) {
631 631
 				if ( $this->new_text_domain !== $text_domain_found
@@ -643,10 +643,10 @@  discard block
 block discarded – undo
643 643
 					);
644 644
 
645 645
 					if ( true === $fix ) {
646
-						if ( isset( $this->tokens[ $text_domain_ptr ]['orig_content'] ) ) {
647
-							$replacement = $this->tokens[ $text_domain_ptr ]['orig_content'];
646
+						if ( isset( $this->tokens[ $text_domain_ptr ][ 'orig_content' ] ) ) {
647
+							$replacement = $this->tokens[ $text_domain_ptr ][ 'orig_content' ];
648 648
 						} else {
649
-							$replacement = $this->tokens[ $text_domain_ptr ]['content'];
649
+							$replacement = $this->tokens[ $text_domain_ptr ][ 'content' ];
650 650
 						}
651 651
 
652 652
 						$replacement = str_replace( $text_domain_found, $this->new_text_domain, $replacement );
@@ -655,8 +655,8 @@  discard block
 block discarded – undo
655 655
 					}
656 656
 				}
657 657
 			} else {
658
-				$last_header_ptr     = $comment_details['last_header_ptr'];
659
-				$last_header_matches = $comment_details['last_header_matches'];
658
+				$last_header_ptr     = $comment_details[ 'last_header_ptr' ];
659
+				$last_header_matches = $comment_details[ 'last_header_matches' ];
660 660
 
661 661
 				$fix = $this->phpcsFile->addFixableError(
662 662
 					'Missing "Text Domain" in %s header',
@@ -666,18 +666,18 @@  discard block
 block discarded – undo
666 666
 				);
667 667
 
668 668
 				if ( true === $fix ) {
669
-					if ( isset( $this->tokens[ $last_header_ptr ]['orig_content'] ) ) {
670
-						$replacement = $this->tokens[ $last_header_ptr ]['orig_content'];
669
+					if ( isset( $this->tokens[ $last_header_ptr ][ 'orig_content' ] ) ) {
670
+						$replacement = $this->tokens[ $last_header_ptr ][ 'orig_content' ];
671 671
 					} else {
672
-						$replacement = $this->tokens[ $last_header_ptr ]['content'];
672
+						$replacement = $this->tokens[ $last_header_ptr ][ 'content' ];
673 673
 					}
674 674
 
675
-					$replacement = str_replace( $last_header_matches[1], 'Text Domain', $replacement );
676
-					$replacement = str_replace( $last_header_matches[2], $this->new_text_domain, $replacement );
675
+					$replacement = str_replace( $last_header_matches[ 1 ], 'Text Domain', $replacement );
676
+					$replacement = str_replace( $last_header_matches[ 2 ], $this->new_text_domain, $replacement );
677 677
 
678
-					if ( \T_DOC_COMMENT_OPEN_TAG === $this->tokens[ $stackPtr ]['code'] ) {
678
+					if ( \T_DOC_COMMENT_OPEN_TAG === $this->tokens[ $stackPtr ][ 'code' ] ) {
679 679
 						for ( $i = ( $last_header_ptr - 1 ); ; $i-- ) {
680
-							if ( $this->tokens[ $i ]['line'] !== $this->tokens[ $last_header_ptr ]['line'] ) {
680
+							if ( $this->tokens[ $i ][ 'line' ] !== $this->tokens[ $last_header_ptr ][ 'line' ] ) {
681 681
 								++$i;
682 682
 								break;
683 683
 							}
@@ -688,7 +688,7 @@  discard block
 block discarded – undo
688 688
 							. $replacement;
689 689
 					}
690 690
 
691
-					$this->phpcsFile->fixer->addContent( $comment_details['last_header_ptr'], $replacement );
691
+					$this->phpcsFile->fixer->addContent( $comment_details[ 'last_header_ptr' ], $replacement );
692 692
 				}
693 693
 			}
694 694
 		}
@@ -709,20 +709,20 @@  discard block
 block discarded – undo
709 709
 	 * @return array Adjusted $comment_details array
710 710
 	 */
711 711
 	protected function examine_comment_line( $stackPtr, $regex, $headers, $comment_details ) {
712
-		if ( preg_match( $regex, $this->tokens[ $stackPtr ]['content'], $matches ) === 1 ) {
713
-			++$comment_details['headers_found'];
712
+		if ( preg_match( $regex, $this->tokens[ $stackPtr ][ 'content' ], $matches ) === 1 ) {
713
+			++$comment_details[ 'headers_found' ];
714 714
 
715
-			if ( true === $headers[ $matches[1] ] ) {
716
-				$comment_details['required_header_found'] = true;
715
+			if ( true === $headers[ $matches[ 1 ] ] ) {
716
+				$comment_details[ 'required_header_found' ] = true;
717 717
 			}
718 718
 
719
-			if ( 'Text Domain' === $matches[1] ) {
720
-				$comment_details['text_domain_ptr']   = $stackPtr;
721
-				$comment_details['text_domain_found'] = trim( $matches[2] );
719
+			if ( 'Text Domain' === $matches[ 1 ] ) {
720
+				$comment_details[ 'text_domain_ptr' ]   = $stackPtr;
721
+				$comment_details[ 'text_domain_found' ] = trim( $matches[ 2 ] );
722 722
 			}
723 723
 
724
-			$comment_details['last_header_ptr']     = $stackPtr;
725
-			$comment_details['last_header_matches'] = $matches;
724
+			$comment_details[ 'last_header_ptr' ]     = $stackPtr;
725
+			$comment_details[ 'last_header_matches' ] = $matches;
726 726
 		}
727 727
 
728 728
 		return $comment_details;
Please login to merge, or discard this patch.
wpcs/WordPress/Sniffs/Security/EscapeOutputSniff.php 2 patches
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -190,26 +190,26 @@  discard block
 block discarded – undo
190 190
 
191 191
 		$this->mergeFunctionLists();
192 192
 
193
-		$function = $this->tokens[ $stackPtr ]['content'];
193
+		$function = $this->tokens[ $stackPtr ][ 'content' ];
194 194
 
195 195
 		// Find the opening parenthesis (if present; T_ECHO might not have it).
196 196
 		$open_paren = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true );
197 197
 
198 198
 		// If function, not T_ECHO nor T_PRINT.
199
-		if ( \T_STRING === $this->tokens[ $stackPtr ]['code'] ) {
199
+		if ( \T_STRING === $this->tokens[ $stackPtr ][ 'code' ] ) {
200 200
 			// Skip if it is a function but is not one of the printing functions.
201
-			if ( ! isset( $this->printingFunctions[ $this->tokens[ $stackPtr ]['content'] ] ) ) {
201
+			if ( ! isset( $this->printingFunctions[ $this->tokens[ $stackPtr ][ 'content' ] ] ) ) {
202 202
 				return;
203 203
 			}
204 204
 
205
-			if ( isset( $this->tokens[ $open_paren ]['parenthesis_closer'] ) ) {
206
-				$end_of_statement = $this->tokens[ $open_paren ]['parenthesis_closer'];
205
+			if ( isset( $this->tokens[ $open_paren ][ 'parenthesis_closer' ] ) ) {
206
+				$end_of_statement = $this->tokens[ $open_paren ][ 'parenthesis_closer' ];
207 207
 			}
208 208
 
209 209
 			// These functions only need to have the first argument escaped.
210 210
 			if ( \in_array( $function, array( 'trigger_error', 'user_error' ), true ) ) {
211 211
 				$first_param      = $this->get_function_call_parameter( $stackPtr, 1 );
212
-				$end_of_statement = ( $first_param['end'] + 1 );
212
+				$end_of_statement = ( $first_param[ 'end' ] + 1 );
213 213
 				unset( $first_param );
214 214
 			}
215 215
 		}
@@ -243,13 +243,13 @@  discard block
 block discarded – undo
243 243
 
244 244
 			// Check for the ternary operator. We only need to do this here if this
245 245
 			// echo is lacking parenthesis. Otherwise it will be handled below.
246
-			if ( \T_OPEN_PARENTHESIS !== $this->tokens[ $open_paren ]['code'] || \T_CLOSE_PARENTHESIS !== $this->tokens[ $last_token ]['code'] ) {
246
+			if ( \T_OPEN_PARENTHESIS !== $this->tokens[ $open_paren ][ 'code' ] || \T_CLOSE_PARENTHESIS !== $this->tokens[ $last_token ][ 'code' ] ) {
247 247
 
248 248
 				$ternary = $this->phpcsFile->findNext( \T_INLINE_THEN, $stackPtr, $end_of_statement );
249 249
 
250 250
 				// If there is a ternary skip over the part before the ?. However, if
251 251
 				// the ternary is within parentheses, it will be handled in the loop.
252
-				if ( false !== $ternary && empty( $this->tokens[ $ternary ]['nested_parenthesis'] ) ) {
252
+				if ( false !== $ternary && empty( $this->tokens[ $ternary ][ 'nested_parenthesis' ] ) ) {
253 253
 					$stackPtr = $ternary;
254 254
 				}
255 255
 			}
@@ -265,18 +265,18 @@  discard block
 block discarded – undo
265 265
 		for ( $i = $stackPtr; $i < $end_of_statement; $i++ ) {
266 266
 
267 267
 			// Ignore whitespaces and comments.
268
-			if ( isset( Tokens::$emptyTokens[ $this->tokens[ $i ]['code'] ] ) ) {
268
+			if ( isset( Tokens::$emptyTokens[ $this->tokens[ $i ][ 'code' ] ] ) ) {
269 269
 				continue;
270 270
 			}
271 271
 
272 272
 			// Ignore namespace separators.
273
-			if ( \T_NS_SEPARATOR === $this->tokens[ $i ]['code'] ) {
273
+			if ( \T_NS_SEPARATOR === $this->tokens[ $i ][ 'code' ] ) {
274 274
 				continue;
275 275
 			}
276 276
 
277
-			if ( \T_OPEN_PARENTHESIS === $this->tokens[ $i ]['code'] ) {
277
+			if ( \T_OPEN_PARENTHESIS === $this->tokens[ $i ][ 'code' ] ) {
278 278
 
279
-				if ( ! isset( $this->tokens[ $i ]['parenthesis_closer'] ) ) {
279
+				if ( ! isset( $this->tokens[ $i ][ 'parenthesis_closer' ] ) ) {
280 280
 					// Live coding or parse error.
281 281
 					break;
282 282
 				}
@@ -284,20 +284,20 @@  discard block
 block discarded – undo
284 284
 				if ( $in_cast ) {
285 285
 
286 286
 					// Skip to the end of a function call if it has been casted to a safe value.
287
-					$i       = $this->tokens[ $i ]['parenthesis_closer'];
287
+					$i       = $this->tokens[ $i ][ 'parenthesis_closer' ];
288 288
 					$in_cast = false;
289 289
 
290 290
 				} else {
291 291
 
292 292
 					// Skip over the condition part of a ternary (i.e., to after the ?).
293
-					$ternary = $this->phpcsFile->findNext( \T_INLINE_THEN, $i, $this->tokens[ $i ]['parenthesis_closer'] );
293
+					$ternary = $this->phpcsFile->findNext( \T_INLINE_THEN, $i, $this->tokens[ $i ][ 'parenthesis_closer' ] );
294 294
 
295 295
 					if ( false !== $ternary ) {
296 296
 
297
-						$next_paren = $this->phpcsFile->findNext( \T_OPEN_PARENTHESIS, ( $i + 1 ), $this->tokens[ $i ]['parenthesis_closer'] );
297
+						$next_paren = $this->phpcsFile->findNext( \T_OPEN_PARENTHESIS, ( $i + 1 ), $this->tokens[ $i ][ 'parenthesis_closer' ] );
298 298
 
299 299
 						// We only do it if the ternary isn't within a subset of parentheses.
300
-						if ( false === $next_paren || ( isset( $this->tokens[ $next_paren ]['parenthesis_closer'] ) && $ternary > $this->tokens[ $next_paren ]['parenthesis_closer'] ) ) {
300
+						if ( false === $next_paren || ( isset( $this->tokens[ $next_paren ][ 'parenthesis_closer' ] ) && $ternary > $this->tokens[ $next_paren ][ 'parenthesis_closer' ] ) ) {
301 301
 							$i = $ternary;
302 302
 						}
303 303
 					}
@@ -307,48 +307,48 @@  discard block
 block discarded – undo
307 307
 			}
308 308
 
309 309
 			// Handle arrays for those functions that accept them.
310
-			if ( \T_ARRAY === $this->tokens[ $i ]['code'] ) {
310
+			if ( \T_ARRAY === $this->tokens[ $i ][ 'code' ] ) {
311 311
 				$i++; // Skip the opening parenthesis.
312 312
 				continue;
313 313
 			}
314 314
 
315
-			if ( \T_OPEN_SHORT_ARRAY === $this->tokens[ $i ]['code']
316
-				|| \T_CLOSE_SHORT_ARRAY === $this->tokens[ $i ]['code']
315
+			if ( \T_OPEN_SHORT_ARRAY === $this->tokens[ $i ][ 'code' ]
316
+				|| \T_CLOSE_SHORT_ARRAY === $this->tokens[ $i ][ 'code' ]
317 317
 			) {
318 318
 				continue;
319 319
 			}
320 320
 
321
-			if ( \in_array( $this->tokens[ $i ]['code'], array( \T_DOUBLE_ARROW, \T_CLOSE_PARENTHESIS ), true ) ) {
321
+			if ( \in_array( $this->tokens[ $i ][ 'code' ], array( \T_DOUBLE_ARROW, \T_CLOSE_PARENTHESIS ), true ) ) {
322 322
 				continue;
323 323
 			}
324 324
 
325 325
 			// Handle magic constants for debug functions.
326
-			if ( isset( $this->magic_constant_tokens[ $this->tokens[ $i ]['type'] ] ) ) {
326
+			if ( isset( $this->magic_constant_tokens[ $this->tokens[ $i ][ 'type' ] ] ) ) {
327 327
 				continue;
328 328
 			}
329 329
 
330 330
 			// Handle safe PHP native constants.
331
-			if ( \T_STRING === $this->tokens[ $i ]['code']
332
-				&& isset( $this->safe_php_constants[ $this->tokens[ $i ]['content'] ] )
331
+			if ( \T_STRING === $this->tokens[ $i ][ 'code' ]
332
+				&& isset( $this->safe_php_constants[ $this->tokens[ $i ][ 'content' ] ] )
333 333
 				&& $this->is_use_of_global_constant( $i )
334 334
 			) {
335 335
 				continue;
336 336
 			}
337 337
 
338 338
 			// Wake up on concatenation characters, another part to check.
339
-			if ( \T_STRING_CONCAT === $this->tokens[ $i ]['code'] ) {
339
+			if ( \T_STRING_CONCAT === $this->tokens[ $i ][ 'code' ] ) {
340 340
 				$watch = true;
341 341
 				continue;
342 342
 			}
343 343
 
344 344
 			// Wake up after a ternary else (:).
345
-			if ( false !== $ternary && \T_INLINE_ELSE === $this->tokens[ $i ]['code'] ) {
345
+			if ( false !== $ternary && \T_INLINE_ELSE === $this->tokens[ $i ][ 'code' ] ) {
346 346
 				$watch = true;
347 347
 				continue;
348 348
 			}
349 349
 
350 350
 			// Wake up for commas.
351
-			if ( \T_COMMA === $this->tokens[ $i ]['code'] ) {
351
+			if ( \T_COMMA === $this->tokens[ $i ][ 'code' ] ) {
352 352
 				$in_cast = false;
353 353
 				$watch   = true;
354 354
 				continue;
@@ -360,23 +360,23 @@  discard block
 block discarded – undo
360 360
 
361 361
 			// Allow T_CONSTANT_ENCAPSED_STRING eg: echo 'Some String';
362 362
 			// Also T_LNUMBER, e.g.: echo 45; exit -1; and booleans.
363
-			if ( isset( $this->safe_components[ $this->tokens[ $i ]['type'] ] ) ) {
363
+			if ( isset( $this->safe_components[ $this->tokens[ $i ][ 'type' ] ] ) ) {
364 364
 				continue;
365 365
 			}
366 366
 
367 367
 			$watch = false;
368 368
 
369 369
 			// Allow int/double/bool casted variables.
370
-			if ( isset( $this->safe_cast_tokens[ $this->tokens[ $i ]['type'] ] ) ) {
370
+			if ( isset( $this->safe_cast_tokens[ $this->tokens[ $i ][ 'type' ] ] ) ) {
371 371
 				$in_cast = true;
372 372
 				continue;
373 373
 			}
374 374
 
375 375
 			// Now check that next token is a function call.
376
-			if ( \T_STRING === $this->tokens[ $i ]['code'] ) {
376
+			if ( \T_STRING === $this->tokens[ $i ][ 'code' ] ) {
377 377
 
378 378
 				$ptr                    = $i;
379
-				$functionName           = $this->tokens[ $i ]['content'];
379
+				$functionName           = $this->tokens[ $i ][ 'content' ];
380 380
 				$function_opener        = $this->phpcsFile->findNext( \T_OPEN_PARENTHESIS, ( $i + 1 ), null, false, null, true );
381 381
 				$is_formatting_function = isset( $this->formattingFunctions[ $functionName ] );
382 382
 
@@ -397,15 +397,15 @@  discard block
 block discarded – undo
397 397
 							 */
398 398
 							$mapped_function = $this->phpcsFile->findNext(
399 399
 								Tokens::$emptyTokens,
400
-								$callback['start'],
401
-								( $callback['end'] + 1 ),
400
+								$callback[ 'start' ],
401
+								( $callback[ 'end' ] + 1 ),
402 402
 								true
403 403
 							);
404 404
 
405 405
 							if ( false !== $mapped_function
406
-								&& \T_CONSTANT_ENCAPSED_STRING === $this->tokens[ $mapped_function ]['code']
406
+								&& \T_CONSTANT_ENCAPSED_STRING === $this->tokens[ $mapped_function ][ 'code' ]
407 407
 							) {
408
-								$functionName = $this->strip_quotes( $this->tokens[ $mapped_function ]['content'] );
408
+								$functionName = $this->strip_quotes( $this->tokens[ $mapped_function ][ 'content' ] );
409 409
 								$ptr          = $mapped_function;
410 410
 							}
411 411
 						}
@@ -418,8 +418,8 @@  discard block
 block discarded – undo
418 418
 						$i     = ( $function_opener + 1 );
419 419
 						$watch = true;
420 420
 					} else {
421
-						if ( isset( $this->tokens[ $function_opener ]['parenthesis_closer'] ) ) {
422
-							$i = $this->tokens[ $function_opener ]['parenthesis_closer'];
421
+						if ( isset( $this->tokens[ $function_opener ][ 'parenthesis_closer' ] ) ) {
422
+							$i = $this->tokens[ $function_opener ][ 'parenthesis_closer' ];
423 423
 						} else {
424 424
 							// Live coding or parse error.
425 425
 							break;
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
 				$content = $functionName;
440 440
 
441 441
 			} else {
442
-				$content = $this->tokens[ $i ]['content'];
442
+				$content = $this->tokens[ $i ][ 'content' ];
443 443
 				$ptr     = $i;
444 444
 			}
445 445
 
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
 	 * @return void
463 463
 	 */
464 464
 	protected function mergeFunctionLists() {
465
-		if ( $this->customEscapingFunctions !== $this->addedCustomFunctions['escape'] ) {
465
+		if ( $this->customEscapingFunctions !== $this->addedCustomFunctions[ 'escape' ] ) {
466 466
 			$customEscapeFunctions = $this->merge_custom_array( $this->customEscapingFunctions, array(), false );
467 467
 
468 468
 			$this->escapingFunctions = $this->merge_custom_array(
@@ -470,26 +470,26 @@  discard block
 block discarded – undo
470 470
 				$this->escapingFunctions
471 471
 			);
472 472
 
473
-			$this->addedCustomFunctions['escape'] = $this->customEscapingFunctions;
473
+			$this->addedCustomFunctions[ 'escape' ] = $this->customEscapingFunctions;
474 474
 		}
475 475
 
476
-		if ( $this->customAutoEscapedFunctions !== $this->addedCustomFunctions['autoescape'] ) {
476
+		if ( $this->customAutoEscapedFunctions !== $this->addedCustomFunctions[ 'autoescape' ] ) {
477 477
 			$this->autoEscapedFunctions = $this->merge_custom_array(
478 478
 				$this->customAutoEscapedFunctions,
479 479
 				$this->autoEscapedFunctions
480 480
 			);
481 481
 
482
-			$this->addedCustomFunctions['autoescape'] = $this->customAutoEscapedFunctions;
482
+			$this->addedCustomFunctions[ 'autoescape' ] = $this->customAutoEscapedFunctions;
483 483
 		}
484 484
 
485
-		if ( $this->customPrintingFunctions !== $this->addedCustomFunctions['print'] ) {
485
+		if ( $this->customPrintingFunctions !== $this->addedCustomFunctions[ 'print' ] ) {
486 486
 
487 487
 			$this->printingFunctions = $this->merge_custom_array(
488 488
 				$this->customPrintingFunctions,
489 489
 				$this->printingFunctions
490 490
 			);
491 491
 
492
-			$this->addedCustomFunctions['print'] = $this->customPrintingFunctions;
492
+			$this->addedCustomFunctions[ 'print' ] = $this->customPrintingFunctions;
493 493
 		}
494 494
 	}
495 495
 
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -165,7 +165,7 @@
 block discarded – undo
165 165
 	/**
166 166
 	 * Returns an array of tokens this test wants to listen for.
167 167
 	 *
168
-	 * @return array
168
+	 * @return integer[]
169 169
 	 */
170 170
 	public function register() {
171 171
 
Please login to merge, or discard this patch.
wpcs/WordPress/Sniffs/Security/NonceVerificationSniff.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 
108 108
 		$instance = $this->tokens[ $stackPtr ];
109 109
 
110
-		if ( ! isset( $this->superglobals[ $instance['content'] ] ) ) {
110
+		if ( ! isset( $this->superglobals[ $instance[ 'content' ] ] ) ) {
111 111
 			return;
112 112
 		}
113 113
 
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 		}
127 127
 
128 128
 		$error_code = 'Missing';
129
-		if ( false === $this->superglobals[ $instance['content'] ] ) {
129
+		if ( false === $this->superglobals[ $instance[ 'content' ] ] ) {
130 130
 			$error_code = 'Recommended';
131 131
 		}
132 132
 
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 		$this->addMessage(
135 135
 			'Processing form data without nonce verification.',
136 136
 			$stackPtr,
137
-			$this->superglobals[ $instance['content'] ],
137
+			$this->superglobals[ $instance[ 'content' ] ],
138 138
 			$error_code
139 139
 		);
140 140
 	}
@@ -147,31 +147,31 @@  discard block
 block discarded – undo
147 147
 	 * @return void
148 148
 	 */
149 149
 	protected function mergeFunctionLists() {
150
-		if ( $this->customNonceVerificationFunctions !== $this->addedCustomFunctions['nonce'] ) {
150
+		if ( $this->customNonceVerificationFunctions !== $this->addedCustomFunctions[ 'nonce' ] ) {
151 151
 			$this->nonceVerificationFunctions = $this->merge_custom_array(
152 152
 				$this->customNonceVerificationFunctions,
153 153
 				$this->nonceVerificationFunctions
154 154
 			);
155 155
 
156
-			$this->addedCustomFunctions['nonce'] = $this->customNonceVerificationFunctions;
156
+			$this->addedCustomFunctions[ 'nonce' ] = $this->customNonceVerificationFunctions;
157 157
 		}
158 158
 
159
-		if ( $this->customSanitizingFunctions !== $this->addedCustomFunctions['sanitize'] ) {
159
+		if ( $this->customSanitizingFunctions !== $this->addedCustomFunctions[ 'sanitize' ] ) {
160 160
 			$this->sanitizingFunctions = $this->merge_custom_array(
161 161
 				$this->customSanitizingFunctions,
162 162
 				$this->sanitizingFunctions
163 163
 			);
164 164
 
165
-			$this->addedCustomFunctions['sanitize'] = $this->customSanitizingFunctions;
165
+			$this->addedCustomFunctions[ 'sanitize' ] = $this->customSanitizingFunctions;
166 166
 		}
167 167
 
168
-		if ( $this->customUnslashingSanitizingFunctions !== $this->addedCustomFunctions['unslashsanitize'] ) {
168
+		if ( $this->customUnslashingSanitizingFunctions !== $this->addedCustomFunctions[ 'unslashsanitize' ] ) {
169 169
 			$this->unslashingSanitizingFunctions = $this->merge_custom_array(
170 170
 				$this->customUnslashingSanitizingFunctions,
171 171
 				$this->unslashingSanitizingFunctions
172 172
 			);
173 173
 
174
-			$this->addedCustomFunctions['unslashsanitize'] = $this->customUnslashingSanitizingFunctions;
174
+			$this->addedCustomFunctions[ 'unslashsanitize' ] = $this->customUnslashingSanitizingFunctions;
175 175
 		}
176 176
 	}
177 177
 
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -165,7 +165,7 @@
 block discarded – undo
165 165
 	/**
166 166
 	 * Returns an array of tokens this test wants to listen for.
167 167
 	 *
168
-	 * @return array
168
+	 * @return integer[]
169 169
 	 */
170 170
 	public function register() {
171 171
 
Please login to merge, or discard this patch.