Completed
Pull Request — develop (#1492)
by Zack
15:57
created
wpcs/WordPress/Sniffs/Arrays/CommaAfterArrayItemSniff.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -60,8 +60,8 @@  discard block
 block discarded – undo
60 60
 			return;
61 61
 		}
62 62
 
63
-		$opener = $array_open_close['opener'];
64
-		$closer = $array_open_close['closer'];
63
+		$opener = $array_open_close[ 'opener' ];
64
+		$closer = $array_open_close[ 'closer' ];
65 65
 		unset( $array_open_close );
66 66
 
67 67
 		// This array is empty, so the below checks aren't necessary.
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 		}
71 71
 
72 72
 		$single_line = true;
73
-		if ( $this->tokens[ $opener ]['line'] !== $this->tokens[ $closer ]['line'] ) {
73
+		if ( $this->tokens[ $opener ][ 'line' ] !== $this->tokens[ $closer ][ 'line' ] ) {
74 74
 			$single_line = false;
75 75
 		}
76 76
 
@@ -84,9 +84,9 @@  discard block
 block discarded – undo
84 84
 
85 85
 		// Note: $item_index is 1-based and the array items are split on the commas!
86 86
 		foreach ( $array_items as $item_index => $item ) {
87
-			$maybe_comma = ( $item['end'] + 1 );
87
+			$maybe_comma = ( $item[ 'end' ] + 1 );
88 88
 			$is_comma    = false;
89
-			if ( isset( $this->tokens[ $maybe_comma ] ) && \T_COMMA === $this->tokens[ $maybe_comma ]['code'] ) {
89
+			if ( isset( $this->tokens[ $maybe_comma ] ) && \T_COMMA === $this->tokens[ $maybe_comma ][ 'code' ] ) {
90 90
 				$is_comma = true;
91 91
 			}
92 92
 
@@ -116,8 +116,8 @@  discard block
 block discarded – undo
116 116
 
117 117
 			$last_content = $this->phpcsFile->findPrevious(
118 118
 				Tokens::$emptyTokens,
119
-				$item['end'],
120
-				$item['start'],
119
+				$item[ 'end' ],
120
+				$item[ 'start' ],
121 121
 				true
122 122
 			);
123 123
 
@@ -153,23 +153,23 @@  discard block
 block discarded – undo
153 153
 			/*
154 154
 			 * Check for whitespace at the end of the array item.
155 155
 			 */
156
-			if ( $last_content !== $item['end']
156
+			if ( $last_content !== $item[ 'end' ]
157 157
 				// Ignore whitespace at the end of a multi-line item if it is the end of a heredoc/nowdoc.
158 158
 				&& ( true === $single_line
159
-					|| ! isset( Tokens::$heredocTokens[ $this->tokens[ $last_content ]['code'] ] ) )
159
+					|| ! isset( Tokens::$heredocTokens[ $this->tokens[ $last_content ][ 'code' ] ] ) )
160 160
 			) {
161 161
 				$newlines = 0;
162 162
 				$spaces   = 0;
163
-				for ( $i = $item['end']; $i > $last_content; $i-- ) {
163
+				for ( $i = $item[ 'end' ]; $i > $last_content; $i-- ) {
164 164
 
165
-					if ( \T_WHITESPACE === $this->tokens[ $i ]['code'] ) {
166
-						if ( $this->tokens[ $i ]['content'] === $this->phpcsFile->eolChar ) {
165
+					if ( \T_WHITESPACE === $this->tokens[ $i ][ 'code' ] ) {
166
+						if ( $this->tokens[ $i ][ 'content' ] === $this->phpcsFile->eolChar ) {
167 167
 							$newlines++;
168 168
 						} else {
169
-							$spaces += $this->tokens[ $i ]['length'];
169
+							$spaces += $this->tokens[ $i ][ 'length' ];
170 170
 						}
171
-					} elseif ( \T_COMMENT === $this->tokens[ $i ]['code']
172
-						|| isset( Tokens::$phpcsCommentTokens[ $this->tokens[ $i ]['code'] ] )
171
+					} elseif ( \T_COMMENT === $this->tokens[ $i ][ 'code' ]
172
+						|| isset( Tokens::$phpcsCommentTokens[ $this->tokens[ $i ][ 'code' ] ] )
173 173
 					) {
174 174
 						break;
175 175
 					}
@@ -177,10 +177,10 @@  discard block
 block discarded – undo
177 177
 
178 178
 				$space_phrases = array();
179 179
 				if ( $spaces > 0 ) {
180
-					$space_phrases[] = $spaces . ' spaces';
180
+					$space_phrases[ ] = $spaces . ' spaces';
181 181
 				}
182 182
 				if ( $newlines > 0 ) {
183
-					$space_phrases[] = $newlines . ' newlines';
183
+					$space_phrases[ ] = $newlines . ' newlines';
184 184
 				}
185 185
 				unset( $newlines, $spaces );
186 186
 
@@ -189,20 +189,20 @@  discard block
 block discarded – undo
189 189
 					$maybe_comma,
190 190
 					'SpaceBeforeComma',
191 191
 					array(
192
-						$this->tokens[ $last_content ]['content'],
192
+						$this->tokens[ $last_content ][ 'content' ],
193 193
 						implode( ' and ', $space_phrases ),
194 194
 					)
195 195
 				);
196 196
 
197 197
 				if ( true === $fix ) {
198 198
 					$this->phpcsFile->fixer->beginChangeset();
199
-					for ( $i = $item['end']; $i > $last_content; $i-- ) {
199
+					for ( $i = $item[ 'end' ]; $i > $last_content; $i-- ) {
200 200
 
201
-						if ( \T_WHITESPACE === $this->tokens[ $i ]['code'] ) {
201
+						if ( \T_WHITESPACE === $this->tokens[ $i ][ 'code' ] ) {
202 202
 							$this->phpcsFile->fixer->replaceToken( $i, '' );
203 203
 
204
-						} elseif ( \T_COMMENT === $this->tokens[ $i ]['code']
205
-							|| isset( Tokens::$phpcsCommentTokens[ $this->tokens[ $i ]['code'] ] )
204
+						} elseif ( \T_COMMENT === $this->tokens[ $i ][ 'code' ]
205
+							|| isset( Tokens::$phpcsCommentTokens[ $this->tokens[ $i ][ 'code' ] ] )
206 206
 						) {
207 207
 							// We need to move the comma to before the comment.
208 208
 							$this->phpcsFile->fixer->addContent( $last_content, ',' );
@@ -231,9 +231,9 @@  discard block
 block discarded – undo
231 231
 			 */
232 232
 			$next_token = $this->tokens[ ( $maybe_comma + 1 ) ];
233 233
 
234
-			if ( \T_WHITESPACE === $next_token['code'] ) {
234
+			if ( \T_WHITESPACE === $next_token[ 'code' ] ) {
235 235
 
236
-				if ( false === $single_line && $this->phpcsFile->eolChar === $next_token['content'] ) {
236
+				if ( false === $single_line && $this->phpcsFile->eolChar === $next_token[ 'content' ] ) {
237 237
 					continue;
238 238
 				}
239 239
 
@@ -246,14 +246,14 @@  discard block
 block discarded – undo
246 246
 
247 247
 				if ( false === $next_non_whitespace
248 248
 					|| ( false === $single_line
249
-						&& $this->tokens[ $next_non_whitespace ]['line'] === $this->tokens[ $maybe_comma ]['line']
250
-						&& ( \T_COMMENT === $this->tokens[ $next_non_whitespace ]['code']
251
-							|| isset( Tokens::$phpcsCommentTokens[ $this->tokens[ $next_non_whitespace ]['code'] ] ) ) )
249
+						&& $this->tokens[ $next_non_whitespace ][ 'line' ] === $this->tokens[ $maybe_comma ][ 'line' ]
250
+						&& ( \T_COMMENT === $this->tokens[ $next_non_whitespace ][ 'code' ]
251
+							|| isset( Tokens::$phpcsCommentTokens[ $this->tokens[ $next_non_whitespace ][ 'code' ] ] ) ) )
252 252
 				) {
253 253
 					continue;
254 254
 				}
255 255
 
256
-				$space_length = $next_token['length'];
256
+				$space_length = $next_token[ 'length' ];
257 257
 				if ( 1 === $space_length ) {
258 258
 					continue;
259 259
 				}
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 					$maybe_comma,
264 264
 					'SpaceAfterComma',
265 265
 					array(
266
-						$this->tokens[ $next_non_whitespace ]['content'],
266
+						$this->tokens[ $next_non_whitespace ][ 'content' ],
267 267
 						$space_length,
268 268
 					)
269 269
 				);
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 					'Expected 1 space between comma and "%s"; 0 found',
279 279
 					$maybe_comma,
280 280
 					'NoSpaceAfterComma',
281
-					array( $next_token['content'] )
281
+					array( $next_token[ 'content' ] )
282 282
 				);
283 283
 
284 284
 				if ( true === $fix ) {
Please login to merge, or discard this patch.
wpcs/WordPress/Sniffs/Arrays/MultipleStatementAlignmentSniff.php 1 patch
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -173,8 +173,8 @@  discard block
 block discarded – undo
173 173
 			return;
174 174
 		}
175 175
 
176
-		$opener = $array_open_close['opener'];
177
-		$closer = $array_open_close['closer'];
176
+		$opener = $array_open_close[ 'opener' ];
177
+		$closer = $array_open_close[ 'closer' ];
178 178
 
179 179
 		$array_items = $this->get_function_call_parameters( $stackPtr );
180 180
 		if ( empty( $array_items ) ) {
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 		}
183 183
 
184 184
 		// Pass off to either the single line or multi-line array analysis.
185
-		if ( $this->tokens[ $opener ]['line'] === $this->tokens[ $closer ]['line'] ) {
185
+		if ( $this->tokens[ $opener ][ 'line' ] === $this->tokens[ $closer ][ 'line' ] ) {
186 186
 			return $this->process_single_line_array( $stackPtr, $array_items, $opener, $closer );
187 187
 		} else {
188 188
 			return $this->process_multi_line_array( $stackPtr, $array_items, $opener, $closer );
@@ -222,12 +222,12 @@  discard block
 block discarded – undo
222 222
 		);
223 223
 
224 224
 		while ( false !== $next_arrow ) {
225
-			if ( \T_WHITESPACE === $this->tokens[ ( $next_arrow - 1 ) ]['code'] ) {
226
-				$space_length = $this->tokens[ ( $next_arrow - 1 ) ]['length'];
225
+			if ( \T_WHITESPACE === $this->tokens[ ( $next_arrow - 1 ) ][ 'code' ] ) {
226
+				$space_length = $this->tokens[ ( $next_arrow - 1 ) ][ 'length' ];
227 227
 				if ( 1 !== $space_length ) {
228 228
 					$error = 'Expected 1 space between "%s" and double arrow; %s found';
229 229
 					$data  = array(
230
-						$this->tokens[ ( $next_arrow - 2 ) ]['content'],
230
+						$this->tokens[ ( $next_arrow - 2 ) ][ 'content' ],
231 231
 						$space_length,
232 232
 					);
233 233
 
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
 	 */
265 265
 	protected function process_multi_line_array( $stackPtr, $items, $opener, $closer ) {
266 266
 
267
-		$this->maxColumn = (int) $this->maxColumn;
267
+		$this->maxColumn = (int)$this->maxColumn;
268 268
 		$this->validate_align_multiline_items();
269 269
 
270 270
 		/*
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 		$total_items       = \count( $items );
286 286
 
287 287
 		foreach ( $items as $key => $item ) {
288
-			if ( strpos( $item['raw'], '=>' ) === false ) {
288
+			if ( strpos( $item[ 'raw' ], '=>' ) === false ) {
289 289
 				// Ignore items without assignment operators.
290 290
 				unset( $items[ $key ] );
291 291
 				continue;
@@ -294,8 +294,8 @@  discard block
 block discarded – undo
294 294
 			// Find the position of the first double arrow.
295 295
 			$double_arrow = $this->phpcsFile->findNext(
296 296
 				\T_DOUBLE_ARROW,
297
-				$item['start'],
298
-				( $item['end'] + 1 )
297
+				$item[ 'start' ],
298
+				( $item[ 'end' ] + 1 )
299 299
 			);
300 300
 
301 301
 			if ( false === $double_arrow ) {
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
 			// Make sure the arrow is for this item and not for a nested array value assignment.
308 308
 			$has_array_opener = $this->phpcsFile->findNext(
309 309
 				$this->register(),
310
-				$item['start'],
310
+				$item[ 'start' ],
311 311
 				$double_arrow
312 312
 			);
313 313
 
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 			$last_index_token = $this->phpcsFile->findPrevious(
322 322
 				\T_WHITESPACE,
323 323
 				( $double_arrow - 1 ),
324
-				$item['start'],
324
+				$item[ 'start' ],
325 325
 				true
326 326
 			);
327 327
 
@@ -332,33 +332,33 @@  discard block
 block discarded – undo
332 332
 			}
333 333
 
334 334
 			if ( true === $this->ignoreNewlines
335
-				&& $this->tokens[ $last_index_token ]['line'] !== $this->tokens[ $double_arrow ]['line']
335
+				&& $this->tokens[ $last_index_token ][ 'line' ] !== $this->tokens[ $double_arrow ][ 'line' ]
336 336
 			) {
337 337
 				// Ignore this item as it has a new line between the item key and the double arrow.
338 338
 				unset( $items[ $key ] );
339 339
 				continue;
340 340
 			}
341 341
 
342
-			$index_end_position                = ( $this->tokens[ $last_index_token ]['column'] + ( $this->tokens[ $last_index_token ]['length'] - 1 ) );
343
-			$items[ $key ]['operatorPtr']      = $double_arrow;
344
-			$items[ $key ]['last_index_token'] = $last_index_token;
345
-			$items[ $key ]['last_index_col']   = $index_end_position;
342
+			$index_end_position                = ( $this->tokens[ $last_index_token ][ 'column' ] + ( $this->tokens[ $last_index_token ][ 'length' ] - 1 ) );
343
+			$items[ $key ][ 'operatorPtr' ]      = $double_arrow;
344
+			$items[ $key ][ 'last_index_token' ] = $last_index_token;
345
+			$items[ $key ][ 'last_index_col' ]   = $index_end_position;
346 346
 
347
-			if ( $this->tokens[ $last_index_token ]['line'] === $this->tokens[ $item['end'] ]['line'] ) {
348
-				$items[ $key ]['single_line'] = true;
347
+			if ( $this->tokens[ $last_index_token ][ 'line' ] === $this->tokens[ $item[ 'end' ] ][ 'line' ] ) {
348
+				$items[ $key ][ 'single_line' ] = true;
349 349
 			} else {
350
-				$items[ $key ]['single_line'] = false;
350
+				$items[ $key ][ 'single_line' ] = false;
351 351
 				$multi_line_count++;
352 352
 			}
353 353
 
354 354
 			if ( ( $index_end_position + 2 ) <= $this->maxColumn ) {
355
-				$index_end_cols[] = $index_end_position;
355
+				$index_end_cols[ ] = $index_end_position;
356 356
 			}
357 357
 
358
-			if ( ! isset( $double_arrow_cols[ $this->tokens[ $double_arrow ]['column'] ] ) ) {
359
-				$double_arrow_cols[ $this->tokens[ $double_arrow ]['column'] ] = 1;
358
+			if ( ! isset( $double_arrow_cols[ $this->tokens[ $double_arrow ][ 'column' ] ] ) ) {
359
+				$double_arrow_cols[ $this->tokens[ $double_arrow ][ 'column' ] ] = 1;
360 360
 			} else {
361
-				$double_arrow_cols[ $this->tokens[ $double_arrow ]['column'] ]++;
361
+				$double_arrow_cols[ $this->tokens[ $double_arrow ][ 'column' ] ]++;
362 362
 			}
363 363
 		}
364 364
 		unset( $key, $item, $double_arrow, $has_array_opener, $last_index_token );
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
 		} elseif ( 'never' === $this->alignMultilineItems ) {
377 377
 			$alignMultilineItems = false;
378 378
 		} else {
379
-			$percentage = (string) round( ( $multi_line_count / $total_items ) * 100, 0 );
379
+			$percentage = (string)round( ( $multi_line_count / $total_items ) * 100, 0 );
380 380
 
381 381
 			// Bit hacky, but this is the only comparison function in PHP which allows to
382 382
 			// pass the comparison operator. And hey, it works ;-).
@@ -392,18 +392,18 @@  discard block
 block discarded – undo
392 392
 			$double_arrow_cols     = array();
393 393
 
394 394
 			foreach ( $items as $item ) {
395
-				if ( false === $item['single_line'] ) {
395
+				if ( false === $item[ 'single_line' ] ) {
396 396
 					continue;
397 397
 				}
398 398
 
399
-				if ( ( $item['last_index_col'] + 2 ) <= $this->maxColumn ) {
400
-					$select_index_end_cols[] = $item['last_index_col'];
399
+				if ( ( $item[ 'last_index_col' ] + 2 ) <= $this->maxColumn ) {
400
+					$select_index_end_cols[ ] = $item[ 'last_index_col' ];
401 401
 				}
402 402
 
403
-				if ( ! isset( $double_arrow_cols[ $this->tokens[ $item['operatorPtr'] ]['column'] ] ) ) {
404
-					$double_arrow_cols[ $this->tokens[ $item['operatorPtr'] ]['column'] ] = 1;
403
+				if ( ! isset( $double_arrow_cols[ $this->tokens[ $item[ 'operatorPtr' ] ][ 'column' ] ] ) ) {
404
+					$double_arrow_cols[ $this->tokens[ $item[ 'operatorPtr' ] ][ 'column' ] ] = 1;
405 405
 				} else {
406
-					$double_arrow_cols[ $this->tokens[ $item['operatorPtr'] ]['column'] ]++;
406
+					$double_arrow_cols[ $this->tokens[ $item[ 'operatorPtr' ] ][ 'column' ] ]++;
407 407
 				}
408 408
 			}
409 409
 		}
@@ -446,20 +446,20 @@  discard block
 block discarded – undo
446 446
 		 * Verify and correct the spacing around the double arrows.
447 447
 		 */
448 448
 		foreach ( $items as $item ) {
449
-			if ( $this->tokens[ $item['operatorPtr'] ]['column'] === $expected_col
450
-				&& $this->tokens[ $item['operatorPtr'] ]['line'] === $this->tokens[ $item['last_index_token'] ]['line']
449
+			if ( $this->tokens[ $item[ 'operatorPtr' ] ][ 'column' ] === $expected_col
450
+				&& $this->tokens[ $item[ 'operatorPtr' ] ][ 'line' ] === $this->tokens[ $item[ 'last_index_token' ] ][ 'line' ]
451 451
 			) {
452 452
 				// Already correctly aligned.
453 453
 				continue;
454 454
 			}
455 455
 
456
-			if ( \T_WHITESPACE !== $this->tokens[ ( $item['operatorPtr'] - 1 ) ]['code'] ) {
456
+			if ( \T_WHITESPACE !== $this->tokens[ ( $item[ 'operatorPtr' ] - 1 ) ][ 'code' ] ) {
457 457
 				$before = 0;
458 458
 			} else {
459
-				if ( $this->tokens[ $item['last_index_token'] ]['line'] !== $this->tokens[ $item['operatorPtr'] ]['line'] ) {
459
+				if ( $this->tokens[ $item[ 'last_index_token' ] ][ 'line' ] !== $this->tokens[ $item[ 'operatorPtr' ] ][ 'line' ] ) {
460 460
 					$before = 'newline';
461 461
 				} else {
462
-					$before = $this->tokens[ ( $item['operatorPtr'] - 1 ) ]['length'];
462
+					$before = $this->tokens[ ( $item[ 'operatorPtr' ] - 1 ) ][ 'length' ];
463 463
 				}
464 464
 			}
465 465
 
@@ -467,19 +467,19 @@  discard block
 block discarded – undo
467 467
 			 * Deal with index sizes larger than maxColumn and with multi-line
468 468
 			 * array items which should not be aligned.
469 469
 			 */
470
-			if ( ( $item['last_index_col'] + 2 ) > $this->maxColumn
471
-				|| ( false === $alignMultilineItems && false === $item['single_line'] )
470
+			if ( ( $item[ 'last_index_col' ] + 2 ) > $this->maxColumn
471
+				|| ( false === $alignMultilineItems && false === $item[ 'single_line' ] )
472 472
 			) {
473 473
 
474
-				if ( ( $item['last_index_col'] + 2 ) === $this->tokens[ $item['operatorPtr'] ]['column']
475
-					&& $this->tokens[ $item['operatorPtr'] ]['line'] === $this->tokens[ $item['last_index_token'] ]['line']
474
+				if ( ( $item[ 'last_index_col' ] + 2 ) === $this->tokens[ $item[ 'operatorPtr' ] ][ 'column' ]
475
+					&& $this->tokens[ $item[ 'operatorPtr' ] ][ 'line' ] === $this->tokens[ $item[ 'last_index_token' ] ][ 'line' ]
476 476
 				) {
477 477
 					// MaxColumn/Multi-line item exception, already correctly aligned.
478 478
 					continue;
479 479
 				}
480 480
 
481 481
 				$prefix = 'LongIndex';
482
-				if ( false === $alignMultilineItems && false === $item['single_line'] ) {
482
+				if ( false === $alignMultilineItems && false === $item[ 'single_line' ] ) {
483 483
 					$prefix = 'MultilineItem';
484 484
 				}
485 485
 
@@ -490,10 +490,10 @@  discard block
 block discarded – undo
490 490
 
491 491
 				$fix = $this->phpcsFile->addFixableWarning(
492 492
 					'Expected 1 space between "%s" and double arrow; %s found.',
493
-					$item['operatorPtr'],
493
+					$item[ 'operatorPtr' ],
494 494
 					$error_code,
495 495
 					array(
496
-						$this->tokens[ $item['last_index_token'] ]['content'],
496
+						$this->tokens[ $item[ 'last_index_token' ] ][ 'content' ],
497 497
 						$before,
498 498
 					)
499 499
 				);
@@ -502,12 +502,12 @@  discard block
 block discarded – undo
502 502
 					$this->phpcsFile->fixer->beginChangeset();
503 503
 
504 504
 					// Remove whitespace tokens between the end of the index and the arrow, if any.
505
-					for ( $i = ( $item['last_index_token'] + 1 ); $i < $item['operatorPtr']; $i++ ) {
505
+					for ( $i = ( $item[ 'last_index_token' ] + 1 ); $i < $item[ 'operatorPtr' ]; $i++ ) {
506 506
 						$this->phpcsFile->fixer->replaceToken( $i, '' );
507 507
 					}
508 508
 
509 509
 					// Add the correct whitespace.
510
-					$this->phpcsFile->fixer->addContent( $item['last_index_token'], ' ' );
510
+					$this->phpcsFile->fixer->addContent( $item[ 'last_index_token' ], ' ' );
511 511
 
512 512
 					$this->phpcsFile->fixer->endChangeset();
513 513
 				}
@@ -517,15 +517,15 @@  discard block
 block discarded – undo
517 517
 			/*
518 518
 			 * Deal with the space before double arrows in all other cases.
519 519
 			 */
520
-			$expected_whitespace = $expected_col - ( $this->tokens[ $item['last_index_token'] ]['column'] + $this->tokens[ $item['last_index_token'] ]['length'] );
520
+			$expected_whitespace = $expected_col - ( $this->tokens[ $item[ 'last_index_token' ] ][ 'column' ] + $this->tokens[ $item[ 'last_index_token' ] ][ 'length' ] );
521 521
 
522 522
 			$fix = $this->phpcsFile->addFixableWarning(
523 523
 				'Array double arrow not aligned correctly; expected %s space(s) between "%s" and double arrow, but found %s.',
524
-				$item['operatorPtr'],
524
+				$item[ 'operatorPtr' ],
525 525
 				'DoubleArrowNotAligned',
526 526
 				array(
527 527
 					$expected_whitespace,
528
-					$this->tokens[ $item['last_index_token'] ]['content'],
528
+					$this->tokens[ $item[ 'last_index_token' ] ][ 'content' ],
529 529
 					$before,
530 530
 				)
531 531
 			);
@@ -535,13 +535,13 @@  discard block
 block discarded – undo
535 535
 					$this->phpcsFile->fixer->beginChangeset();
536 536
 
537 537
 					// Remove whitespace tokens between the end of the index and the arrow, if any.
538
-					for ( $i = ( $item['last_index_token'] + 1 ); $i < $item['operatorPtr']; $i++ ) {
538
+					for ( $i = ( $item[ 'last_index_token' ] + 1 ); $i < $item[ 'operatorPtr' ]; $i++ ) {
539 539
 						$this->phpcsFile->fixer->replaceToken( $i, '' );
540 540
 					}
541 541
 
542 542
 					// Add the correct whitespace.
543 543
 					$this->phpcsFile->fixer->addContent(
544
-						$item['last_index_token'],
544
+						$item[ 'last_index_token' ],
545 545
 						str_repeat( ' ', $expected_whitespace )
546 546
 					);
547 547
 
@@ -550,13 +550,13 @@  discard block
 block discarded – undo
550 550
 					// Add to the existing whitespace to prevent replacing tabs with spaces.
551 551
 					// That's the concern of another sniff.
552 552
 					$this->phpcsFile->fixer->addContent(
553
-						( $item['operatorPtr'] - 1 ),
553
+						( $item[ 'operatorPtr' ] - 1 ),
554 554
 						str_repeat( ' ', ( $expected_whitespace - $before ) )
555 555
 					);
556 556
 				} else {
557 557
 					// Too much whitespace found.
558 558
 					$this->phpcsFile->fixer->replaceToken(
559
-						( $item['operatorPtr'] - 1 ),
559
+						( $item[ 'operatorPtr' ] - 1 ),
560 560
 						str_repeat( ' ', $expected_whitespace )
561 561
 					);
562 562
 				}
@@ -581,14 +581,14 @@  discard block
 block discarded – undo
581 581
 			$alignMultilineItems = rtrim( $alignMultilineItems, '%' );
582 582
 
583 583
 			if ( preg_match( '`^([=<>!]{1,2})(100|[0-9]{1,2})$`', $alignMultilineItems, $matches ) > 0 ) {
584
-				$operator = $matches[1];
585
-				$number   = (int) $matches[2];
584
+				$operator = $matches[ 1 ];
585
+				$number   = (int)$matches[ 2 ];
586 586
 
587 587
 				if ( \in_array( $operator, array( '<', '<=', '>', '>=', '==', '=', '!=', '<>' ), true ) === true
588 588
 					&& ( $number >= 0 && $number <= 100 )
589 589
 				) {
590 590
 					$this->alignMultilineItems = $alignMultilineItems;
591
-					$this->number              = (string) $number;
591
+					$this->number              = (string)$number;
592 592
 					$this->operator            = $operator;
593 593
 					return;
594 594
 				}
Please login to merge, or discard this patch.
wpcs/WordPress/Sniffs/WP/EnqueuedResourceParametersSniff.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 	public function process_parameters( $stackPtr, $group_name, $matched_content, $parameters ) {
121 121
 
122 122
 		// Check to see if a source ($src) is specified.
123
-		if ( ! isset( $parameters[2] ) ) {
123
+		if ( ! isset( $parameters[ 2 ] ) ) {
124 124
 			return;
125 125
 		}
126 126
 
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 		 * Version Check: Check to make sure the version is set explicitly.
129 129
 		 */
130 130
 
131
-		if ( ! isset( $parameters[4] ) || 'null' === $parameters[4]['raw'] ) {
131
+		if ( ! isset( $parameters[ 4 ] ) || 'null' === $parameters[ 4 ][ 'raw' ] ) {
132 132
 			$type = 'script';
133 133
 			if ( strpos( $matched_content, '_style' ) !== false ) {
134 134
 				$type = 'style';
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 			);
143 143
 		} else {
144 144
 			// The version argument should have a non-false value.
145
-			if ( $this->is_falsy( $parameters[4]['start'], $parameters[4]['end'] ) ) {
145
+			if ( $this->is_falsy( $parameters[ 4 ][ 'start' ], $parameters[ 4 ][ 'end' ] ) ) {
146 146
 				$this->phpcsFile->addError(
147 147
 					'Version parameter is not explicitly set or has been set to an equivalent of "false" for %s; ' .
148 148
 					'This means that the WordPress core version will be used which is not recommended for plugin or theme development.',
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 			return;
167 167
 		}
168 168
 
169
-		if ( ! isset( $parameters[5] ) ) {
169
+		if ( ! isset( $parameters[ 5 ] ) ) {
170 170
 			// If in footer is not set, throw a warning about the default.
171 171
 			$this->phpcsFile->addWarning(
172 172
 				'In footer ($in_footer) is not set explicitly %s; ' .
@@ -199,17 +199,17 @@  discard block
 block discarded – undo
199 199
 
200 200
 		$code_string = '';
201 201
 		for ( $i = $start; $i <= $end; $i++ ) {
202
-			if ( isset( $this->safe_tokens[ $this->tokens[ $i ]['code'] ] ) === false ) {
202
+			if ( isset( $this->safe_tokens[ $this->tokens[ $i ][ 'code' ] ] ) === false ) {
203 203
 				// Function call/variable or other token which makes it neigh impossible
204 204
 				// to determine whether the actual value would evaluate to false.
205 205
 				return false;
206 206
 			}
207 207
 
208
-			if ( isset( Tokens::$emptyTokens[ $this->tokens[ $i ]['code'] ] ) === true ) {
208
+			if ( isset( Tokens::$emptyTokens[ $this->tokens[ $i ][ 'code' ] ] ) === true ) {
209 209
 				continue;
210 210
 			}
211 211
 
212
-			$code_string .= $this->tokens[ $i ]['content'];
212
+			$code_string .= $this->tokens[ $i ][ 'content' ];
213 213
 		}
214 214
 
215 215
 		if ( '' === $code_string ) {
Please login to merge, or discard this patch.
wpcs/WordPress/Sniffs/WP/DeprecatedClassesSniff.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -86,18 +86,18 @@
 block discarded – undo
86 86
 		$message = 'The %s class has been deprecated since WordPress version %s.';
87 87
 		$data    = array(
88 88
 			ltrim( $matched_content, '\\' ),
89
-			$this->deprecated_classes[ $class_name ]['version'],
89
+			$this->deprecated_classes[ $class_name ][ 'version' ],
90 90
 		);
91 91
 
92
-		if ( ! empty( $this->deprecated_classes[ $class_name ]['alt'] ) ) {
92
+		if ( ! empty( $this->deprecated_classes[ $class_name ][ 'alt' ] ) ) {
93 93
 			$message .= ' Use %s instead.';
94
-			$data[]   = $this->deprecated_classes[ $class_name ]['alt'];
94
+			$data[ ]   = $this->deprecated_classes[ $class_name ][ 'alt' ];
95 95
 		}
96 96
 
97 97
 		$this->addMessage(
98 98
 			$message,
99 99
 			$stackPtr,
100
-			( version_compare( $this->deprecated_classes[ $class_name ]['version'], $this->minimum_supported_version, '<' ) ),
100
+			( version_compare( $this->deprecated_classes[ $class_name ][ 'version' ], $this->minimum_supported_version, '<' ) ),
101 101
 			$this->string_to_errorcode( $class_name . 'Found' ),
102 102
 			$data
103 103
 		);
Please login to merge, or discard this patch.
wpcs/WordPress/Sniffs/WP/AlternativeFunctionsSniff.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -216,34 +216,34 @@  discard block
 block discarded – undo
216 216
 				 */
217 217
 				$params = $this->get_function_call_parameters( $stackPtr );
218 218
 
219
-				if ( isset( $params[2] ) && 'true' === $params[2]['raw'] ) {
219
+				if ( isset( $params[ 2 ] ) && 'true' === $params[ 2 ][ 'raw' ] ) {
220 220
 					// Setting `$use_include_path` to `true` is only relevant for local files.
221 221
 					return;
222 222
 				}
223 223
 
224
-				if ( isset( $params[1] ) === false ) {
224
+				if ( isset( $params[ 1 ] ) === false ) {
225 225
 					// If the file to get is not set, this is a non-issue anyway.
226 226
 					return;
227 227
 				}
228 228
 
229
-				if ( strpos( $params[1]['raw'], 'http:' ) !== false
230
-					|| strpos( $params[1]['raw'], 'https:' ) !== false
229
+				if ( strpos( $params[ 1 ][ 'raw' ], 'http:' ) !== false
230
+					|| strpos( $params[ 1 ][ 'raw' ], 'https:' ) !== false
231 231
 				) {
232 232
 					// Definitely a URL, throw notice.
233 233
 					break;
234 234
 				}
235 235
 
236
-				if ( preg_match( '`\b(?:ABSPATH|WP_(?:CONTENT|PLUGIN)_DIR|WPMU_PLUGIN_DIR|TEMPLATEPATH|STYLESHEETPATH|(?:MU)?PLUGINDIR)\b`', $params[1]['raw'] ) === 1 ) {
236
+				if ( preg_match( '`\b(?:ABSPATH|WP_(?:CONTENT|PLUGIN)_DIR|WPMU_PLUGIN_DIR|TEMPLATEPATH|STYLESHEETPATH|(?:MU)?PLUGINDIR)\b`', $params[ 1 ][ 'raw' ] ) === 1 ) {
237 237
 					// Using any of the constants matched in this regex is an indicator of a local file.
238 238
 					return;
239 239
 				}
240 240
 
241
-				if ( preg_match( '`(?:get_home_path|plugin_dir_path|get_(?:stylesheet|template)_directory|wp_upload_dir)\s*\(`i', $params[1]['raw'] ) === 1 ) {
241
+				if ( preg_match( '`(?:get_home_path|plugin_dir_path|get_(?:stylesheet|template)_directory|wp_upload_dir)\s*\(`i', $params[ 1 ][ 'raw' ] ) === 1 ) {
242 242
 					// Using any of the functions matched in the regex is an indicator of a local file.
243 243
 					return;
244 244
 				}
245 245
 
246
-				if ( $this->is_local_data_stream( $params[1]['raw'] ) === true ) {
246
+				if ( $this->is_local_data_stream( $params[ 1 ][ 'raw' ] ) === true ) {
247 247
 					// Local data stream.
248 248
 					return;
249 249
 				}
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
 					break;
266 266
 				}
267 267
 
268
-				if ( $this->is_local_data_stream( $first_param['raw'] ) === true ) {
268
+				if ( $this->is_local_data_stream( $first_param[ 'raw' ] ) === true ) {
269 269
 					// Local data stream.
270 270
 					return;
271 271
 				}
@@ -279,12 +279,12 @@  discard block
 block discarded – undo
279 279
 				return;
280 280
 		}
281 281
 
282
-		if ( ! isset( $this->groups[ $group_name ]['since'] ) ) {
282
+		if ( ! isset( $this->groups[ $group_name ][ 'since' ] ) ) {
283 283
 			return parent::process_matched_token( $stackPtr, $group_name, $matched_content );
284 284
 		}
285 285
 
286 286
 		// Verify if the alternative is available in the minimum supported WP version.
287
-		if ( version_compare( $this->groups[ $group_name ]['since'], $this->minimum_supported_version, '<=' ) ) {
287
+		if ( version_compare( $this->groups[ $group_name ][ 'since' ], $this->minimum_supported_version, '<=' ) ) {
288 288
 			return parent::process_matched_token( $stackPtr, $group_name, $matched_content );
289 289
 		}
290 290
 	}
Please login to merge, or discard this patch.
wpcs/WordPress/Sniffs/WP/DiscouragedConstantsSniff.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	 *                  normal file processing.
86 86
 	 */
87 87
 	public function process_token( $stackPtr ) {
88
-		if ( isset( $this->target_functions[ strtolower( $this->tokens[ $stackPtr ]['content'] ) ] ) ) {
88
+		if ( isset( $this->target_functions[ strtolower( $this->tokens[ $stackPtr ][ 'content' ] ) ] ) ) {
89 89
 			// Disallow excluding function groups for this sniff.
90 90
 			$this->exclude = array();
91 91
 
@@ -106,20 +106,20 @@  discard block
 block discarded – undo
106 106
 	 * @return void
107 107
 	 */
108 108
 	public function process_arbitrary_tstring( $stackPtr ) {
109
-		$content = $this->tokens[ $stackPtr ]['content'];
109
+		$content = $this->tokens[ $stackPtr ][ 'content' ];
110 110
 
111 111
 		if ( ! isset( $this->discouraged_constants[ $content ] ) ) {
112 112
 			return;
113 113
 		}
114 114
 
115 115
 		$next = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true );
116
-		if ( false !== $next && \T_OPEN_PARENTHESIS === $this->tokens[ $next ]['code'] ) {
116
+		if ( false !== $next && \T_OPEN_PARENTHESIS === $this->tokens[ $next ][ 'code' ] ) {
117 117
 			// Function call or declaration.
118 118
 			return;
119 119
 		}
120 120
 
121 121
 		$prev = $this->phpcsFile->findPrevious( Tokens::$emptyTokens, ( $stackPtr - 1 ), null, true );
122
-		if ( false !== $prev && isset( $this->preceding_tokens_to_ignore[ $this->tokens[ $prev ]['code'] ] ) ) {
122
+		if ( false !== $prev && isset( $this->preceding_tokens_to_ignore[ $this->tokens[ $prev ][ 'code' ] ] ) ) {
123 123
 			// Not the use of a constant.
124 124
 			return;
125 125
 		}
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 		}
131 131
 
132 132
 		if ( false !== $prev
133
-			&& \T_CONST === $this->tokens[ $prev ]['code']
133
+			&& \T_CONST === $this->tokens[ $prev ][ 'code' ]
134 134
 			&& true === $this->is_class_constant( $prev )
135 135
 		) {
136 136
 			// Class constant of the same name.
@@ -141,18 +141,18 @@  discard block
 block discarded – undo
141 141
 		 * Deal with a number of variations of use statements.
142 142
 		 */
143 143
 		for ( $i = $stackPtr; $i > 0; $i-- ) {
144
-			if ( $this->tokens[ $i ]['line'] !== $this->tokens[ $stackPtr ]['line'] ) {
144
+			if ( $this->tokens[ $i ][ 'line' ] !== $this->tokens[ $stackPtr ][ 'line' ] ) {
145 145
 				break;
146 146
 			}
147 147
 		}
148 148
 
149 149
 		$first_on_line = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $i + 1 ), null, true );
150
-		if ( false !== $first_on_line && \T_USE === $this->tokens[ $first_on_line ]['code'] ) {
150
+		if ( false !== $first_on_line && \T_USE === $this->tokens[ $first_on_line ][ 'code' ] ) {
151 151
 			$next_on_line = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $first_on_line + 1 ), null, true );
152 152
 			if ( false !== $next_on_line ) {
153
-				if ( ( \T_STRING === $this->tokens[ $next_on_line ]['code']
154
-						&& 'const' === $this->tokens[ $next_on_line ]['content'] )
155
-					|| \T_CONST === $this->tokens[ $next_on_line ]['code'] // Happens in some PHPCS versions.
153
+				if ( ( \T_STRING === $this->tokens[ $next_on_line ][ 'code' ]
154
+						&& 'const' === $this->tokens[ $next_on_line ][ 'content' ] )
155
+					|| \T_CONST === $this->tokens[ $next_on_line ][ 'code' ] // Happens in some PHPCS versions.
156 156
 				) {
157 157
 					$has_ns_sep = $this->phpcsFile->findNext( \T_NS_SEPARATOR, ( $next_on_line + 1 ), $stackPtr );
158 158
 					if ( false !== $has_ns_sep ) {
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 			return;
200 200
 		}
201 201
 
202
-		$raw_content = $this->strip_quotes( $parameters[ $target_param ]['raw'] );
202
+		$raw_content = $this->strip_quotes( $parameters[ $target_param ][ 'raw' ] );
203 203
 
204 204
 		if ( isset( $this->discouraged_constants[ $raw_content ] ) ) {
205 205
 			$this->phpcsFile->addWarning(
Please login to merge, or discard this patch.
wpcs/WordPress/Sniffs/WP/GlobalVariablesOverrideSniff.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -97,14 +97,14 @@  discard block
 block discarded – undo
97 97
 		$token = $this->tokens[ $stackPtr ];
98 98
 
99 99
 		// Ignore variable overrides in test classes.
100
-		if ( isset( Tokens::$ooScopeTokens[ $token['code'] ] ) ) {
100
+		if ( isset( Tokens::$ooScopeTokens[ $token[ 'code' ] ] ) ) {
101 101
 
102 102
 			if ( true === $this->is_test_class( $stackPtr )
103
-				&& $token['scope_condition'] === $stackPtr
104
-				&& isset( $token['scope_closer'] )
103
+				&& $token[ 'scope_condition' ] === $stackPtr
104
+				&& isset( $token[ 'scope_closer' ] )
105 105
 			) {
106 106
 				// Skip forward to end of test class.
107
-				return $token['scope_closer'];
107
+				return $token[ 'scope_closer' ];
108 108
 			}
109 109
 
110 110
 			// Otherwise ignore the tokens as they were only registered to enable skipping over test classes.
@@ -119,12 +119,12 @@  discard block
 block discarded – undo
119 119
 		 */
120 120
 		$in_function_scope = $this->phpcsFile->hasCondition( $stackPtr, array( \T_FUNCTION, \T_CLOSURE ) );
121 121
 
122
-		if ( \T_VARIABLE === $token['code']
123
-			&& ( '$GLOBALS' === $token['content']
122
+		if ( \T_VARIABLE === $token[ 'code' ]
123
+			&& ( '$GLOBALS' === $token[ 'content' ]
124 124
 				|| ( false === $in_function_scope && false === $this->treat_files_as_scoped ) )
125 125
 		) {
126 126
 			return $this->process_variable_assignment( $stackPtr );
127
-		} elseif ( \T_GLOBAL === $token['code']
127
+		} elseif ( \T_GLOBAL === $token[ 'code' ]
128 128
 			&& ( true === $in_function_scope || true === $this->treat_files_as_scoped )
129 129
 		) {
130 130
 			return $this->process_global_statement( $stackPtr, $in_function_scope );
@@ -147,34 +147,34 @@  discard block
 block discarded – undo
147 147
 		}
148 148
 
149 149
 		$token    = $this->tokens[ $stackPtr ];
150
-		$var_name = substr( $token['content'], 1 ); // Strip the dollar sign.
150
+		$var_name = substr( $token[ 'content' ], 1 ); // Strip the dollar sign.
151 151
 		$data     = array();
152 152
 
153 153
 		// Determine the variable name for `$GLOBALS['array_key']`.
154 154
 		if ( 'GLOBALS' === $var_name ) {
155 155
 			$bracketPtr = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true );
156 156
 
157
-			if ( false === $bracketPtr || \T_OPEN_SQUARE_BRACKET !== $this->tokens[ $bracketPtr ]['code'] || ! isset( $this->tokens[ $bracketPtr ]['bracket_closer'] ) ) {
157
+			if ( false === $bracketPtr || \T_OPEN_SQUARE_BRACKET !== $this->tokens[ $bracketPtr ][ 'code' ] || ! isset( $this->tokens[ $bracketPtr ][ 'bracket_closer' ] ) ) {
158 158
 				return;
159 159
 			}
160 160
 
161 161
 			// Retrieve the array key and avoid getting tripped up by some simple obfuscation.
162 162
 			$var_name = '';
163 163
 			$start    = ( $bracketPtr + 1 );
164
-			for ( $ptr = $start; $ptr < $this->tokens[ $bracketPtr ]['bracket_closer']; $ptr++ ) {
164
+			for ( $ptr = $start; $ptr < $this->tokens[ $bracketPtr ][ 'bracket_closer' ]; $ptr++ ) {
165 165
 				/*
166 166
 				 * If the globals array key contains a variable, constant, function call
167 167
 				 * or interpolated variable, bow out.
168 168
 				 */
169
-				if ( \T_VARIABLE === $this->tokens[ $ptr ]['code']
170
-					|| \T_STRING === $this->tokens[ $ptr ]['code']
171
-					|| \T_DOUBLE_QUOTED_STRING === $this->tokens[ $ptr ]['code']
169
+				if ( \T_VARIABLE === $this->tokens[ $ptr ][ 'code' ]
170
+					|| \T_STRING === $this->tokens[ $ptr ][ 'code' ]
171
+					|| \T_DOUBLE_QUOTED_STRING === $this->tokens[ $ptr ][ 'code' ]
172 172
 				) {
173 173
 					return;
174 174
 				}
175 175
 
176
-				if ( \T_CONSTANT_ENCAPSED_STRING === $this->tokens[ $ptr ]['code'] ) {
177
-					$var_name .= $this->strip_quotes( $this->tokens[ $ptr ]['content'] );
176
+				if ( \T_CONSTANT_ENCAPSED_STRING === $this->tokens[ $ptr ][ 'code' ] ) {
177
+					$var_name .= $this->strip_quotes( $this->tokens[ $ptr ][ 'content' ] );
178 178
 				}
179 179
 			}
180 180
 
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 			}
185 185
 
186 186
 			// Set up the data for the error message.
187
-			$data[] = '$GLOBALS[\'' . $var_name . '\']';
187
+			$data[ ] = '$GLOBALS[\'' . $var_name . '\']';
188 188
 		}
189 189
 
190 190
 		/*
@@ -207,11 +207,11 @@  discard block
 block discarded – undo
207 207
 		 * Function parameters with the same name as a WP global variable are fine,
208 208
 		 * including when they are being assigned a default value.
209 209
 		 */
210
-		if ( isset( $this->tokens[ $stackPtr ]['nested_parenthesis'] ) ) {
211
-			foreach ( $this->tokens[ $stackPtr ]['nested_parenthesis'] as $opener => $closer ) {
212
-				if ( isset( $this->tokens[ $opener ]['parenthesis_owner'] )
213
-					&& ( \T_FUNCTION === $this->tokens[ $this->tokens[ $opener ]['parenthesis_owner'] ]['code']
214
-						|| \T_CLOSURE === $this->tokens[ $this->tokens[ $opener ]['parenthesis_owner'] ]['code'] )
210
+		if ( isset( $this->tokens[ $stackPtr ][ 'nested_parenthesis' ] ) ) {
211
+			foreach ( $this->tokens[ $stackPtr ][ 'nested_parenthesis' ] as $opener => $closer ) {
212
+				if ( isset( $this->tokens[ $opener ][ 'parenthesis_owner' ] )
213
+					&& ( \T_FUNCTION === $this->tokens[ $this->tokens[ $opener ][ 'parenthesis_owner' ] ][ 'code' ]
214
+						|| \T_CLOSURE === $this->tokens[ $this->tokens[ $opener ][ 'parenthesis_owner' ] ][ 'code' ] )
215 215
 				) {
216 216
 					return;
217 217
 				}
@@ -251,13 +251,13 @@  discard block
 block discarded – undo
251 251
 			$var = $this->tokens[ $ptr ];
252 252
 
253 253
 			// Halt the loop at end of statement.
254
-			if ( \T_SEMICOLON === $var['code'] ) {
254
+			if ( \T_SEMICOLON === $var[ 'code' ] ) {
255 255
 				break;
256 256
 			}
257 257
 
258
-			if ( \T_VARIABLE === $var['code'] ) {
259
-				if ( isset( $this->wp_globals[ substr( $var['content'], 1 ) ] ) ) {
260
-					$search[] = $var['content'];
258
+			if ( \T_VARIABLE === $var[ 'code' ] ) {
259
+				if ( isset( $this->wp_globals[ substr( $var[ 'content' ], 1 ) ] ) ) {
260
+					$search[ ] = $var[ 'content' ];
261 261
 				}
262 262
 			}
263 263
 
@@ -277,11 +277,11 @@  discard block
 block discarded – undo
277 277
 			$function_cond = $this->phpcsFile->getCondition( $stackPtr, \T_FUNCTION );
278 278
 			$closure_cond  = $this->phpcsFile->getCondition( $stackPtr, \T_CLOSURE );
279 279
 			$scope_cond    = max( $function_cond, $closure_cond ); // If false, it will evaluate as zero, so this is fine.
280
-			if ( isset( $this->tokens[ $scope_cond ]['scope_closer'] ) === false ) {
280
+			if ( isset( $this->tokens[ $scope_cond ][ 'scope_closer' ] ) === false ) {
281 281
 				// Live coding or parse error.
282 282
 				return;
283 283
 			}
284
-			$end = $this->tokens[ $scope_cond ]['scope_closer'];
284
+			$end = $this->tokens[ $scope_cond ][ 'scope_closer' ];
285 285
 		} else {
286 286
 			// Global statement in the global namespace with file is being treated as scoped.
287 287
 			$end = ( $this->phpcsFile->numTokens + 1 );
@@ -290,21 +290,21 @@  discard block
 block discarded – undo
290 290
 		for ( $ptr = $start; $ptr < $end; $ptr++ ) {
291 291
 
292 292
 			// Skip over nested functions, classes and the likes.
293
-			if ( isset( $this->skip_over[ $this->tokens[ $ptr ]['code'] ] ) ) {
294
-				if ( ! isset( $this->tokens[ $ptr ]['scope_closer'] ) ) {
293
+			if ( isset( $this->skip_over[ $this->tokens[ $ptr ][ 'code' ] ] ) ) {
294
+				if ( ! isset( $this->tokens[ $ptr ][ 'scope_closer' ] ) ) {
295 295
 					// Live coding or parse error.
296 296
 					break;
297 297
 				}
298 298
 
299
-				$ptr = $this->tokens[ $ptr ]['scope_closer'];
299
+				$ptr = $this->tokens[ $ptr ][ 'scope_closer' ];
300 300
 				continue;
301 301
 			}
302 302
 
303
-			if ( \T_VARIABLE !== $this->tokens[ $ptr ]['code'] ) {
303
+			if ( \T_VARIABLE !== $this->tokens[ $ptr ][ 'code' ] ) {
304 304
 				continue;
305 305
 			}
306 306
 
307
-			if ( \in_array( $this->tokens[ $ptr ]['content'], $search, true ) === false ) {
307
+			if ( \in_array( $this->tokens[ $ptr ][ 'content' ], $search, true ) === false ) {
308 308
 				// Not one of the variables we're interested in.
309 309
 				continue;
310 310
 			}
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
 	 */
358 358
 	protected function add_error( $stackPtr, $data = array() ) {
359 359
 		if ( empty( $data ) ) {
360
-			$data[] = $this->tokens[ $stackPtr ]['content'];
360
+			$data[ ] = $this->tokens[ $stackPtr ][ 'content' ];
361 361
 		}
362 362
 
363 363
 		$this->phpcsFile->addError(
Please login to merge, or discard this patch.
wpcs/WordPress/Sniffs/WP/DeprecatedParametersSniff.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 			}
291 291
 
292 292
 			// The list will need to updated if the default value is not supported.
293
-			switch ( $parameters[ $position ]['raw'] ) {
293
+			switch ( $parameters[ $position ][ 'raw' ] ) {
294 294
 				case 'true':
295 295
 					$matched_parameter = true;
296 296
 					break;
@@ -305,28 +305,28 @@  discard block
 block discarded – undo
305 305
 					$matched_parameter = array();
306 306
 					break;
307 307
 				default:
308
-					$matched_parameter = $this->strip_quotes( $parameters[ $position ]['raw'] );
308
+					$matched_parameter = $this->strip_quotes( $parameters[ $position ][ 'raw' ] );
309 309
 					break;
310 310
 			}
311 311
 
312
-			if ( $parameter_args['value'] === $matched_parameter ) {
312
+			if ( $parameter_args[ 'value' ] === $matched_parameter ) {
313 313
 				continue;
314 314
 			}
315 315
 
316 316
 			$message  = 'The parameter "%s" at position #%s of %s() has been deprecated since WordPress version %s.';
317
-			$is_error = version_compare( $parameter_args['version'], $this->minimum_supported_version, '<' );
317
+			$is_error = version_compare( $parameter_args[ 'version' ], $this->minimum_supported_version, '<' );
318 318
 			$code     = $this->string_to_errorcode( ucfirst( $matched_content ) . 'Param' . $position . 'Found' );
319 319
 
320 320
 			$data = array(
321
-				$parameters[ $position ]['raw'],
321
+				$parameters[ $position ][ 'raw' ],
322 322
 				$position,
323 323
 				$matched_content,
324
-				$parameter_args['version'],
324
+				$parameter_args[ 'version' ],
325 325
 			);
326 326
 
327
-			if ( isset( $parameter_args['value'] ) && $position < $paramCount ) {
327
+			if ( isset( $parameter_args[ 'value' ] ) && $position < $paramCount ) {
328 328
 				$message .= ' Use "%s" instead.';
329
-				$data[]   = (string) $parameter_args['value'];
329
+				$data[ ]   = (string)$parameter_args[ 'value' ];
330 330
 			} else {
331 331
 				$message .= ' Instead do not pass the parameter.';
332 332
 			}
Please login to merge, or discard this patch.
wpcs/WordPress/Sniffs/WP/I18nSniff.php 1 patch
Spacing   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -229,8 +229,8 @@  discard block
 block discarded – undo
229 229
 
230 230
 		$func_open_paren_token = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $stack_ptr + 1 ), null, true );
231 231
 		if ( false === $func_open_paren_token
232
-			|| \T_OPEN_PARENTHESIS !== $this->tokens[ $func_open_paren_token ]['code']
233
-			|| ! isset( $this->tokens[ $func_open_paren_token ]['parenthesis_closer'] )
232
+			|| \T_OPEN_PARENTHESIS !== $this->tokens[ $func_open_paren_token ][ 'code' ]
233
+			|| ! isset( $this->tokens[ $func_open_paren_token ][ 'parenthesis_closer' ] )
234 234
 		) {
235 235
 			// Live coding, parse error or not a function call.
236 236
 			return;
@@ -250,128 +250,128 @@  discard block
 block discarded – undo
250 250
 		$tokens           = $this->tokens;
251 251
 
252 252
 		// Look at arguments.
253
-		for ( $i = ( $func_open_paren_token + 1 ); $i < $this->tokens[ $func_open_paren_token ]['parenthesis_closer']; $i++ ) {
253
+		for ( $i = ( $func_open_paren_token + 1 ); $i < $this->tokens[ $func_open_paren_token ][ 'parenthesis_closer' ]; $i++ ) {
254 254
 			$this_token                = $this->tokens[ $i ];
255
-			$this_token['token_index'] = $i;
256
-			if ( isset( Tokens::$emptyTokens[ $this_token['code'] ] ) ) {
255
+			$this_token[ 'token_index' ] = $i;
256
+			if ( isset( Tokens::$emptyTokens[ $this_token[ 'code' ] ] ) ) {
257 257
 				continue;
258 258
 			}
259
-			if ( \T_COMMA === $this_token['code'] ) {
260
-				$arguments_tokens[] = $argument_tokens;
259
+			if ( \T_COMMA === $this_token[ 'code' ] ) {
260
+				$arguments_tokens[ ] = $argument_tokens;
261 261
 				$argument_tokens    = array();
262 262
 				continue;
263 263
 			}
264 264
 
265 265
 			// Merge consecutive single or double quoted strings (when they span multiple lines).
266
-			if ( isset( Tokens::$textStringTokens[ $this_token['code'] ] ) ) {
267
-				for ( $j = ( $i + 1 ); $j < $this->tokens[ $func_open_paren_token ]['parenthesis_closer']; $j++ ) {
268
-					if ( $this_token['code'] === $this->tokens[ $j ]['code'] ) {
269
-						$this_token['content'] .= $this->tokens[ $j ]['content'];
266
+			if ( isset( Tokens::$textStringTokens[ $this_token[ 'code' ] ] ) ) {
267
+				for ( $j = ( $i + 1 ); $j < $this->tokens[ $func_open_paren_token ][ 'parenthesis_closer' ]; $j++ ) {
268
+					if ( $this_token[ 'code' ] === $this->tokens[ $j ][ 'code' ] ) {
269
+						$this_token[ 'content' ] .= $this->tokens[ $j ][ 'content' ];
270 270
 						$i                      = $j;
271 271
 					} else {
272 272
 						break;
273 273
 					}
274 274
 				}
275 275
 			}
276
-			$argument_tokens[] = $this_token;
276
+			$argument_tokens[ ] = $this_token;
277 277
 
278 278
 			// Include everything up to and including the parenthesis_closer if this token has one.
279
-			if ( ! empty( $this_token['parenthesis_closer'] ) ) {
280
-				for ( $j = ( $i + 1 ); $j <= $this_token['parenthesis_closer']; $j++ ) {
281
-					$tokens[ $j ]['token_index'] = $j;
282
-					$argument_tokens[]           = $tokens[ $j ];
279
+			if ( ! empty( $this_token[ 'parenthesis_closer' ] ) ) {
280
+				for ( $j = ( $i + 1 ); $j <= $this_token[ 'parenthesis_closer' ]; $j++ ) {
281
+					$tokens[ $j ][ 'token_index' ] = $j;
282
+					$argument_tokens[ ]           = $tokens[ $j ];
283 283
 				}
284
-				$i = $this_token['parenthesis_closer'];
284
+				$i = $this_token[ 'parenthesis_closer' ];
285 285
 			}
286 286
 		}
287 287
 
288 288
 		if ( ! empty( $argument_tokens ) ) {
289
-			$arguments_tokens[] = $argument_tokens;
289
+			$arguments_tokens[ ] = $argument_tokens;
290 290
 		}
291 291
 		unset( $argument_tokens );
292 292
 
293 293
 		$argument_assertions = array();
294 294
 		if ( 'simple' === $this->i18n_functions[ $matched_content ] ) {
295
-			$argument_assertions[] = array(
295
+			$argument_assertions[ ] = array(
296 296
 				'arg_name' => 'text',
297 297
 				'tokens'   => array_shift( $arguments_tokens ),
298 298
 			);
299
-			$argument_assertions[] = array(
299
+			$argument_assertions[ ] = array(
300 300
 				'arg_name' => 'domain',
301 301
 				'tokens'   => array_shift( $arguments_tokens ),
302 302
 			);
303 303
 		} elseif ( 'context' === $this->i18n_functions[ $matched_content ] ) {
304
-			$argument_assertions[] = array(
304
+			$argument_assertions[ ] = array(
305 305
 				'arg_name' => 'text',
306 306
 				'tokens'   => array_shift( $arguments_tokens ),
307 307
 			);
308
-			$argument_assertions[] = array(
308
+			$argument_assertions[ ] = array(
309 309
 				'arg_name' => 'context',
310 310
 				'tokens'   => array_shift( $arguments_tokens ),
311 311
 			);
312
-			$argument_assertions[] = array(
312
+			$argument_assertions[ ] = array(
313 313
 				'arg_name' => 'domain',
314 314
 				'tokens'   => array_shift( $arguments_tokens ),
315 315
 			);
316 316
 		} elseif ( 'number' === $this->i18n_functions[ $matched_content ] ) {
317
-			$argument_assertions[] = array(
317
+			$argument_assertions[ ] = array(
318 318
 				'arg_name' => 'single',
319 319
 				'tokens'   => array_shift( $arguments_tokens ),
320 320
 			);
321
-			$argument_assertions[] = array(
321
+			$argument_assertions[ ] = array(
322 322
 				'arg_name' => 'plural',
323 323
 				'tokens'   => array_shift( $arguments_tokens ),
324 324
 			);
325 325
 			array_shift( $arguments_tokens );
326
-			$argument_assertions[] = array(
326
+			$argument_assertions[ ] = array(
327 327
 				'arg_name' => 'domain',
328 328
 				'tokens'   => array_shift( $arguments_tokens ),
329 329
 			);
330 330
 		} elseif ( 'number_context' === $this->i18n_functions[ $matched_content ] ) {
331
-			$argument_assertions[] = array(
331
+			$argument_assertions[ ] = array(
332 332
 				'arg_name' => 'single',
333 333
 				'tokens'   => array_shift( $arguments_tokens ),
334 334
 			);
335
-			$argument_assertions[] = array(
335
+			$argument_assertions[ ] = array(
336 336
 				'arg_name' => 'plural',
337 337
 				'tokens'   => array_shift( $arguments_tokens ),
338 338
 			);
339 339
 			array_shift( $arguments_tokens );
340
-			$argument_assertions[] = array(
340
+			$argument_assertions[ ] = array(
341 341
 				'arg_name' => 'context',
342 342
 				'tokens'   => array_shift( $arguments_tokens ),
343 343
 			);
344
-			$argument_assertions[] = array(
344
+			$argument_assertions[ ] = array(
345 345
 				'arg_name' => 'domain',
346 346
 				'tokens'   => array_shift( $arguments_tokens ),
347 347
 			);
348 348
 		} elseif ( 'noopnumber' === $this->i18n_functions[ $matched_content ] ) {
349
-			$argument_assertions[] = array(
349
+			$argument_assertions[ ] = array(
350 350
 				'arg_name' => 'single',
351 351
 				'tokens'   => array_shift( $arguments_tokens ),
352 352
 			);
353
-			$argument_assertions[] = array(
353
+			$argument_assertions[ ] = array(
354 354
 				'arg_name' => 'plural',
355 355
 				'tokens'   => array_shift( $arguments_tokens ),
356 356
 			);
357
-			$argument_assertions[] = array(
357
+			$argument_assertions[ ] = array(
358 358
 				'arg_name' => 'domain',
359 359
 				'tokens'   => array_shift( $arguments_tokens ),
360 360
 			);
361 361
 		} elseif ( 'noopnumber_context' === $this->i18n_functions[ $matched_content ] ) {
362
-			$argument_assertions[] = array(
362
+			$argument_assertions[ ] = array(
363 363
 				'arg_name' => 'single',
364 364
 				'tokens'   => array_shift( $arguments_tokens ),
365 365
 			);
366
-			$argument_assertions[] = array(
366
+			$argument_assertions[ ] = array(
367 367
 				'arg_name' => 'plural',
368 368
 				'tokens'   => array_shift( $arguments_tokens ),
369 369
 			);
370
-			$argument_assertions[] = array(
370
+			$argument_assertions[ ] = array(
371 371
 				'arg_name' => 'context',
372 372
 				'tokens'   => array_shift( $arguments_tokens ),
373 373
 			);
374
-			$argument_assertions[] = array(
374
+			$argument_assertions[ ] = array(
375 375
 				'arg_name' => 'domain',
376 376
 				'tokens'   => array_shift( $arguments_tokens ),
377 377
 			);
@@ -382,18 +382,18 @@  discard block
 block discarded – undo
382 382
 		}
383 383
 
384 384
 		foreach ( $argument_assertions as $argument_assertion_context ) {
385
-			if ( empty( $argument_assertion_context['tokens'][0] ) ) {
386
-				$argument_assertion_context['stack_ptr'] = $func_open_paren_token;
385
+			if ( empty( $argument_assertion_context[ 'tokens' ][ 0 ] ) ) {
386
+				$argument_assertion_context[ 'stack_ptr' ] = $func_open_paren_token;
387 387
 			} else {
388
-				$argument_assertion_context['stack_ptr'] = $argument_assertion_context['tokens'][0]['token_index'];
388
+				$argument_assertion_context[ 'stack_ptr' ] = $argument_assertion_context[ 'tokens' ][ 0 ][ 'token_index' ];
389 389
 			}
390 390
 			$this->check_argument_tokens( $argument_assertion_context );
391 391
 		}
392 392
 
393 393
 		// For _n*() calls, compare the singular and plural strings.
394 394
 		if ( false !== strpos( $this->i18n_functions[ $matched_content ], 'number' ) ) {
395
-			$single_context = $argument_assertions[0];
396
-			$plural_context = $argument_assertions[1];
395
+			$single_context = $argument_assertions[ 0 ];
396
+			$plural_context = $argument_assertions[ 1 ];
397 397
 
398 398
 			$this->compare_single_and_plural_arguments( $stack_ptr, $single_context, $plural_context );
399 399
 		}
@@ -410,11 +410,11 @@  discard block
 block discarded – undo
410 410
 	 * @return bool
411 411
 	 */
412 412
 	protected function check_argument_tokens( $context ) {
413
-		$stack_ptr = $context['stack_ptr'];
414
-		$tokens    = $context['tokens'];
415
-		$arg_name  = $context['arg_name'];
416
-		$is_error  = empty( $context['warning'] );
417
-		$content   = isset( $tokens[0] ) ? $tokens[0]['content'] : '';
413
+		$stack_ptr = $context[ 'stack_ptr' ];
414
+		$tokens    = $context[ 'tokens' ];
415
+		$arg_name  = $context[ 'arg_name' ];
416
+		$is_error  = empty( $context[ 'warning' ] );
417
+		$content   = isset( $tokens[ 0 ] ) ? $tokens[ 0 ][ 'content' ] : '';
418 418
 
419 419
 		if ( empty( $tokens ) || 0 === \count( $tokens ) ) {
420 420
 			$code = $this->string_to_errorcode( 'MissingArg' . ucfirst( $arg_name ) );
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
 		if ( \count( $tokens ) > 1 ) {
446 446
 			$contents = '';
447 447
 			foreach ( $tokens as $token ) {
448
-				$contents .= $token['content'];
448
+				$contents .= $token[ 'content' ];
449 449
 			}
450 450
 			$code = $this->string_to_errorcode( 'NonSingularStringLiteral' . ucfirst( $arg_name ) );
451 451
 			$this->addMessage( 'The $%s arg must be a single string literal, not "%s".', $stack_ptr, $is_error, $code, array( $arg_name, $contents ) );
@@ -456,7 +456,7 @@  discard block
 block discarded – undo
456 456
 			$this->check_text( $context );
457 457
 		}
458 458
 
459
-		if ( \T_DOUBLE_QUOTED_STRING === $tokens[0]['code'] || \T_HEREDOC === $tokens[0]['code'] ) {
459
+		if ( \T_DOUBLE_QUOTED_STRING === $tokens[ 0 ][ 'code' ] || \T_HEREDOC === $tokens[ 0 ][ 'code' ] ) {
460 460
 			$interpolated_variables = $this->get_interpolated_variables( $content );
461 461
 			foreach ( $interpolated_variables as $interpolated_variable ) {
462 462
 				$code = $this->string_to_errorcode( 'InterpolatedVariable' . ucfirst( $arg_name ) );
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
 			}
468 468
 		}
469 469
 
470
-		if ( isset( Tokens::$textStringTokens[ $tokens[0]['code'] ] ) ) {
470
+		if ( isset( Tokens::$textStringTokens[ $tokens[ 0 ][ 'code' ] ] ) ) {
471 471
 			if ( 'domain' === $arg_name && ! empty( $this->text_domain ) ) {
472 472
 				$stripped_content = $this->strip_quotes( $content );
473 473
 
@@ -487,9 +487,9 @@  discard block
 block discarded – undo
487 487
 					$error      = 'No need to supply the text domain when the only accepted text domain is "default".';
488 488
 					$error_code = 'SuperfluousDefaultTextDomain';
489 489
 
490
-					if ( $tokens[0]['token_index'] === $stack_ptr ) {
490
+					if ( $tokens[ 0 ][ 'token_index' ] === $stack_ptr ) {
491 491
 						$prev = $this->phpcsFile->findPrevious( \T_WHITESPACE, ( $stack_ptr - 1 ), null, true );
492
-						if ( false !== $prev && \T_COMMA === $this->tokens[ $prev ]['code'] ) {
492
+						if ( false !== $prev && \T_COMMA === $this->tokens[ $prev ][ 'code' ] ) {
493 493
 							$fixable = true;
494 494
 						}
495 495
 					}
@@ -530,20 +530,20 @@  discard block
 block discarded – undo
530 530
 	 * @return void
531 531
 	 */
532 532
 	protected function compare_single_and_plural_arguments( $stack_ptr, $single_context, $plural_context ) {
533
-		$single_content = $single_context['tokens'][0]['content'];
534
-		$plural_content = $plural_context['tokens'][0]['content'];
533
+		$single_content = $single_context[ 'tokens' ][ 0 ][ 'content' ];
534
+		$plural_content = $plural_context[ 'tokens' ][ 0 ][ 'content' ];
535 535
 
536 536
 		preg_match_all( self::SPRINTF_PLACEHOLDER_REGEX, $single_content, $single_placeholders );
537
-		$single_placeholders = $single_placeholders[0];
537
+		$single_placeholders = $single_placeholders[ 0 ];
538 538
 
539 539
 		preg_match_all( self::SPRINTF_PLACEHOLDER_REGEX, $plural_content, $plural_placeholders );
540
-		$plural_placeholders = $plural_placeholders[0];
540
+		$plural_placeholders = $plural_placeholders[ 0 ];
541 541
 
542 542
 		// English conflates "singular" with "only one", described in the codex:
543 543
 		// https://codex.wordpress.org/I18n_for_WordPress_Developers#Plurals .
544 544
 		if ( \count( $single_placeholders ) < \count( $plural_placeholders ) ) {
545 545
 			$error_string = 'Missing singular placeholder, needed for some languages. See https://codex.wordpress.org/I18n_for_WordPress_Developers#Plurals';
546
-			$single_index = $single_context['tokens'][0]['token_index'];
546
+			$single_index = $single_context[ 'tokens' ][ 0 ][ 'token_index' ];
547 547
 
548 548
 			$this->phpcsFile->addError( $error_string, $single_index, 'MissingSingularPlaceholder' );
549 549
 		}
@@ -564,14 +564,14 @@  discard block
 block discarded – undo
564 564
 	 * @return void
565 565
 	 */
566 566
 	protected function check_text( $context ) {
567
-		$stack_ptr = $context['stack_ptr'];
568
-		$arg_name  = $context['arg_name'];
569
-		$content   = $context['tokens'][0]['content'];
570
-		$is_error  = empty( $context['warning'] );
567
+		$stack_ptr = $context[ 'stack_ptr' ];
568
+		$arg_name  = $context[ 'arg_name' ];
569
+		$content   = $context[ 'tokens' ][ 0 ][ 'content' ];
570
+		$is_error  = empty( $context[ 'warning' ] );
571 571
 
572 572
 		// UnorderedPlaceholders: Check for multiple unordered placeholders.
573 573
 		$unordered_matches_count = preg_match_all( self::UNORDERED_SPRINTF_PLACEHOLDER_REGEX, $content, $unordered_matches );
574
-		$unordered_matches       = $unordered_matches[0];
574
+		$unordered_matches       = $unordered_matches[ 0 ];
575 575
 		$all_matches_count       = preg_match_all( self::SPRINTF_PLACEHOLDER_REGEX, $content, $all_matches );
576 576
 
577 577
 		if ( $unordered_matches_count > 0 && $unordered_matches_count !== $all_matches_count && $all_matches_count > 1 ) {
@@ -580,7 +580,7 @@  discard block
 block discarded – undo
580 580
 				'Multiple placeholders should be ordered. Mix of ordered and non-ordered placeholders found. Found: %s.',
581 581
 				$stack_ptr,
582 582
 				$code,
583
-				array( implode( ', ', $all_matches[0] ) )
583
+				array( implode( ', ', $all_matches[ 0 ] ) )
584 584
 			);
585 585
 
586 586
 		} elseif ( $unordered_matches_count >= 2 ) {
@@ -591,7 +591,7 @@  discard block
 block discarded – undo
591 591
 			$replacements    = array();
592 592
 			for ( $i = 0; $i < $unordered_matches_count; $i++ ) {
593 593
 				$to_insert         = ( $i + 1 );
594
-				$to_insert        .= ( '"' !== $content[0] ) ? '$' : '\$';
594
+				$to_insert        .= ( '"' !== $content[ 0 ] ) ? '$' : '\$';
595 595
 				$suggestions[ $i ] = substr_replace( $unordered_matches[ $i ], $to_insert, 1, 0 );
596 596
 
597 597
 				// Prepare the strings for use a regex.
@@ -639,20 +639,20 @@  discard block
 block discarded – undo
639 639
 	 */
640 640
 	protected function check_for_translator_comment( $stack_ptr, $args ) {
641 641
 		foreach ( $args as $arg ) {
642
-			if ( false === \in_array( $arg['arg_name'], array( 'text', 'single', 'plural' ), true ) ) {
642
+			if ( false === \in_array( $arg[ 'arg_name' ], array( 'text', 'single', 'plural' ), true ) ) {
643 643
 				continue;
644 644
 			}
645 645
 
646
-			if ( empty( $arg['tokens'] ) ) {
646
+			if ( empty( $arg[ 'tokens' ] ) ) {
647 647
 				continue;
648 648
 			}
649 649
 
650
-			foreach ( $arg['tokens'] as $token ) {
651
-				if ( empty( $token['content'] ) ) {
650
+			foreach ( $arg[ 'tokens' ] as $token ) {
651
+				if ( empty( $token[ 'content' ] ) ) {
652 652
 					continue;
653 653
 				}
654 654
 
655
-				if ( preg_match( self::SPRINTF_PLACEHOLDER_REGEX, $token['content'], $placeholders ) < 1 ) {
655
+				if ( preg_match( self::SPRINTF_PLACEHOLDER_REGEX, $token[ 'content' ], $placeholders ) < 1 ) {
656 656
 					// No placeholders found.
657 657
 					continue;
658 658
 				}
@@ -666,11 +666,11 @@  discard block
 block discarded – undo
666 666
 					 */
667 667
 					$correctly_placed = false;
668 668
 
669
-					if ( ( $this->tokens[ $previous_comment ]['line'] + 1 ) === $this->tokens[ $stack_ptr ]['line'] ) {
669
+					if ( ( $this->tokens[ $previous_comment ][ 'line' ] + 1 ) === $this->tokens[ $stack_ptr ][ 'line' ] ) {
670 670
 						$correctly_placed = true;
671 671
 					} else {
672 672
 						$next_non_whitespace = $this->phpcsFile->findNext( \T_WHITESPACE, ( $previous_comment + 1 ), $stack_ptr, true );
673
-						if ( false === $next_non_whitespace || $this->tokens[ $next_non_whitespace ]['line'] === $this->tokens[ $stack_ptr ]['line'] ) {
673
+						if ( false === $next_non_whitespace || $this->tokens[ $next_non_whitespace ][ 'line' ] === $this->tokens[ $stack_ptr ][ 'line' ] ) {
674 674
 							// No non-whitespace found or next non-whitespace is on same line as gettext call.
675 675
 							$correctly_placed = true;
676 676
 						}
@@ -682,17 +682,17 @@  discard block
 block discarded – undo
682 682
 					 */
683 683
 					if ( true === $correctly_placed ) {
684 684
 
685
-						if ( \T_COMMENT === $this->tokens[ $previous_comment ]['code'] ) {
686
-							$comment_text = trim( $this->tokens[ $previous_comment ]['content'] );
685
+						if ( \T_COMMENT === $this->tokens[ $previous_comment ][ 'code' ] ) {
686
+							$comment_text = trim( $this->tokens[ $previous_comment ][ 'content' ] );
687 687
 
688 688
 							// If it's multi-line /* */ comment, collect all the parts.
689 689
 							if ( '*/' === substr( $comment_text, -2 ) && '/*' !== substr( $comment_text, 0, 2 ) ) {
690 690
 								for ( $i = ( $previous_comment - 1 ); 0 <= $i; $i-- ) {
691
-									if ( \T_COMMENT !== $this->tokens[ $i ]['code'] ) {
691
+									if ( \T_COMMENT !== $this->tokens[ $i ][ 'code' ] ) {
692 692
 										break;
693 693
 									}
694 694
 
695
-									$comment_text = trim( $this->tokens[ $i ]['content'] ) . $comment_text;
695
+									$comment_text = trim( $this->tokens[ $i ][ 'content' ] ) . $comment_text;
696 696
 								}
697 697
 							}
698 698
 
@@ -700,12 +700,12 @@  discard block
 block discarded – undo
700 700
 								// Comment is ok.
701 701
 								return;
702 702
 							}
703
-						} elseif ( \T_DOC_COMMENT_CLOSE_TAG === $this->tokens[ $previous_comment ]['code'] ) {
703
+						} elseif ( \T_DOC_COMMENT_CLOSE_TAG === $this->tokens[ $previous_comment ][ 'code' ] ) {
704 704
 							// If it's docblock comment (wrong style) make sure that it's a translators comment.
705 705
 							$db_start      = $this->phpcsFile->findPrevious( \T_DOC_COMMENT_OPEN_TAG, ( $previous_comment - 1 ) );
706 706
 							$db_first_text = $this->phpcsFile->findNext( \T_DOC_COMMENT_STRING, ( $db_start + 1 ), $previous_comment );
707 707
 
708
-							if ( true === $this->is_translators_comment( $this->tokens[ $db_first_text ]['content'] ) ) {
708
+							if ( true === $this->is_translators_comment( $this->tokens[ $db_first_text ][ 'content' ] ) ) {
709 709
 								$this->phpcsFile->addWarning(
710 710
 									'A "translators:" comment must be a "/* */" style comment. Docblock comments will not be picked up by the tools to generate a ".pot" file.',
711 711
 									$stack_ptr,
Please login to merge, or discard this patch.