Completed
Pull Request — develop (#1492)
by Zack
28:58 queued 09:00
created
wpcs/WordPress/Sniffs/NamingConventions/PrefixAllGlobalsSniff.php 1 patch
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -195,10 +195,10 @@  discard block
 block discarded – undo
195 195
 	public function register() {
196 196
 		// Get a list of all PHP native functions.
197 197
 		$all_functions            = get_defined_functions();
198
-		$this->built_in_functions = array_flip( $all_functions['internal'] );
198
+		$this->built_in_functions = array_flip( $all_functions[ 'internal' ] );
199 199
 
200 200
 		// Set the sniff targets.
201
-		$targets  = array(
201
+		$targets = array(
202 202
 			\T_NAMESPACE => \T_NAMESPACE,
203 203
 			\T_FUNCTION  => \T_FUNCTION,
204 204
 			\T_CONST     => \T_CONST,
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 		// Add function call target for hook names and constants defined using define().
211 211
 		$parent = parent::register();
212 212
 		if ( ! empty( $parent ) ) {
213
-			$targets[] = \T_STRING;
213
+			$targets[ ] = \T_STRING;
214 214
 		}
215 215
 
216 216
 		return $targets;
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 	 */
226 226
 	public function getGroups() {
227 227
 		$this->target_functions           = $this->hookInvokeFunctions;
228
-		$this->target_functions['define'] = true;
228
+		$this->target_functions[ 'define' ] = true;
229 229
 
230 230
 		return parent::getGroups();
231 231
 	}
@@ -273,36 +273,36 @@  discard block
 block discarded – undo
273 273
 		}
274 274
 
275 275
 		// Ignore test classes.
276
-		if ( isset( Tokens::$ooScopeTokens[ $this->tokens[ $stackPtr ]['code'] ] )
276
+		if ( isset( Tokens::$ooScopeTokens[ $this->tokens[ $stackPtr ][ 'code' ] ] )
277 277
 			&& true === $this->is_test_class( $stackPtr )
278 278
 		) {
279
-			if ( $this->tokens[ $stackPtr ]['scope_condition'] === $stackPtr && isset( $this->tokens[ $stackPtr ]['scope_closer'] ) ) {
279
+			if ( $this->tokens[ $stackPtr ][ 'scope_condition' ] === $stackPtr && isset( $this->tokens[ $stackPtr ][ 'scope_closer' ] ) ) {
280 280
 				// Skip forward to end of test class.
281
-				return $this->tokens[ $stackPtr ]['scope_closer'];
281
+				return $this->tokens[ $stackPtr ][ 'scope_closer' ];
282 282
 			}
283 283
 			return;
284 284
 		}
285 285
 
286
-		if ( \T_ANON_CLASS === $this->tokens[ $stackPtr ]['code'] ) {
286
+		if ( \T_ANON_CLASS === $this->tokens[ $stackPtr ][ 'code' ] ) {
287 287
 			// Token was only registered to allow skipping over test classes.
288 288
 			return;
289 289
 		}
290 290
 
291
-		if ( \T_STRING === $this->tokens[ $stackPtr ]['code'] ) {
291
+		if ( \T_STRING === $this->tokens[ $stackPtr ][ 'code' ] ) {
292 292
 			// Disallow excluding function groups for this sniff.
293 293
 			$this->exclude = array();
294 294
 
295 295
 			return parent::process_token( $stackPtr );
296 296
 
297
-		} elseif ( \T_DOLLAR === $this->tokens[ $stackPtr ]['code'] ) {
297
+		} elseif ( \T_DOLLAR === $this->tokens[ $stackPtr ][ 'code' ] ) {
298 298
 
299 299
 			return $this->process_variable_variable( $stackPtr );
300 300
 
301
-		} elseif ( \T_VARIABLE === $this->tokens[ $stackPtr ]['code'] ) {
301
+		} elseif ( \T_VARIABLE === $this->tokens[ $stackPtr ][ 'code' ] ) {
302 302
 
303 303
 			return $this->process_variable_assignment( $stackPtr );
304 304
 
305
-		} elseif ( \T_NAMESPACE === $this->tokens[ $stackPtr ]['code'] ) {
305
+		} elseif ( \T_NAMESPACE === $this->tokens[ $stackPtr ][ 'code' ] ) {
306 306
 			$namespace_name = $this->get_declared_namespace_name( $stackPtr );
307 307
 
308 308
 			if ( false === $namespace_name || '' === $namespace_name || '\\' === $namespace_name ) {
@@ -310,14 +310,14 @@  discard block
 block discarded – undo
310 310
 			}
311 311
 
312 312
 			foreach ( $this->validated_namespace_prefixes as $key => $prefix_info ) {
313
-				if ( false === $prefix_info['is_regex'] ) {
314
-					if ( stripos( $namespace_name, $prefix_info['prefix'] ) === 0 ) {
313
+				if ( false === $prefix_info[ 'is_regex' ] ) {
314
+					if ( stripos( $namespace_name, $prefix_info[ 'prefix' ] ) === 0 ) {
315 315
 						$this->phpcsFile->recordMetric( $stackPtr, 'Prefix all globals: allowed prefixes', $key );
316 316
 						return;
317 317
 					}
318 318
 				} else {
319 319
 					// Ok, so this prefix should be used as a regex.
320
-					$regex = '`^' . $prefix_info['prefix'] . '`i';
320
+					$regex = '`^' . $prefix_info[ 'prefix' ] . '`i';
321 321
 					if ( preg_match( $regex, $namespace_name ) > 0 ) {
322 322
 						$this->phpcsFile->recordMetric( $stackPtr, 'Prefix all globals: allowed prefixes', $key );
323 323
 						return;
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
 			$error_text = 'Unknown syntax used';
355 355
 			$error_code = 'NonPrefixedSyntaxFound';
356 356
 
357
-			switch ( $this->tokens[ $stackPtr ]['type'] ) {
357
+			switch ( $this->tokens[ $stackPtr ][ 'type' ] ) {
358 358
 				case 'T_FUNCTION':
359 359
 					// Methods in a class do not need to be prefixed.
360 360
 					if ( $this->phpcsFile->hasCondition( $stackPtr, Tokens::$ooScopeTokens ) === true ) {
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
 					$error_text = 'Classes declared';
379 379
 					$error_code = 'NonPrefixedClassFound';
380 380
 
381
-					switch ( $this->tokens[ $stackPtr ]['type'] ) {
381
+					switch ( $this->tokens[ $stackPtr ][ 'type' ] ) {
382 382
 						case 'T_CLASS':
383 383
 							if ( class_exists( '\\' . $item_name, false ) ) {
384 384
 								// Backfill for PHP native class.
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
 						return;
427 427
 					}
428 428
 
429
-					$item_name = $this->tokens[ $constant_name_ptr ]['content'];
429
+					$item_name = $this->tokens[ $constant_name_ptr ][ 'content' ];
430 430
 					if ( \defined( '\\' . $item_name ) ) {
431 431
 						// Backfill for PHP native constant.
432 432
 						return;
@@ -486,26 +486,26 @@  discard block
 block discarded – undo
486 486
 		// Is this a variable variable ?
487 487
 		// Not concerned with nested ones as those will be recognized on their own token.
488 488
 		$next_non_empty = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true, null, true );
489
-		if ( false === $next_non_empty || ! isset( $indicators[ $this->tokens[ $next_non_empty ]['code'] ] ) ) {
489
+		if ( false === $next_non_empty || ! isset( $indicators[ $this->tokens[ $next_non_empty ][ 'code' ] ] ) ) {
490 490
 			return;
491 491
 		}
492 492
 
493
-		if ( \T_OPEN_CURLY_BRACKET === $this->tokens[ $next_non_empty ]['code']
494
-			&& isset( $this->tokens[ $next_non_empty ]['bracket_closer'] )
493
+		if ( \T_OPEN_CURLY_BRACKET === $this->tokens[ $next_non_empty ][ 'code' ]
494
+			&& isset( $this->tokens[ $next_non_empty ][ 'bracket_closer' ] )
495 495
 		) {
496 496
 			// Skip over the variable part.
497
-			$next_non_empty = $this->tokens[ $next_non_empty ]['bracket_closer'];
497
+			$next_non_empty = $this->tokens[ $next_non_empty ][ 'bracket_closer' ];
498 498
 		}
499 499
 
500 500
 		$maybe_assignment = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $next_non_empty + 1 ), null, true, null, true );
501 501
 
502 502
 		while ( false !== $maybe_assignment
503
-			&& \T_OPEN_SQUARE_BRACKET === $this->tokens[ $maybe_assignment ]['code']
504
-			&& isset( $this->tokens[ $maybe_assignment ]['bracket_closer'] )
503
+			&& \T_OPEN_SQUARE_BRACKET === $this->tokens[ $maybe_assignment ][ 'code' ]
504
+			&& isset( $this->tokens[ $maybe_assignment ][ 'bracket_closer' ] )
505 505
 		) {
506 506
 			$maybe_assignment = $this->phpcsFile->findNext(
507 507
 				Tokens::$emptyTokens,
508
-				( $this->tokens[ $maybe_assignment ]['bracket_closer'] + 1 ),
508
+				( $this->tokens[ $maybe_assignment ][ 'bracket_closer' ] + 1 ),
509 509
 				null,
510 510
 				true,
511 511
 				null,
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
 			return;
518 518
 		}
519 519
 
520
-		if ( ! isset( Tokens::$assignmentTokens[ $this->tokens[ $maybe_assignment ]['code'] ] ) ) {
520
+		if ( ! isset( Tokens::$assignmentTokens[ $this->tokens[ $maybe_assignment ][ 'code' ] ] ) ) {
521 521
 			// Not an assignment.
522 522
 			return;
523 523
 		}
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
 				$condition = $this->phpcsFile->getCondition( $stackPtr, \T_CLOSURE );
539 539
 			}
540 540
 
541
-			$has_global = $this->phpcsFile->findPrevious( \T_GLOBAL, ( $stackPtr - 1 ), $this->tokens[ $condition ]['scope_opener'] );
541
+			$has_global = $this->phpcsFile->findPrevious( \T_GLOBAL, ( $stackPtr - 1 ), $this->tokens[ $condition ][ 'scope_opener' ] );
542 542
 			if ( false === $has_global ) {
543 543
 				// No variable import happening.
544 544
 				return;
@@ -592,7 +592,7 @@  discard block
 block discarded – undo
592 592
 		}
593 593
 
594 594
 		$is_error      = true;
595
-		$variable_name = substr( $this->tokens[ $stackPtr ]['content'], 1 ); // Strip the dollar sign.
595
+		$variable_name = substr( $this->tokens[ $stackPtr ][ 'content' ], 1 ); // Strip the dollar sign.
596 596
 
597 597
 		// Bow out early if we know for certain no prefix is needed.
598 598
 		if ( $this->variable_prefixed_or_whitelisted( $stackPtr, $variable_name ) === true ) {
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 
602 602
 		if ( 'GLOBALS' === $variable_name ) {
603 603
 			$array_open = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true, null, true );
604
-			if ( false === $array_open || \T_OPEN_SQUARE_BRACKET !== $this->tokens[ $array_open ]['code'] ) {
604
+			if ( false === $array_open || \T_OPEN_SQUARE_BRACKET !== $this->tokens[ $array_open ][ 'code' ] ) {
605 605
 				// Live coding or something very silly.
606 606
 				return;
607 607
 			}
@@ -613,20 +613,20 @@  discard block
 block discarded – undo
613 613
 			}
614 614
 
615 615
 			$stackPtr      = $array_key;
616
-			$variable_name = $this->strip_quotes( $this->tokens[ $array_key ]['content'] );
616
+			$variable_name = $this->strip_quotes( $this->tokens[ $array_key ][ 'content' ] );
617 617
 
618 618
 			// Check whether a prefix is needed.
619
-			if ( isset( Tokens::$stringTokens[ $this->tokens[ $array_key ]['code'] ] )
619
+			if ( isset( Tokens::$stringTokens[ $this->tokens[ $array_key ][ 'code' ] ] )
620 620
 				&& $this->variable_prefixed_or_whitelisted( $stackPtr, $variable_name ) === true
621 621
 			) {
622 622
 				return;
623 623
 			}
624 624
 
625
-			if ( \T_DOUBLE_QUOTED_STRING === $this->tokens[ $array_key ]['code'] ) {
625
+			if ( \T_DOUBLE_QUOTED_STRING === $this->tokens[ $array_key ][ 'code' ] ) {
626 626
 				// If the array key is a double quoted string, try again with only
627 627
 				// the part before the first variable (if any).
628 628
 				$exploded = explode( '$', $variable_name );
629
-				$first    = rtrim( $exploded[0], '{' );
629
+				$first    = rtrim( $exploded[ 0 ], '{' );
630 630
 				if ( '' !== $first ) {
631 631
 					if ( $this->variable_prefixed_or_whitelisted( $array_key, $first ) === true ) {
632 632
 						return;
@@ -635,17 +635,17 @@  discard block
 block discarded – undo
635 635
 					// If the first part was dynamic, throw a warning.
636 636
 					$is_error = false;
637 637
 				}
638
-			} elseif ( ! isset( Tokens::$stringTokens[ $this->tokens[ $array_key ]['code'] ] ) ) {
638
+			} elseif ( ! isset( Tokens::$stringTokens[ $this->tokens[ $array_key ][ 'code' ] ] ) ) {
639 639
 				// Dynamic array key, throw a warning.
640 640
 				$is_error = false;
641 641
 			}
642 642
 		} else {
643 643
 			// Function parameters do not need to be prefixed.
644
-			if ( isset( $this->tokens[ $stackPtr ]['nested_parenthesis'] ) ) {
645
-				foreach ( $this->tokens[ $stackPtr ]['nested_parenthesis'] as $opener => $closer ) {
646
-					if ( isset( $this->tokens[ $opener ]['parenthesis_owner'] )
647
-						&& ( \T_FUNCTION === $this->tokens[ $this->tokens[ $opener ]['parenthesis_owner'] ]['code']
648
-							|| \T_CLOSURE === $this->tokens[ $this->tokens[ $opener ]['parenthesis_owner'] ]['code'] )
644
+			if ( isset( $this->tokens[ $stackPtr ][ 'nested_parenthesis' ] ) ) {
645
+				foreach ( $this->tokens[ $stackPtr ][ 'nested_parenthesis' ] as $opener => $closer ) {
646
+					if ( isset( $this->tokens[ $opener ][ 'parenthesis_owner' ] )
647
+						&& ( \T_FUNCTION === $this->tokens[ $this->tokens[ $opener ][ 'parenthesis_owner' ] ][ 'code' ]
648
+							|| \T_CLOSURE === $this->tokens[ $this->tokens[ $opener ][ 'parenthesis_owner' ] ][ 'code' ] )
649 649
 					) {
650 650
 						return;
651 651
 					}
@@ -665,7 +665,7 @@  discard block
 block discarded – undo
665 665
 					$condition = $this->phpcsFile->getCondition( $stackPtr, \T_CLOSURE );
666 666
 				}
667 667
 
668
-				$has_global = $this->phpcsFile->findPrevious( \T_GLOBAL, ( $stackPtr - 1 ), $this->tokens[ $condition ]['scope_opener'] );
668
+				$has_global = $this->phpcsFile->findPrevious( \T_GLOBAL, ( $stackPtr - 1 ), $this->tokens[ $condition ][ 'scope_opener' ] );
669 669
 				if ( false === $has_global ) {
670 670
 					// No variable import happening.
671 671
 					return;
@@ -688,7 +688,7 @@  discard block
 block discarded – undo
688 688
 						return;
689 689
 					}
690 690
 
691
-					if ( substr( $this->tokens[ $ptr ]['content'], 1 ) === $variable_name ) {
691
+					if ( substr( $this->tokens[ $ptr ][ 'content' ], 1 ) === $variable_name ) {
692 692
 						break;
693 693
 					}
694 694
 				}
@@ -735,12 +735,12 @@  discard block
 block discarded – undo
735 735
 		}
736 736
 
737 737
 		// No matter whether it is a constant definition or a hook call, both use the first parameter.
738
-		if ( ! isset( $parameters[1] ) ) {
738
+		if ( ! isset( $parameters[ 1 ] ) ) {
739 739
 			return;
740 740
 		}
741 741
 
742 742
 		$is_error    = true;
743
-		$raw_content = $this->strip_quotes( $parameters[1]['raw'] );
743
+		$raw_content = $this->strip_quotes( $parameters[ 1 ][ 'raw' ] );
744 744
 
745 745
 		if ( ( 'define' !== $matched_content
746 746
 			&& isset( $this->whitelisted_core_hooks[ $raw_content ] ) )
@@ -750,14 +750,14 @@  discard block
 block discarded – undo
750 750
 			return;
751 751
 		}
752 752
 
753
-		if ( $this->is_prefixed( $parameters[1]['start'], $raw_content ) === true ) {
753
+		if ( $this->is_prefixed( $parameters[ 1 ][ 'start' ], $raw_content ) === true ) {
754 754
 			return;
755 755
 		} else {
756 756
 			// This may be a dynamic hook/constant name.
757 757
 			$first_non_empty = $this->phpcsFile->findNext(
758 758
 				Tokens::$emptyTokens,
759
-				$parameters[1]['start'],
760
-				( $parameters[1]['end'] + 1 ),
759
+				$parameters[ 1 ][ 'start' ],
760
+				( $parameters[ 1 ][ 'end' ] + 1 ),
761 761
 				true
762 762
 			);
763 763
 
@@ -765,29 +765,29 @@  discard block
 block discarded – undo
765 765
 				return;
766 766
 			}
767 767
 
768
-			$first_non_empty_content = $this->strip_quotes( $this->tokens[ $first_non_empty ]['content'] );
768
+			$first_non_empty_content = $this->strip_quotes( $this->tokens[ $first_non_empty ][ 'content' ] );
769 769
 
770 770
 			// Try again with just the first token if it's a text string.
771
-			if ( isset( Tokens::$stringTokens[ $this->tokens[ $first_non_empty ]['code'] ] )
772
-				&& $this->is_prefixed( $parameters[1]['start'], $first_non_empty_content ) === true
771
+			if ( isset( Tokens::$stringTokens[ $this->tokens[ $first_non_empty ][ 'code' ] ] )
772
+				&& $this->is_prefixed( $parameters[ 1 ][ 'start' ], $first_non_empty_content ) === true
773 773
 			) {
774 774
 				return;
775 775
 			}
776 776
 
777
-			if ( \T_DOUBLE_QUOTED_STRING === $this->tokens[ $first_non_empty ]['code'] ) {
777
+			if ( \T_DOUBLE_QUOTED_STRING === $this->tokens[ $first_non_empty ][ 'code' ] ) {
778 778
 				// If the first part of the parameter is a double quoted string, try again with only
779 779
 				// the part before the first variable (if any).
780 780
 				$exploded = explode( '$', $first_non_empty_content );
781
-				$first    = rtrim( $exploded[0], '{' );
781
+				$first    = rtrim( $exploded[ 0 ], '{' );
782 782
 				if ( '' !== $first ) {
783
-					if ( $this->is_prefixed( $parameters[1]['start'], $first ) === true ) {
783
+					if ( $this->is_prefixed( $parameters[ 1 ][ 'start' ], $first ) === true ) {
784 784
 						return;
785 785
 					}
786 786
 				} else {
787 787
 					// Start of hook/constant name is dynamic, throw a warning.
788 788
 					$is_error = false;
789 789
 				}
790
-			} elseif ( ! isset( Tokens::$stringTokens[ $this->tokens[ $first_non_empty ]['code'] ] ) ) {
790
+			} elseif ( ! isset( Tokens::$stringTokens[ $this->tokens[ $first_non_empty ][ 'code' ] ] ) ) {
791 791
 				// Dynamic hook/constant name, throw a warning.
792 792
 				$is_error = false;
793 793
 			}
@@ -817,7 +817,7 @@  discard block
 block discarded – undo
817 817
 			}
818 818
 		}
819 819
 
820
-		$data[] = $raw_content;
820
+		$data[ ] = $raw_content;
821 821
 
822 822
 		$recorded = $this->addMessage( self::ERROR_MSG, $first_non_empty, $is_error, $error_code, $data );
823 823
 
@@ -959,9 +959,9 @@  discard block
 block discarded – undo
959 959
 	 */
960 960
 	private function record_potential_prefix_metric( $stackPtr, $construct_name ) {
961 961
 		if ( preg_match( '`^([A-Z]*[a-z0-9]*+)`', ltrim( $construct_name, '\$_' ), $matches ) > 0
962
-			&& isset( $matches[1] ) && '' !== $matches[1]
962
+			&& isset( $matches[ 1 ] ) && '' !== $matches[ 1 ]
963 963
 		) {
964
-			$this->phpcsFile->recordMetric( $stackPtr, 'Prefix all globals: potential prefixes - start of non-prefixed construct', strtolower( $matches[1] ) );
964
+			$this->phpcsFile->recordMetric( $stackPtr, 'Prefix all globals: potential prefixes - start of non-prefixed construct', strtolower( $matches[ 1 ] ) );
965 965
 		}
966 966
 	}
967 967
 }
Please login to merge, or discard this patch.
wpcs/WordPress/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php 1 patch
Spacing   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -111,11 +111,11 @@  discard block
 block discarded – undo
111 111
 	 * @return void
112 112
 	 */
113 113
 	public function process_token( $stackPtr ) {
114
-		$this->spaces_before_closure_open_paren = (int) $this->spaces_before_closure_open_paren;
114
+		$this->spaces_before_closure_open_paren = (int)$this->spaces_before_closure_open_paren;
115 115
 
116
-		if ( isset( $this->tokens[ ( $stackPtr + 1 ) ] ) && \T_WHITESPACE !== $this->tokens[ ( $stackPtr + 1 ) ]['code']
117
-			&& ! ( \T_ELSE === $this->tokens[ $stackPtr ]['code'] && \T_COLON === $this->tokens[ ( $stackPtr + 1 ) ]['code'] )
118
-			&& ! ( \T_CLOSURE === $this->tokens[ $stackPtr ]['code']
116
+		if ( isset( $this->tokens[ ( $stackPtr + 1 ) ] ) && \T_WHITESPACE !== $this->tokens[ ( $stackPtr + 1 ) ][ 'code' ]
117
+			&& ! ( \T_ELSE === $this->tokens[ $stackPtr ][ 'code' ] && \T_COLON === $this->tokens[ ( $stackPtr + 1 ) ][ 'code' ] )
118
+			&& ! ( \T_CLOSURE === $this->tokens[ $stackPtr ][ 'code' ]
119 119
 				&& 0 >= $this->spaces_before_closure_open_paren )
120 120
 		) {
121 121
 			$error = 'Space after opening control structure is required';
@@ -126,25 +126,25 @@  discard block
 block discarded – undo
126 126
 			}
127 127
 		}
128 128
 
129
-		if ( ! isset( $this->tokens[ $stackPtr ]['scope_closer'] ) ) {
129
+		if ( ! isset( $this->tokens[ $stackPtr ][ 'scope_closer' ] ) ) {
130 130
 
131
-			if ( \T_USE === $this->tokens[ $stackPtr ]['code'] && 'closure' === $this->get_use_type( $stackPtr ) ) {
131
+			if ( \T_USE === $this->tokens[ $stackPtr ][ 'code' ] && 'closure' === $this->get_use_type( $stackPtr ) ) {
132 132
 				$scopeOpener = $this->phpcsFile->findNext( \T_OPEN_CURLY_BRACKET, ( $stackPtr + 1 ) );
133
-				$scopeCloser = $this->tokens[ $scopeOpener ]['scope_closer'];
134
-			} elseif ( \T_WHILE !== $this->tokens[ $stackPtr ]['code'] ) {
133
+				$scopeCloser = $this->tokens[ $scopeOpener ][ 'scope_closer' ];
134
+			} elseif ( \T_WHILE !== $this->tokens[ $stackPtr ][ 'code' ] ) {
135 135
 				return;
136 136
 			}
137 137
 		} else {
138
-			$scopeOpener = $this->tokens[ $stackPtr ]['scope_opener'];
139
-			$scopeCloser = $this->tokens[ $stackPtr ]['scope_closer'];
138
+			$scopeOpener = $this->tokens[ $stackPtr ][ 'scope_opener' ];
139
+			$scopeCloser = $this->tokens[ $stackPtr ][ 'scope_closer' ];
140 140
 		}
141 141
 
142 142
 		// Alternative syntax.
143
-		if ( isset( $scopeOpener ) && \T_COLON === $this->tokens[ $scopeOpener ]['code'] ) {
143
+		if ( isset( $scopeOpener ) && \T_COLON === $this->tokens[ $scopeOpener ][ 'code' ] ) {
144 144
 
145 145
 			if ( 'required' === $this->space_before_colon ) {
146 146
 
147
-				if ( \T_WHITESPACE !== $this->tokens[ ( $scopeOpener - 1 ) ]['code'] ) {
147
+				if ( \T_WHITESPACE !== $this->tokens[ ( $scopeOpener - 1 ) ][ 'code' ] ) {
148 148
 					$error = 'Space between opening control structure and T_COLON is required';
149 149
 					$fix   = $this->phpcsFile->addFixableError( $error, $scopeOpener, 'NoSpaceBetweenStructureColon' );
150 150
 
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 				}
155 155
 			} elseif ( 'forbidden' === $this->space_before_colon ) {
156 156
 
157
-				if ( \T_WHITESPACE === $this->tokens[ ( $scopeOpener - 1 ) ]['code'] ) {
157
+				if ( \T_WHITESPACE === $this->tokens[ ( $scopeOpener - 1 ) ][ 'code' ] ) {
158 158
 					$error = 'Extra space between opening control structure and T_COLON found';
159 159
 					$fix   = $this->phpcsFile->addFixableError( $error, ( $scopeOpener - 1 ), 'SpaceBetweenStructureColon' );
160 160
 
@@ -168,13 +168,13 @@  discard block
 block discarded – undo
168 168
 		$parenthesisOpener = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true );
169 169
 
170 170
 		// If this is a function declaration.
171
-		if ( \T_FUNCTION === $this->tokens[ $stackPtr ]['code'] ) {
171
+		if ( \T_FUNCTION === $this->tokens[ $stackPtr ][ 'code' ] ) {
172 172
 
173
-			if ( \T_STRING === $this->tokens[ $parenthesisOpener ]['code'] ) {
173
+			if ( \T_STRING === $this->tokens[ $parenthesisOpener ][ 'code' ] ) {
174 174
 
175 175
 				$function_name_ptr = $parenthesisOpener;
176 176
 
177
-			} elseif ( \T_BITWISE_AND === $this->tokens[ $parenthesisOpener ]['code'] ) {
177
+			} elseif ( \T_BITWISE_AND === $this->tokens[ $parenthesisOpener ][ 'code' ] ) {
178 178
 
179 179
 				// This function returns by reference (function &function_name() {}).
180 180
 				$parenthesisOpener = $this->phpcsFile->findNext(
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 						$error,
203 203
 						$stackPtr,
204 204
 						'SpaceBeforeFunctionOpenParenthesis',
205
-						$this->tokens[ ( $function_name_ptr + 1 ) ]['content']
205
+						$this->tokens[ ( $function_name_ptr + 1 ) ][ 'content' ]
206 206
 					);
207 207
 
208 208
 					if ( true === $fix ) {
@@ -210,14 +210,14 @@  discard block
 block discarded – undo
210 210
 					}
211 211
 				}
212 212
 			}
213
-		} elseif ( \T_CLOSURE === $this->tokens[ $stackPtr ]['code'] ) {
213
+		} elseif ( \T_CLOSURE === $this->tokens[ $stackPtr ][ 'code' ] ) {
214 214
 
215 215
 			// Check if there is a use () statement.
216
-			if ( isset( $this->tokens[ $parenthesisOpener ]['parenthesis_closer'] ) ) {
216
+			if ( isset( $this->tokens[ $parenthesisOpener ][ 'parenthesis_closer' ] ) ) {
217 217
 
218 218
 				$usePtr = $this->phpcsFile->findNext(
219 219
 					Tokens::$emptyTokens,
220
-					( $this->tokens[ $parenthesisOpener ]['parenthesis_closer'] + 1 ),
220
+					( $this->tokens[ $parenthesisOpener ][ 'parenthesis_closer' ] + 1 ),
221 221
 					null,
222 222
 					true,
223 223
 					null,
@@ -225,17 +225,17 @@  discard block
 block discarded – undo
225 225
 				);
226 226
 
227 227
 				// If it is, we set that as the "scope opener".
228
-				if ( \T_USE === $this->tokens[ $usePtr ]['code'] ) {
228
+				if ( \T_USE === $this->tokens[ $usePtr ][ 'code' ] ) {
229 229
 					$scopeOpener = $usePtr;
230 230
 				}
231 231
 			}
232 232
 		}
233 233
 
234
-		if ( \T_COLON !== $this->tokens[ $parenthesisOpener ]['code']
235
-			&& \T_FUNCTION !== $this->tokens[ $stackPtr ]['code']
234
+		if ( \T_COLON !== $this->tokens[ $parenthesisOpener ][ 'code' ]
235
+			&& \T_FUNCTION !== $this->tokens[ $stackPtr ][ 'code' ]
236 236
 		) {
237 237
 
238
-			if ( \T_CLOSURE === $this->tokens[ $stackPtr ]['code']
238
+			if ( \T_CLOSURE === $this->tokens[ $stackPtr ][ 'code' ]
239 239
 				&& 0 === $this->spaces_before_closure_open_paren
240 240
 			) {
241 241
 
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 				}
251 251
 			} elseif (
252 252
 				(
253
-					\T_CLOSURE !== $this->tokens[ $stackPtr ]['code']
253
+					\T_CLOSURE !== $this->tokens[ $stackPtr ][ 'code' ]
254 254
 					|| 1 === $this->spaces_before_closure_open_paren
255 255
 				)
256 256
 				&& ( $stackPtr + 1 ) === $parenthesisOpener
@@ -266,8 +266,8 @@  discard block
 block discarded – undo
266 266
 			}
267 267
 		}
268 268
 
269
-		if ( \T_WHITESPACE === $this->tokens[ ( $stackPtr + 1 ) ]['code']
270
-			&& ' ' !== $this->tokens[ ( $stackPtr + 1 ) ]['content']
269
+		if ( \T_WHITESPACE === $this->tokens[ ( $stackPtr + 1 ) ][ 'code' ]
270
+			&& ' ' !== $this->tokens[ ( $stackPtr + 1 ) ][ 'content' ]
271 271
 		) {
272 272
 			// Checking this: if [*](...) {}.
273 273
 			$error = 'Expected exactly one space before opening parenthesis; "%s" found.';
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 				$error,
276 276
 				$stackPtr,
277 277
 				'ExtraSpaceBeforeOpenParenthesis',
278
-				$this->tokens[ ( $stackPtr + 1 ) ]['content']
278
+				$this->tokens[ ( $stackPtr + 1 ) ][ 'content' ]
279 279
 			);
280 280
 
281 281
 			if ( true === $fix ) {
@@ -283,8 +283,8 @@  discard block
 block discarded – undo
283 283
 			}
284 284
 		}
285 285
 
286
-		if ( \T_CLOSE_PARENTHESIS !== $this->tokens[ ( $parenthesisOpener + 1 ) ]['code'] ) {
287
-			if ( \T_WHITESPACE !== $this->tokens[ ( $parenthesisOpener + 1 ) ]['code'] ) {
286
+		if ( \T_CLOSE_PARENTHESIS !== $this->tokens[ ( $parenthesisOpener + 1 ) ][ 'code' ] ) {
287
+			if ( \T_WHITESPACE !== $this->tokens[ ( $parenthesisOpener + 1 ) ][ 'code' ] ) {
288 288
 				// Checking this: $value = my_function([*]...).
289 289
 				$error = 'No space after opening parenthesis is prohibited';
290 290
 				$fix   = $this->phpcsFile->addFixableError( $error, $stackPtr, 'NoSpaceAfterOpenParenthesis' );
@@ -292,10 +292,10 @@  discard block
 block discarded – undo
292 292
 				if ( true === $fix ) {
293 293
 					$this->phpcsFile->fixer->addContent( $parenthesisOpener, ' ' );
294 294
 				}
295
-			} elseif ( ( ' ' !== $this->tokens[ ( $parenthesisOpener + 1 ) ]['content']
296
-				&& "\n" !== $this->tokens[ ( $parenthesisOpener + 1 ) ]['content']
297
-				&& "\r\n" !== $this->tokens[ ( $parenthesisOpener + 1 ) ]['content'] )
298
-				&& ! isset( $this->ignore_extra_space_after_open_paren[ $this->tokens[ $stackPtr ]['code'] ] )
295
+			} elseif ( ( ' ' !== $this->tokens[ ( $parenthesisOpener + 1 ) ][ 'content' ]
296
+				&& "\n" !== $this->tokens[ ( $parenthesisOpener + 1 ) ][ 'content' ]
297
+				&& "\r\n" !== $this->tokens[ ( $parenthesisOpener + 1 ) ][ 'content' ] )
298
+				&& ! isset( $this->ignore_extra_space_after_open_paren[ $this->tokens[ $stackPtr ][ 'code' ] ] )
299 299
 			) {
300 300
 				// Checking this: if ([*]...) {}.
301 301
 				$error = 'Expected exactly one space after opening parenthesis; "%s" found.';
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
 					$error,
304 304
 					$stackPtr,
305 305
 					'ExtraSpaceAfterOpenParenthesis',
306
-					$this->tokens[ ( $parenthesisOpener + 1 ) ]['content']
306
+					$this->tokens[ ( $parenthesisOpener + 1 ) ][ 'content' ]
307 307
 				);
308 308
 
309 309
 				if ( true === $fix ) {
@@ -312,29 +312,29 @@  discard block
 block discarded – undo
312 312
 			}
313 313
 		}
314 314
 
315
-		if ( isset( $this->tokens[ $parenthesisOpener ]['parenthesis_closer'] ) ) {
315
+		if ( isset( $this->tokens[ $parenthesisOpener ][ 'parenthesis_closer' ] ) ) {
316 316
 
317
-			$parenthesisCloser = $this->tokens[ $parenthesisOpener ]['parenthesis_closer'];
317
+			$parenthesisCloser = $this->tokens[ $parenthesisOpener ][ 'parenthesis_closer' ];
318 318
 
319
-			if ( \T_CLOSE_PARENTHESIS !== $this->tokens[ ( $parenthesisOpener + 1 ) ]['code'] ) {
319
+			if ( \T_CLOSE_PARENTHESIS !== $this->tokens[ ( $parenthesisOpener + 1 ) ][ 'code' ] ) {
320 320
 
321 321
 				// Checking this: if (...[*]) {}.
322
-				if ( \T_WHITESPACE !== $this->tokens[ ( $parenthesisCloser - 1 ) ]['code'] ) {
322
+				if ( \T_WHITESPACE !== $this->tokens[ ( $parenthesisCloser - 1 ) ][ 'code' ] ) {
323 323
 					$error = 'No space before closing parenthesis is prohibited';
324 324
 					$fix   = $this->phpcsFile->addFixableError( $error, $parenthesisCloser, 'NoSpaceBeforeCloseParenthesis' );
325 325
 
326 326
 					if ( true === $fix ) {
327 327
 						$this->phpcsFile->fixer->addContentBefore( $parenthesisCloser, ' ' );
328 328
 					}
329
-				} elseif ( ' ' !== $this->tokens[ ( $parenthesisCloser - 1 ) ]['content'] ) {
329
+				} elseif ( ' ' !== $this->tokens[ ( $parenthesisCloser - 1 ) ][ 'content' ] ) {
330 330
 					$prevNonEmpty = $this->phpcsFile->findPrevious( Tokens::$emptyTokens, ( $parenthesisCloser - 1 ), null, true );
331
-					if ( $this->tokens[ ( $parenthesisCloser ) ]['line'] === $this->tokens[ ( $prevNonEmpty + 1 ) ]['line'] ) {
331
+					if ( $this->tokens[ ( $parenthesisCloser ) ][ 'line' ] === $this->tokens[ ( $prevNonEmpty + 1 ) ][ 'line' ] ) {
332 332
 						$error = 'Expected exactly one space before closing parenthesis; "%s" found.';
333 333
 						$fix   = $this->phpcsFile->addFixableError(
334 334
 							$error,
335 335
 							$stackPtr,
336 336
 							'ExtraSpaceBeforeCloseParenthesis',
337
-							$this->tokens[ ( $parenthesisCloser - 1 ) ]['content']
337
+							$this->tokens[ ( $parenthesisCloser - 1 ) ][ 'content' ]
338 338
 						);
339 339
 
340 340
 						if ( true === $fix ) {
@@ -343,12 +343,12 @@  discard block
 block discarded – undo
343 343
 					}
344 344
 				}
345 345
 
346
-				if ( \T_WHITESPACE !== $this->tokens[ ( $parenthesisCloser + 1 ) ]['code']
346
+				if ( \T_WHITESPACE !== $this->tokens[ ( $parenthesisCloser + 1 ) ][ 'code' ]
347 347
 					&& ! ( // Do NOT flag : immediately following ) for return types declarations.
348
-						\T_COLON === $this->tokens[ ( $parenthesisCloser + 1 ) ]['code']
349
-						&& in_array( $this->tokens[ $this->tokens[ $parenthesisCloser ]['parenthesis_owner'] ]['code'], array( \T_FUNCTION, \T_CLOSURE ), true )
348
+						\T_COLON === $this->tokens[ ( $parenthesisCloser + 1 ) ][ 'code' ]
349
+						&& in_array( $this->tokens[ $this->tokens[ $parenthesisCloser ][ 'parenthesis_owner' ] ][ 'code' ], array( \T_FUNCTION, \T_CLOSURE ), true )
350 350
 					)
351
-					&& ( isset( $scopeOpener ) && \T_COLON !== $this->tokens[ $scopeOpener ]['code'] )
351
+					&& ( isset( $scopeOpener ) && \T_COLON !== $this->tokens[ $scopeOpener ][ 'code' ] )
352 352
 				) {
353 353
 					$error = 'Space between opening control structure and closing parenthesis is required';
354 354
 					$fix   = $this->phpcsFile->addFixableError( $error, $scopeOpener, 'NoSpaceAfterCloseParenthesis' );
@@ -360,11 +360,11 @@  discard block
 block discarded – undo
360 360
 			}
361 361
 
362 362
 			// Ignore this for function declarations. Handled by the OpeningFunctionBraceKernighanRitchie sniff.
363
-			if ( \T_FUNCTION !== $this->tokens[ $stackPtr ]['code']
364
-				&& \T_CLOSURE !== $this->tokens[ $stackPtr ]['code']
365
-				&& isset( $this->tokens[ $parenthesisOpener ]['parenthesis_owner'] )
363
+			if ( \T_FUNCTION !== $this->tokens[ $stackPtr ][ 'code' ]
364
+				&& \T_CLOSURE !== $this->tokens[ $stackPtr ][ 'code' ]
365
+				&& isset( $this->tokens[ $parenthesisOpener ][ 'parenthesis_owner' ] )
366 366
 				&& ( isset( $scopeOpener )
367
-				&& $this->tokens[ $parenthesisCloser ]['line'] !== $this->tokens[ $scopeOpener ]['line'] )
367
+				&& $this->tokens[ $parenthesisCloser ][ 'line' ] !== $this->tokens[ $scopeOpener ][ 'line' ] )
368 368
 			) {
369 369
 				$error = 'Opening brace should be on the same line as the declaration';
370 370
 				$fix   = $this->phpcsFile->addFixableError( $error, $parenthesisOpener, 'OpenBraceNotSameLine' );
@@ -381,8 +381,8 @@  discard block
 block discarded – undo
381 381
 				}
382 382
 				return;
383 383
 
384
-			} elseif ( \T_WHITESPACE === $this->tokens[ ( $parenthesisCloser + 1 ) ]['code']
385
-				&& ' ' !== $this->tokens[ ( $parenthesisCloser + 1 ) ]['content']
384
+			} elseif ( \T_WHITESPACE === $this->tokens[ ( $parenthesisCloser + 1 ) ][ 'code' ]
385
+				&& ' ' !== $this->tokens[ ( $parenthesisCloser + 1 ) ][ 'content' ]
386 386
 			) {
387 387
 
388 388
 				// Checking this: if (...) [*]{}.
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
 					$error,
392 392
 					$stackPtr,
393 393
 					'ExtraSpaceAfterCloseParenthesis',
394
-					$this->tokens[ ( $parenthesisCloser + 1 ) ]['content']
394
+					$this->tokens[ ( $parenthesisCloser + 1 ) ][ 'content' ]
395 395
 				);
396 396
 
397 397
 				if ( true === $fix ) {
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
 			$firstContent = $this->phpcsFile->findNext( \T_WHITESPACE, ( $scopeOpener + 1 ), null, true );
405 405
 
406 406
 			// We ignore spacing for some structures that tend to have their own rules.
407
-			$ignore  = array(
407
+			$ignore = array(
408 408
 				\T_FUNCTION             => true,
409 409
 				\T_CLOSURE              => true,
410 410
 				\T_DOC_COMMENT_OPEN_TAG => true,
@@ -413,8 +413,8 @@  discard block
 block discarded – undo
413 413
 			);
414 414
 			$ignore += Tokens::$ooScopeTokens;
415 415
 
416
-			if ( ! isset( $ignore[ $this->tokens[ $firstContent ]['code'] ] )
417
-				&& $this->tokens[ $firstContent ]['line'] > ( $this->tokens[ $scopeOpener ]['line'] + 1 )
416
+			if ( ! isset( $ignore[ $this->tokens[ $firstContent ][ 'code' ] ] )
417
+				&& $this->tokens[ $firstContent ][ 'line' ] > ( $this->tokens[ $scopeOpener ][ 'line' ] + 1 )
418 418
 			) {
419 419
 				$error = 'Blank line found at start of control structure';
420 420
 				$fix   = $this->phpcsFile->addFixableError( $error, $scopeOpener, 'BlankLineAfterStart' );
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
 					$this->phpcsFile->fixer->beginChangeset();
424 424
 
425 425
 					for ( $i = ( $scopeOpener + 1 ); $i < $firstContent; $i++ ) {
426
-						if ( $this->tokens[ $i ]['line'] === $this->tokens[ $firstContent ]['line'] ) {
426
+						if ( $this->tokens[ $i ][ 'line' ] === $this->tokens[ $firstContent ][ 'line' ] ) {
427 427
 							break;
428 428
 						}
429 429
 						$this->phpcsFile->fixer->replaceToken( $i, '' );
@@ -440,16 +440,16 @@  discard block
 block discarded – undo
440 440
 				$lastNonEmptyContent = $this->phpcsFile->findPrevious( Tokens::$emptyTokens, ( $scopeCloser - 1 ), null, true );
441 441
 
442 442
 				$checkToken = $lastContent;
443
-				if ( isset( $this->tokens[ $lastNonEmptyContent ]['scope_condition'] ) ) {
444
-					$checkToken = $this->tokens[ $lastNonEmptyContent ]['scope_condition'];
443
+				if ( isset( $this->tokens[ $lastNonEmptyContent ][ 'scope_condition' ] ) ) {
444
+					$checkToken = $this->tokens[ $lastNonEmptyContent ][ 'scope_condition' ];
445 445
 				}
446 446
 
447
-				if ( ! isset( $ignore[ $this->tokens[ $checkToken ]['code'] ] )
448
-					&& $this->tokens[ $lastContent ]['line'] <= ( $this->tokens[ $scopeCloser ]['line'] - 2 )
447
+				if ( ! isset( $ignore[ $this->tokens[ $checkToken ][ 'code' ] ] )
448
+					&& $this->tokens[ $lastContent ][ 'line' ] <= ( $this->tokens[ $scopeCloser ][ 'line' ] - 2 )
449 449
 				) {
450 450
 					for ( $i = ( $scopeCloser - 1 ); $i > $lastContent; $i-- ) {
451
-						if ( $this->tokens[ $i ]['line'] < $this->tokens[ $scopeCloser ]['line']
452
-							&& \T_OPEN_TAG !== $this->tokens[ $firstContent ]['code']
451
+						if ( $this->tokens[ $i ][ 'line' ] < $this->tokens[ $scopeCloser ][ 'line' ]
452
+							&& \T_OPEN_TAG !== $this->tokens[ $firstContent ][ 'code' ]
453 453
 						) {
454 454
 							// TODO: Reporting error at empty line won't highlight it in IDE.
455 455
 							$error = 'Blank line found at end of control structure';
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
 								$this->phpcsFile->fixer->beginChangeset();
460 460
 
461 461
 								for ( $j = ( $lastContent + 1 ); $j < $scopeCloser; $j++ ) {
462
-									if ( $this->tokens[ $j ]['line'] === $this->tokens[ $scopeCloser ]['line'] ) {
462
+									if ( $this->tokens[ $j ][ 'line' ] === $this->tokens[ $scopeCloser ][ 'line' ] ) {
463 463
 										break;
464 464
 									}
465 465
 									$this->phpcsFile->fixer->replaceToken( $j, '' );
@@ -470,8 +470,8 @@  discard block
 block discarded – undo
470 470
 								 * the new line at the end, so don't add any extra as it would cause a fixer
471 471
 								 * conflict.
472 472
 								 */
473
-								if ( \T_COMMENT !== $this->tokens[ $lastContent ]['code']
474
-									&& ! isset( Tokens::$phpcsCommentTokens[ $this->tokens[ $lastContent ]['code'] ] ) ) {
473
+								if ( \T_COMMENT !== $this->tokens[ $lastContent ][ 'code' ]
474
+									&& ! isset( Tokens::$phpcsCommentTokens[ $this->tokens[ $lastContent ][ 'code' ] ] ) ) {
475 475
 									$this->phpcsFile->fixer->addNewlineBefore( $j );
476 476
 								}
477 477
 
@@ -496,53 +496,53 @@  discard block
 block discarded – undo
496 496
 			return;
497 497
 		}
498 498
 
499
-		if ( \T_COMMENT === $this->tokens[ $trailingContent ]['code']
500
-			|| isset( Tokens::$phpcsCommentTokens[ $this->tokens[ $trailingContent ]['code'] ] )
499
+		if ( \T_COMMENT === $this->tokens[ $trailingContent ][ 'code' ]
500
+			|| isset( Tokens::$phpcsCommentTokens[ $this->tokens[ $trailingContent ][ 'code' ] ] )
501 501
 		) {
502 502
 			// Special exception for code where the comment about
503 503
 			// an ELSE or ELSEIF is written between the control structures.
504 504
 			$nextCode = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $scopeCloser + 1 ), null, true );
505 505
 
506
-			if ( \T_ELSE === $this->tokens[ $nextCode ]['code'] || \T_ELSEIF === $this->tokens[ $nextCode ]['code'] ) {
506
+			if ( \T_ELSE === $this->tokens[ $nextCode ][ 'code' ] || \T_ELSEIF === $this->tokens[ $nextCode ][ 'code' ] ) {
507 507
 				$trailingContent = $nextCode;
508 508
 			}
509 509
 
510 510
 			// Move past end comments.
511
-			if ( $this->tokens[ $trailingContent ]['line'] === $this->tokens[ $scopeCloser ]['line'] ) {
512
-				if ( preg_match( '`^//[ ]?end`i', $this->tokens[ $trailingContent ]['content'], $matches ) > 0 ) {
511
+			if ( $this->tokens[ $trailingContent ][ 'line' ] === $this->tokens[ $scopeCloser ][ 'line' ] ) {
512
+				if ( preg_match( '`^//[ ]?end`i', $this->tokens[ $trailingContent ][ 'content' ], $matches ) > 0 ) {
513 513
 					$scopeCloser     = $trailingContent;
514 514
 					$trailingContent = $this->phpcsFile->findNext( \T_WHITESPACE, ( $trailingContent + 1 ), null, true );
515 515
 				}
516 516
 			}
517 517
 		}
518 518
 
519
-		if ( \T_ELSE === $this->tokens[ $trailingContent ]['code'] && \T_IF === $this->tokens[ $stackPtr ]['code'] ) {
519
+		if ( \T_ELSE === $this->tokens[ $trailingContent ][ 'code' ] && \T_IF === $this->tokens[ $stackPtr ][ 'code' ] ) {
520 520
 			// IF with ELSE.
521 521
 			return;
522 522
 		}
523 523
 
524
-		if ( \T_WHILE === $this->tokens[ $trailingContent ]['code'] && \T_DO === $this->tokens[ $stackPtr ]['code'] ) {
524
+		if ( \T_WHILE === $this->tokens[ $trailingContent ][ 'code' ] && \T_DO === $this->tokens[ $stackPtr ][ 'code' ] ) {
525 525
 			// DO with WHILE.
526 526
 			return;
527 527
 		}
528 528
 
529
-		if ( \T_CLOSE_TAG === $this->tokens[ $trailingContent ]['code'] ) {
529
+		if ( \T_CLOSE_TAG === $this->tokens[ $trailingContent ][ 'code' ] ) {
530 530
 			// At the end of the script or embedded code.
531 531
 			return;
532 532
 		}
533 533
 
534
-		if ( isset( $this->tokens[ $trailingContent ]['scope_condition'] )
535
-			&& \T_CLOSE_CURLY_BRACKET === $this->tokens[ $trailingContent ]['code']
534
+		if ( isset( $this->tokens[ $trailingContent ][ 'scope_condition' ] )
535
+			&& \T_CLOSE_CURLY_BRACKET === $this->tokens[ $trailingContent ][ 'code' ]
536 536
 		) {
537 537
 			// Another control structure's closing brace.
538
-			$owner = $this->tokens[ $trailingContent ]['scope_condition'];
539
-			if ( \in_array( $this->tokens[ $owner ]['code'], array( \T_FUNCTION, \T_CLOSURE, \T_CLASS, \T_ANON_CLASS, \T_INTERFACE, \T_TRAIT ), true ) ) {
538
+			$owner = $this->tokens[ $trailingContent ][ 'scope_condition' ];
539
+			if ( \in_array( $this->tokens[ $owner ][ 'code' ], array( \T_FUNCTION, \T_CLOSURE, \T_CLASS, \T_ANON_CLASS, \T_INTERFACE, \T_TRAIT ), true ) ) {
540 540
 				// The next content is the closing brace of a function, class, interface or trait
541 541
 				// so normal function/class rules apply and we can ignore it.
542 542
 				return;
543 543
 			}
544 544
 
545
-			if ( ( $this->tokens[ $scopeCloser ]['line'] + 1 ) !== $this->tokens[ $trailingContent ]['line'] ) {
545
+			if ( ( $this->tokens[ $scopeCloser ][ 'line' ] + 1 ) !== $this->tokens[ $trailingContent ][ 'line' ] ) {
546 546
 				// TODO: Won't cover following case: "} echo 'OK';".
547 547
 				$error = 'Blank line found after control structure';
548 548
 				$fix   = $this->phpcsFile->addFixableError( $error, $scopeCloser, 'BlankLineAfterEnd' );
@@ -551,14 +551,14 @@  discard block
 block discarded – undo
551 551
 					$this->phpcsFile->fixer->beginChangeset();
552 552
 
553 553
 					$i = ( $scopeCloser + 1 );
554
-					while ( $this->tokens[ $i ]['line'] !== $this->tokens[ $trailingContent ]['line'] ) {
554
+					while ( $this->tokens[ $i ][ 'line' ] !== $this->tokens[ $trailingContent ][ 'line' ] ) {
555 555
 						$this->phpcsFile->fixer->replaceToken( $i, '' );
556 556
 						$i++;
557 557
 					}
558 558
 
559 559
 					// TODO: Instead a separate error should be triggered when content comes right after closing brace.
560
-					if ( \T_COMMENT !== $this->tokens[ $scopeCloser ]['code']
561
-						&& isset( Tokens::$phpcsCommentTokens[ $this->tokens[ $scopeCloser ]['code'] ] ) === false
560
+					if ( \T_COMMENT !== $this->tokens[ $scopeCloser ][ 'code' ]
561
+						&& isset( Tokens::$phpcsCommentTokens[ $this->tokens[ $scopeCloser ][ 'code' ] ] ) === false
562 562
 					) {
563 563
 						$this->phpcsFile->fixer->addNewlineBefore( $trailingContent );
564 564
 					}
Please login to merge, or discard this patch.
wpcs/WordPress/Sniffs/WhiteSpace/CastStructureSpacingSniff.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@
 block discarded – undo
45 45
 	 */
46 46
 	public function process_token( $stackPtr ) {
47 47
 
48
-		if ( \T_WHITESPACE !== $this->tokens[ ( $stackPtr - 1 ) ]['code'] ) {
48
+		if ( \T_WHITESPACE !== $this->tokens[ ( $stackPtr - 1 ) ][ 'code' ] ) {
49 49
 			$error = 'No space before opening casting parenthesis is prohibited';
50 50
 			$fix   = $this->phpcsFile->addFixableError( $error, $stackPtr, 'NoSpaceBeforeOpenParenthesis' );
51 51
 			if ( true === $fix ) {
Please login to merge, or discard this patch.
wpcs/WordPress/Sniffs/WhiteSpace/PrecisionAlignmentSniff.php 2 patches
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 		// Handle any custom ignore tokens received from a ruleset.
97 97
 		$ignoreAlignmentTokens = $this->merge_custom_array( $this->ignoreAlignmentTokens );
98 98
 
99
-		$check_tokens  = array(
99
+		$check_tokens = array(
100 100
 			\T_WHITESPACE             => true,
101 101
 			\T_INLINE_HTML            => true,
102 102
 			\T_DOC_COMMENT_WHITESPACE => true,
@@ -106,32 +106,32 @@  discard block
 block discarded – undo
106 106
 
107 107
 		for ( $i = 0; $i < $this->phpcsFile->numTokens; $i++ ) {
108 108
 
109
-			if ( 1 !== $this->tokens[ $i ]['column'] ) {
109
+			if ( 1 !== $this->tokens[ $i ][ 'column' ] ) {
110 110
 				continue;
111
-			} elseif ( isset( $check_tokens[ $this->tokens[ $i ]['code'] ] ) === false
111
+			} elseif ( isset( $check_tokens[ $this->tokens[ $i ][ 'code' ] ] ) === false
112 112
 				|| ( isset( $this->tokens[ ( $i + 1 ) ] )
113
-					&& \T_WHITESPACE === $this->tokens[ ( $i + 1 ) ]['code'] )
114
-				|| $this->tokens[ $i ]['content'] === $this->phpcsFile->eolChar
115
-				|| isset( $ignoreAlignmentTokens[ $this->tokens[ $i ]['type'] ] )
113
+					&& \T_WHITESPACE === $this->tokens[ ( $i + 1 ) ][ 'code' ] )
114
+				|| $this->tokens[ $i ][ 'content' ] === $this->phpcsFile->eolChar
115
+				|| isset( $ignoreAlignmentTokens[ $this->tokens[ $i ][ 'type' ] ] )
116 116
 				|| ( isset( $this->tokens[ ( $i + 1 ) ] )
117
-					&& isset( $ignoreAlignmentTokens[ $this->tokens[ ( $i + 1 ) ]['type'] ] ) )
117
+					&& isset( $ignoreAlignmentTokens[ $this->tokens[ ( $i + 1 ) ][ 'type' ] ] ) )
118 118
 			) {
119 119
 				continue;
120 120
 			}
121 121
 
122 122
 			$spaces = 0;
123
-			switch ( $this->tokens[ $i ]['type'] ) {
123
+			switch ( $this->tokens[ $i ][ 'type' ] ) {
124 124
 				case 'T_WHITESPACE':
125
-					$spaces = ( $this->tokens[ $i ]['length'] % $this->tab_width );
125
+					$spaces = ( $this->tokens[ $i ][ 'length' ] % $this->tab_width );
126 126
 					break;
127 127
 
128 128
 				case 'T_DOC_COMMENT_WHITESPACE':
129
-					$length = $this->tokens[ $i ]['length'];
129
+					$length = $this->tokens[ $i ][ 'length' ];
130 130
 					$spaces = ( $length % $this->tab_width );
131 131
 
132 132
 					if ( isset( $this->tokens[ ( $i + 1 ) ] )
133
-						&& ( \T_DOC_COMMENT_STAR === $this->tokens[ ( $i + 1 ) ]['code']
134
-							|| \T_DOC_COMMENT_CLOSE_TAG === $this->tokens[ ( $i + 1 ) ]['code'] )
133
+						&& ( \T_DOC_COMMENT_STAR === $this->tokens[ ( $i + 1 ) ][ 'code' ]
134
+							|| \T_DOC_COMMENT_CLOSE_TAG === $this->tokens[ ( $i + 1 ) ][ 'code' ] )
135 135
 						&& 0 !== $spaces
136 136
 					) {
137 137
 						// One alignment space expected before the *.
@@ -149,25 +149,25 @@  discard block
 block discarded – undo
149 149
 					 * Indentation whitespace for subsequent lines of multi-line comments
150 150
 					 * are tokenized as part of the comment.
151 151
 					 */
152
-					$comment    = ltrim( $this->tokens[ $i ]['content'] );
153
-					$whitespace = str_replace( $comment, '', $this->tokens[ $i ]['content'] );
152
+					$comment    = ltrim( $this->tokens[ $i ][ 'content' ] );
153
+					$whitespace = str_replace( $comment, '', $this->tokens[ $i ][ 'content' ] );
154 154
 					$length     = \strlen( $whitespace );
155 155
 					$spaces     = ( $length % $this->tab_width );
156 156
 
157
-					if ( isset( $comment[0] ) && '*' === $comment[0] && 0 !== $spaces ) {
157
+					if ( isset( $comment[ 0 ] ) && '*' === $comment[ 0 ] && 0 !== $spaces ) {
158 158
 						--$spaces;
159 159
 					}
160 160
 					break;
161 161
 
162 162
 				case 'T_INLINE_HTML':
163
-					if ( $this->tokens[ $i ]['content'] === $this->phpcsFile->eolChar ) {
163
+					if ( $this->tokens[ $i ][ 'content' ] === $this->phpcsFile->eolChar ) {
164 164
 						$spaces = 0;
165 165
 					} else {
166 166
 						/*
167 167
 						 * Indentation whitespace for inline HTML is part of the T_INLINE_HTML token.
168 168
 						 */
169
-						$content    = ltrim( $this->tokens[ $i ]['content'] );
170
-						$whitespace = str_replace( $content, '', $this->tokens[ $i ]['content'] );
169
+						$content    = ltrim( $this->tokens[ $i ][ 'content' ] );
170
+						$whitespace = str_replace( $content, '', $this->tokens[ $i ][ 'content' ] );
171 171
 						$spaces     = ( \strlen( $whitespace ) % $this->tab_width );
172 172
 					}
173 173
 
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 					 * This may cause false negatives as there is no check for being in a
177 177
 					 * <script> tag, but that will be rare.
178 178
 					 */
179
-					if ( isset( $content[0] ) && '*' === $content[0] && 0 !== $spaces ) {
179
+					if ( isset( $content[ 0 ] ) && '*' === $content[ 0 ] && 0 !== $spaces ) {
180 180
 						--$spaces;
181 181
 					}
182 182
 					break;
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/WhiteSpace/DisallowInlineTabsSniff.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -62,16 +62,16 @@  discard block
 block discarded – undo
62 62
 
63 63
 		for ( $i = ( $stackPtr + 1 ); $i < $this->phpcsFile->numTokens; $i++ ) {
64 64
 			// Skip all non-whitespace tokens and skip whitespace at the start of a new line.
65
-			if ( ! isset( $check_tokens[ $this->tokens[ $i ]['code'] ] ) || 1 === $this->tokens[ $i ]['column'] ) {
65
+			if ( ! isset( $check_tokens[ $this->tokens[ $i ][ 'code' ] ] ) || 1 === $this->tokens[ $i ][ 'column' ] ) {
66 66
 				continue;
67 67
 			}
68 68
 
69 69
 			// If tabs are being converted to spaces by the tokenizer, the
70 70
 			// original content should be checked instead of the converted content.
71
-			if ( isset( $this->tokens[ $i ]['orig_content'] ) ) {
72
-				$content = $this->tokens[ $i ]['orig_content'];
71
+			if ( isset( $this->tokens[ $i ][ 'orig_content' ] ) ) {
72
+				$content = $this->tokens[ $i ][ 'orig_content' ];
73 73
 			} else {
74
-				$content = $this->tokens[ $i ]['content'];
74
+				$content = $this->tokens[ $i ][ 'content' ];
75 75
 			}
76 76
 
77 77
 			if ( '' === $content || strpos( $content, "\t" ) === false ) {
@@ -84,14 +84,14 @@  discard block
 block discarded – undo
84 84
 				'NonIndentTabsUsed'
85 85
 			);
86 86
 			if ( true === $fix ) {
87
-				if ( isset( $this->tokens[ $i ]['orig_content'] ) ) {
87
+				if ( isset( $this->tokens[ $i ][ 'orig_content' ] ) ) {
88 88
 					// Use the replacement that PHPCS has already done.
89
-					$this->phpcsFile->fixer->replaceToken( $i, $this->tokens[ $i ]['content'] );
89
+					$this->phpcsFile->fixer->replaceToken( $i, $this->tokens[ $i ][ 'content' ] );
90 90
 				} else {
91 91
 					// Replace tabs with spaces, using an indent of $tab_width.
92 92
 					// Other sniffs can then correct the indent if they need to.
93 93
 					$spaces     = str_repeat( ' ', $this->tab_width );
94
-					$newContent = str_replace( "\t", $spaces, $this->tokens[ $i ]['content'] );
94
+					$newContent = str_replace( "\t", $spaces, $this->tokens[ $i ][ 'content' ] );
95 95
 					$this->phpcsFile->fixer->replaceToken( $i, $newContent );
96 96
 				}
97 97
 			}
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/Arrays/ArrayIndentationSniff.php 1 patch
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -101,10 +101,10 @@  discard block
 block discarded – undo
101 101
 			return;
102 102
 		}
103 103
 
104
-		$opener = $array_open_close['opener'];
105
-		$closer = $array_open_close['closer'];
104
+		$opener = $array_open_close[ 'opener' ];
105
+		$closer = $array_open_close[ 'closer' ];
106 106
 
107
-		if ( $this->tokens[ $opener ]['line'] === $this->tokens[ $closer ]['line'] ) {
107
+		if ( $this->tokens[ $opener ][ 'line' ] === $this->tokens[ $closer ][ 'line' ] ) {
108 108
 			// Not interested in single line arrays.
109 109
 			return;
110 110
 		}
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 		 * containing the array opener.
115 115
 		 */
116 116
 		$opener_line_spaces = $this->get_indentation_size( $opener );
117
-		$closer_line_spaces = ( $this->tokens[ $closer ]['column'] - 1 );
117
+		$closer_line_spaces = ( $this->tokens[ $closer ][ 'column' ] - 1 );
118 118
 
119 119
 		if ( $closer_line_spaces !== $opener_line_spaces ) {
120 120
 			$error      = 'Array closer not aligned correctly; expected %s space(s) but found %s';
@@ -125,8 +125,8 @@  discard block
 block discarded – undo
125 125
 			 * nothing or only indentation whitespace before it.
126 126
 			 */
127 127
 			if ( 0 === $closer_line_spaces
128
-				|| ( \T_WHITESPACE === $this->tokens[ ( $closer - 1 ) ]['code']
129
-					&& 1 === $this->tokens[ ( $closer - 1 ) ]['column'] )
128
+				|| ( \T_WHITESPACE === $this->tokens[ ( $closer - 1 ) ][ 'code' ]
129
+					&& 1 === $this->tokens[ ( $closer - 1 ) ][ 'column' ] )
130 130
 			) {
131 131
 				$this->add_array_alignment_error(
132 132
 					$closer,
@@ -168,20 +168,20 @@  discard block
 block discarded – undo
168 168
 		$end_of_previous_item = $opener;
169 169
 
170 170
 		foreach ( $array_items as $item ) {
171
-			$end_of_this_item = ( $item['end'] + 1 );
171
+			$end_of_this_item = ( $item[ 'end' ] + 1 );
172 172
 
173 173
 			// Find the line on which the item starts.
174 174
 			$first_content = $this->phpcsFile->findNext(
175 175
 				array( \T_WHITESPACE, \T_DOC_COMMENT_WHITESPACE ),
176
-				$item['start'],
176
+				$item[ 'start' ],
177 177
 				$end_of_this_item,
178 178
 				true
179 179
 			);
180 180
 
181 181
 			// Deal with trailing comments.
182 182
 			if ( false !== $first_content
183
-				&& \T_COMMENT === $this->tokens[ $first_content ]['code']
184
-				&& $this->tokens[ $first_content ]['line'] === $this->tokens[ $end_of_previous_item ]['line']
183
+				&& \T_COMMENT === $this->tokens[ $first_content ][ 'code' ]
184
+				&& $this->tokens[ $first_content ][ 'line' ] === $this->tokens[ $end_of_previous_item ][ 'line' ]
185 185
 			) {
186 186
 				$first_content = $this->phpcsFile->findNext(
187 187
 					array( \T_WHITESPACE, \T_DOC_COMMENT_WHITESPACE, \T_COMMENT ),
@@ -198,14 +198,14 @@  discard block
 block discarded – undo
198 198
 
199 199
 			// Bow out from reporting and fixing mixed multi-line/single-line arrays.
200 200
 			// That is handled by the ArrayDeclarationSpacingSniff.
201
-			if ( $this->tokens[ $first_content ]['line'] === $this->tokens[ $end_of_previous_item ]['line']
202
-				|| ( 1 !== $this->tokens[ $first_content ]['column']
203
-					&& \T_WHITESPACE !== $this->tokens[ ( $first_content - 1 ) ]['code'] )
201
+			if ( $this->tokens[ $first_content ][ 'line' ] === $this->tokens[ $end_of_previous_item ][ 'line' ]
202
+				|| ( 1 !== $this->tokens[ $first_content ][ 'column' ]
203
+					&& \T_WHITESPACE !== $this->tokens[ ( $first_content - 1 ) ][ 'code' ] )
204 204
 			) {
205 205
 				return $closer;
206 206
 			}
207 207
 
208
-			$found_spaces = ( $this->tokens[ $first_content ]['column'] - 1 );
208
+			$found_spaces = ( $this->tokens[ $first_content ][ 'column' ] - 1 );
209 209
 
210 210
 			if ( $found_spaces !== $expected_spaces ) {
211 211
 				$this->add_array_alignment_error(
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 			}
220 220
 
221 221
 			// No need for further checking if this is a one-line array item.
222
-			if ( $this->tokens[ $first_content ]['line'] === $this->tokens[ $item['end'] ]['line'] ) {
222
+			if ( $this->tokens[ $first_content ][ 'line' ] === $this->tokens[ $item[ 'end' ] ][ 'line' ] ) {
223 223
 				$end_of_previous_item = $end_of_this_item;
224 224
 				continue;
225 225
 			}
@@ -237,9 +237,9 @@  discard block
 block discarded – undo
237 237
 			// Find first token on second line of the array item.
238 238
 			// If the second line is a heredoc/nowdoc, continue on until we find a line with a different token.
239 239
 			// Same for the second line of a multi-line text string.
240
-			for ( $ptr = ( $first_content + 1 ); $ptr <= $item['end']; $ptr++ ) {
241
-				if ( $this->tokens[ $first_content ]['line'] !== $this->tokens[ $ptr ]['line']
242
-					&& 1 === $this->tokens[ $ptr ]['column']
240
+			for ( $ptr = ( $first_content + 1 ); $ptr <= $item[ 'end' ]; $ptr++ ) {
241
+				if ( $this->tokens[ $first_content ][ 'line' ] !== $this->tokens[ $ptr ][ 'line' ]
242
+					&& 1 === $this->tokens[ $ptr ][ 'column' ]
243 243
 					&& false === $this->ignore_token( $ptr )
244 244
 				) {
245 245
 					break;
@@ -260,16 +260,16 @@  discard block
 block discarded – undo
260 260
 				 * In that case, the comma after the array item might be on a line by itself,
261 261
 				 * so check its placement.
262 262
 				 */
263
-				if ( $this->tokens[ $item['end'] ]['line'] !== $this->tokens[ $end_of_this_item ]['line']
264
-					&& \T_COMMA === $this->tokens[ $end_of_this_item ]['code']
265
-					&& ( $this->tokens[ $end_of_this_item ]['column'] - 1 ) !== $expected_spaces
263
+				if ( $this->tokens[ $item[ 'end' ] ][ 'line' ] !== $this->tokens[ $end_of_this_item ][ 'line' ]
264
+					&& \T_COMMA === $this->tokens[ $end_of_this_item ][ 'code' ]
265
+					&& ( $this->tokens[ $end_of_this_item ][ 'column' ] - 1 ) !== $expected_spaces
266 266
 				) {
267 267
 					$this->add_array_alignment_error(
268 268
 						$end_of_this_item,
269 269
 						'Comma after multi-line array item not aligned correctly; expected %s spaces, but found %s',
270 270
 						'MultiLineArrayItemCommaNotAligned',
271 271
 						$expected_spaces,
272
-						( $this->tokens[ $end_of_this_item ]['column'] - 1 ),
272
+						( $this->tokens[ $end_of_this_item ][ 'column' ] - 1 ),
273 273
 						$expected_indent
274 274
 					);
275 275
 				}
@@ -303,10 +303,10 @@  discard block
 block discarded – undo
303 303
 					$this->phpcsFile->fixer->beginChangeset();
304 304
 
305 305
 					// Fix second line for the array item.
306
-					if ( 1 === $this->tokens[ $first_content_on_line2 ]['column']
307
-						&& \T_COMMENT === $this->tokens[ $first_content_on_line2 ]['code']
306
+					if ( 1 === $this->tokens[ $first_content_on_line2 ][ 'column' ]
307
+						&& \T_COMMENT === $this->tokens[ $first_content_on_line2 ][ 'code' ]
308 308
 					) {
309
-						$actual_comment = ltrim( $this->tokens[ $first_content_on_line2 ]['content'] );
309
+						$actual_comment = ltrim( $this->tokens[ $first_content_on_line2 ][ 'content' ] );
310 310
 						$replacement    = $expected_indent_on_line2 . $actual_comment;
311 311
 
312 312
 						$this->phpcsFile->fixer->replaceToken( $first_content_on_line2, $replacement );
@@ -316,10 +316,10 @@  discard block
 block discarded – undo
316 316
 					}
317 317
 
318 318
 					// Fix subsequent lines.
319
-					for ( $i = ( $first_content_on_line2 + 1 ); $i <= $item['end']; $i++ ) {
319
+					for ( $i = ( $first_content_on_line2 + 1 ); $i <= $item[ 'end' ]; $i++ ) {
320 320
 						// We're only interested in the first token on each line.
321
-						if ( 1 !== $this->tokens[ $i ]['column'] ) {
322
-							if ( $this->tokens[ $i ]['line'] === $this->tokens[ $item['end'] ]['line'] ) {
321
+						if ( 1 !== $this->tokens[ $i ][ 'column' ] ) {
322
+							if ( $this->tokens[ $i ][ 'line' ] === $this->tokens[ $item[ 'end' ] ][ 'line' ] ) {
323 323
 								// We might as well quit if we're past the first token on the last line.
324 324
 								break;
325 325
 							}
@@ -349,10 +349,10 @@  discard block
 block discarded – undo
349 349
 						$expected_indent_on_line = $this->get_indentation_string( $expected_spaces_on_line );
350 350
 
351 351
 						if ( $found_spaces_on_line !== $expected_spaces_on_line ) {
352
-							if ( 1 === $this->tokens[ $first_content_on_line ]['column']
353
-								&& \T_COMMENT === $this->tokens[ $first_content_on_line ]['code']
352
+							if ( 1 === $this->tokens[ $first_content_on_line ][ 'column' ]
353
+								&& \T_COMMENT === $this->tokens[ $first_content_on_line ][ 'code' ]
354 354
 							) {
355
-								$actual_comment = ltrim( $this->tokens[ $first_content_on_line ]['content'] );
355
+								$actual_comment = ltrim( $this->tokens[ $first_content_on_line ][ 'content' ] );
356 356
 								$replacement    = $expected_indent_on_line . $actual_comment;
357 357
 
358 358
 								$this->phpcsFile->fixer->replaceToken( $first_content_on_line, $replacement );
@@ -369,16 +369,16 @@  discard block
 block discarded – undo
369 369
 					/*
370 370
 					 * Check the placement of the comma after the array item as it might be on a line by itself.
371 371
 					 */
372
-					if ( $this->tokens[ $item['end'] ]['line'] !== $this->tokens[ $end_of_this_item ]['line']
373
-						&& \T_COMMA === $this->tokens[ $end_of_this_item ]['code']
374
-						&& ( $this->tokens[ $end_of_this_item ]['column'] - 1 ) !== $expected_spaces
372
+					if ( $this->tokens[ $item[ 'end' ] ][ 'line' ] !== $this->tokens[ $end_of_this_item ][ 'line' ]
373
+						&& \T_COMMA === $this->tokens[ $end_of_this_item ][ 'code' ]
374
+						&& ( $this->tokens[ $end_of_this_item ][ 'column' ] - 1 ) !== $expected_spaces
375 375
 					) {
376 376
 						$this->add_array_alignment_error(
377 377
 							$end_of_this_item,
378 378
 							'Comma after array item not aligned correctly; expected %s spaces, but found %s',
379 379
 							'MultiLineArrayItemCommaNotAligned',
380 380
 							$expected_spaces,
381
-							( $this->tokens[ $end_of_this_item ]['column'] - 1 ),
381
+							( $this->tokens[ $end_of_this_item ][ 'column' ] - 1 ),
382 382
 							$expected_indent
383 383
 						);
384 384
 					}
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
 	 * @return bool
403 403
 	 */
404 404
 	protected function ignore_token( $ptr ) {
405
-		$token_code = $this->tokens[ $ptr ]['code'];
405
+		$token_code = $this->tokens[ $ptr ][ 'code' ];
406 406
 
407 407
 		if ( isset( $this->ignore_tokens[ $token_code ] ) ) {
408 408
 			return true;
@@ -416,15 +416,15 @@  discard block
 block discarded – undo
416 416
 			|| \T_DOUBLE_QUOTED_STRING === $token_code
417 417
 		) {
418 418
 			// Deal with closing quote of a multi-line string being on its own line.
419
-			if ( "'" === $this->tokens[ $ptr ]['content']
420
-				|| '"' === $this->tokens[ $ptr ]['content']
419
+			if ( "'" === $this->tokens[ $ptr ][ 'content' ]
420
+				|| '"' === $this->tokens[ $ptr ][ 'content' ]
421 421
 			) {
422 422
 				return true;
423 423
 			}
424 424
 
425 425
 			// Deal with subsequent lines of a multi-line string where the token is broken up per line.
426
-			if ( "'" !== $this->tokens[ $ptr ]['content'][0]
427
-				&& '"' !== $this->tokens[ $ptr ]['content'][0]
426
+			if ( "'" !== $this->tokens[ $ptr ][ 'content' ][ 0 ]
427
+				&& '"' !== $this->tokens[ $ptr ][ 'content' ][ 0 ]
428 428
 			) {
429 429
 				return true;
430 430
 			}
@@ -444,17 +444,17 @@  discard block
 block discarded – undo
444 444
 
445 445
 		// Find the first token on the line.
446 446
 		for ( ; $ptr >= 0; $ptr-- ) {
447
-			if ( 1 === $this->tokens[ $ptr ]['column'] ) {
447
+			if ( 1 === $this->tokens[ $ptr ][ 'column' ] ) {
448 448
 				break;
449 449
 			}
450 450
 		}
451 451
 
452 452
 		$whitespace = '';
453 453
 
454
-		if ( \T_WHITESPACE === $this->tokens[ $ptr ]['code']
455
-			|| \T_DOC_COMMENT_WHITESPACE === $this->tokens[ $ptr ]['code']
454
+		if ( \T_WHITESPACE === $this->tokens[ $ptr ][ 'code' ]
455
+			|| \T_DOC_COMMENT_WHITESPACE === $this->tokens[ $ptr ][ 'code' ]
456 456
 		) {
457
-			return $this->tokens[ $ptr ]['length'];
457
+			return $this->tokens[ $ptr ][ 'length' ];
458 458
 		}
459 459
 
460 460
 		/*
@@ -464,8 +464,8 @@  discard block
 block discarded – undo
464 464
 		 * First/Single line is tokenized as T_WHITESPACE + T_COMMENT
465 465
 		 * Subsequent lines are tokenized as T_COMMENT including the indentation whitespace.
466 466
 		 */
467
-		if ( \T_COMMENT === $this->tokens[ $ptr ]['code'] ) {
468
-			$content        = $this->tokens[ $ptr ]['content'];
467
+		if ( \T_COMMENT === $this->tokens[ $ptr ][ 'code' ] ) {
468
+			$content        = $this->tokens[ $ptr ][ 'content' ];
469 469
 			$actual_comment = ltrim( $content );
470 470
 			$whitespace     = str_replace( $actual_comment, '', $content );
471 471
 		}
@@ -491,7 +491,7 @@  discard block
 block discarded – undo
491 491
 		}
492 492
 
493 493
 		// Tab-based indentation.
494
-		$num_tabs    = (int) floor( $nr / $this->tab_width );
494
+		$num_tabs    = (int)floor( $nr / $this->tab_width );
495 495
 		$remaining   = ( $nr % $this->tab_width );
496 496
 		$tab_indent  = str_repeat( "\t", $num_tabs );
497 497
 		$tab_indent .= str_repeat( ' ', $remaining );
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
 	 * @param string $new_indent Whitespace indent replacement content.
525 525
 	 */
526 526
 	protected function fix_alignment_error( $ptr, $new_indent ) {
527
-		if ( 1 === $this->tokens[ $ptr ]['column'] ) {
527
+		if ( 1 === $this->tokens[ $ptr ][ 'column' ] ) {
528 528
 			$this->phpcsFile->fixer->addContentBefore( $ptr, $new_indent );
529 529
 		} else {
530 530
 			$this->phpcsFile->fixer->replaceToken( ( $ptr - 1 ), $new_indent );
Please login to merge, or discard this patch.
wpcs/WordPress/Sniffs/Arrays/ArrayDeclarationSpacingSniff.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -96,14 +96,14 @@  discard block
 block discarded – undo
96 96
 			return;
97 97
 		}
98 98
 
99
-		$opener = $array_open_close['opener'];
100
-		$closer = $array_open_close['closer'];
99
+		$opener = $array_open_close[ 'opener' ];
100
+		$closer = $array_open_close[ 'closer' ];
101 101
 		unset( $array_open_close );
102 102
 
103 103
 		/*
104 104
 		 * Long arrays only: Check for space between the array keyword and the open parenthesis.
105 105
 		 */
106
-		if ( \T_ARRAY === $this->tokens[ $stackPtr ]['code'] ) {
106
+		if ( \T_ARRAY === $this->tokens[ $stackPtr ][ 'code' ] ) {
107 107
 
108 108
 			if ( ( $stackPtr + 1 ) !== $opener ) {
109 109
 				$error      = 'There must be no space between the "array" keyword and the opening parenthesis';
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 		unset( $nextNonWhitespace );
160 160
 
161 161
 		// Pass off to either the single line or multi-line array analysis.
162
-		if ( $this->tokens[ $opener ]['line'] === $this->tokens[ $closer ]['line'] ) {
162
+		if ( $this->tokens[ $opener ][ 'line' ] === $this->tokens[ $closer ][ 'line' ] ) {
163 163
 			$this->process_single_line_array( $stackPtr, $opener, $closer );
164 164
 		} else {
165 165
 			$this->process_multi_line_array( $stackPtr, $opener, $closer );
@@ -197,21 +197,21 @@  discard block
 block discarded – undo
197 197
 				 */
198 198
 				$array_has_keys = false; // Reset before doing more detailed check.
199 199
 				foreach ( $array_items as $item ) {
200
-					for ( $ptr = $item['start']; $ptr <= $item['end']; $ptr++ ) {
201
-						if ( \T_DOUBLE_ARROW === $this->tokens[ $ptr ]['code'] ) {
200
+					for ( $ptr = $item[ 'start' ]; $ptr <= $item[ 'end' ]; $ptr++ ) {
201
+						if ( \T_DOUBLE_ARROW === $this->tokens[ $ptr ][ 'code' ] ) {
202 202
 							$array_has_keys = true;
203 203
 							break 2;
204 204
 						}
205 205
 
206 206
 						// Skip passed any nested arrays.
207
-						if ( isset( $this->targets[ $this->tokens[ $ptr ]['code'] ] ) ) {
207
+						if ( isset( $this->targets[ $this->tokens[ $ptr ][ 'code' ] ] ) ) {
208 208
 							$nested_array_open_close = $this->find_array_open_close( $ptr );
209 209
 							if ( false === $nested_array_open_close ) {
210 210
 								// Nested array open/close could not be determined.
211 211
 								continue;
212 212
 							}
213 213
 
214
-							$ptr = $nested_array_open_close['closer'];
214
+							$ptr = $nested_array_open_close[ 'closer' ];
215 215
 						}
216 216
 					}
217 217
 				}
@@ -241,16 +241,16 @@  discard block
 block discarded – undo
241 241
 							 */
242 242
 							$first_non_empty = $this->phpcsFile->findNext(
243 243
 								Tokens::$emptyTokens,
244
-								$item['start'],
245
-								( $item['end'] + 1 ),
244
+								$item[ 'start' ],
245
+								( $item[ 'end' ] + 1 ),
246 246
 								true
247 247
 							);
248 248
 							if ( false === $first_non_empty ) {
249 249
 								continue;
250 250
 							}
251 251
 
252
-							if ( $item['start'] <= ( $first_non_empty - 1 )
253
-								&& \T_WHITESPACE === $this->tokens[ ( $first_non_empty - 1 ) ]['code']
252
+							if ( $item[ 'start' ] <= ( $first_non_empty - 1 )
253
+								&& \T_WHITESPACE === $this->tokens[ ( $first_non_empty - 1 ) ][ 'code' ]
254 254
 							) {
255 255
 								// Remove whitespace which would otherwise becoming trailing
256 256
 								// (as it gives problems with the fixed file).
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 		/*
273 273
 		 * Check that there is a single space after the array opener and before the array closer.
274 274
 		 */
275
-		if ( \T_WHITESPACE !== $this->tokens[ ( $opener + 1 ) ]['code'] ) {
275
+		if ( \T_WHITESPACE !== $this->tokens[ ( $opener + 1 ) ][ 'code' ] ) {
276 276
 
277 277
 			$fix = $this->phpcsFile->addFixableError(
278 278
 				'Missing space after array opener.',
@@ -283,13 +283,13 @@  discard block
 block discarded – undo
283 283
 			if ( true === $fix ) {
284 284
 				$this->phpcsFile->fixer->addContent( $opener, ' ' );
285 285
 			}
286
-		} elseif ( ' ' !== $this->tokens[ ( $opener + 1 ) ]['content'] ) {
286
+		} elseif ( ' ' !== $this->tokens[ ( $opener + 1 ) ][ 'content' ] ) {
287 287
 
288 288
 			$fix = $this->phpcsFile->addFixableError(
289 289
 				'Expected 1 space after array opener, found %s.',
290 290
 				$opener,
291 291
 				'SpaceAfterArrayOpener',
292
-				array( \strlen( $this->tokens[ ( $opener + 1 ) ]['content'] ) )
292
+				array( \strlen( $this->tokens[ ( $opener + 1 ) ][ 'content' ] ) )
293 293
 			);
294 294
 
295 295
 			if ( true === $fix ) {
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 			}
298 298
 		}
299 299
 
300
-		if ( \T_WHITESPACE !== $this->tokens[ ( $closer - 1 ) ]['code'] ) {
300
+		if ( \T_WHITESPACE !== $this->tokens[ ( $closer - 1 ) ][ 'code' ] ) {
301 301
 
302 302
 			$fix = $this->phpcsFile->addFixableError(
303 303
 				'Missing space before array closer.',
@@ -308,13 +308,13 @@  discard block
 block discarded – undo
308 308
 			if ( true === $fix ) {
309 309
 				$this->phpcsFile->fixer->addContentBefore( $closer, ' ' );
310 310
 			}
311
-		} elseif ( ' ' !== $this->tokens[ ( $closer - 1 ) ]['content'] ) {
311
+		} elseif ( ' ' !== $this->tokens[ ( $closer - 1 ) ][ 'content' ] ) {
312 312
 
313 313
 			$fix = $this->phpcsFile->addFixableError(
314 314
 				'Expected 1 space before array closer, found %s.',
315 315
 				$closer,
316 316
 				'SpaceBeforeArrayCloser',
317
-				array( \strlen( $this->tokens[ ( $closer - 1 ) ]['content'] ) )
317
+				array( \strlen( $this->tokens[ ( $closer - 1 ) ][ 'content' ] ) )
318 318
 			);
319 319
 
320 320
 			if ( true === $fix ) {
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
 		 */
342 342
 		$last_content = $this->phpcsFile->findPrevious( \T_WHITESPACE, ( $closer - 1 ), $opener, true );
343 343
 		if ( false !== $last_content
344
-			&& $this->tokens[ $last_content ]['line'] === $this->tokens[ $closer ]['line']
344
+			&& $this->tokens[ $last_content ][ 'line' ] === $this->tokens[ $closer ][ 'line' ]
345 345
 		) {
346 346
 			$fix = $this->phpcsFile->addFixableError(
347 347
 				'Closing parenthesis of array declaration must be on a new line',
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 				$this->phpcsFile->fixer->beginChangeset();
353 353
 
354 354
 				if ( $last_content < ( $closer - 1 )
355
-					&& \T_WHITESPACE === $this->tokens[ ( $closer - 1 ) ]['code']
355
+					&& \T_WHITESPACE === $this->tokens[ ( $closer - 1 ) ][ 'code' ]
356 356
 				) {
357 357
 					// Remove whitespace which would otherwise becoming trailing
358 358
 					// (as it gives problems with the fixed file).
@@ -371,34 +371,34 @@  discard block
 block discarded – undo
371 371
 		$end_of_last_item = $opener;
372 372
 
373 373
 		foreach ( $array_items as $item ) {
374
-			$end_of_this_item = ( $item['end'] + 1 );
374
+			$end_of_this_item = ( $item[ 'end' ] + 1 );
375 375
 
376 376
 			// Find the line on which the item starts.
377 377
 			$first_content = $this->phpcsFile->findNext(
378 378
 				array( \T_WHITESPACE, \T_DOC_COMMENT_WHITESPACE ),
379
-				$item['start'],
379
+				$item[ 'start' ],
380 380
 				$end_of_this_item,
381 381
 				true
382 382
 			);
383 383
 
384 384
 			// Ignore comments after array items if the next real content starts on a new line.
385
-			if ( $this->tokens[ $first_content ]['line'] === $this->tokens[ $end_of_last_item ]['line']
386
-				&& ( \T_COMMENT === $this->tokens[ $first_content ]['code']
387
-				|| isset( Tokens::$phpcsCommentTokens[ $this->tokens[ $first_content ]['code'] ] ) )
385
+			if ( $this->tokens[ $first_content ][ 'line' ] === $this->tokens[ $end_of_last_item ][ 'line' ]
386
+				&& ( \T_COMMENT === $this->tokens[ $first_content ][ 'code' ]
387
+				|| isset( Tokens::$phpcsCommentTokens[ $this->tokens[ $first_content ][ 'code' ] ] ) )
388 388
 			) {
389 389
 				$end_of_comment = $first_content;
390 390
 
391 391
 				// Find the end of (multi-line) /* */- style trailing comments.
392
-				if ( substr( ltrim( $this->tokens[ $end_of_comment ]['content'] ), 0, 2 ) === '/*' ) {
393
-					while ( ( \T_COMMENT === $this->tokens[ $end_of_comment ]['code']
394
-						|| isset( Tokens::$phpcsCommentTokens[ $this->tokens[ $end_of_comment ]['code'] ] ) )
395
-						&& substr( rtrim( $this->tokens[ $end_of_comment ]['content'] ), -2 ) !== '*/'
392
+				if ( substr( ltrim( $this->tokens[ $end_of_comment ][ 'content' ] ), 0, 2 ) === '/*' ) {
393
+					while ( ( \T_COMMENT === $this->tokens[ $end_of_comment ][ 'code' ]
394
+						|| isset( Tokens::$phpcsCommentTokens[ $this->tokens[ $end_of_comment ][ 'code' ] ] ) )
395
+						&& substr( rtrim( $this->tokens[ $end_of_comment ][ 'content' ] ), -2 ) !== '*/'
396 396
 						&& ( $end_of_comment + 1 ) < $end_of_this_item
397 397
 					) {
398 398
 						$end_of_comment++;
399 399
 					}
400 400
 
401
-					if ( $this->tokens[ $end_of_comment ]['line'] !== $this->tokens[ $end_of_last_item ]['line'] ) {
401
+					if ( $this->tokens[ $end_of_comment ][ 'line' ] !== $this->tokens[ $end_of_last_item ][ 'line' ] ) {
402 402
 						// Multi-line trailing comment.
403 403
 						$end_of_last_item = $end_of_comment;
404 404
 					}
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
 					continue;
418 418
 				}
419 419
 
420
-				if ( $this->tokens[ $next ]['line'] !== $this->tokens[ $first_content ]['line'] ) {
420
+				if ( $this->tokens[ $next ][ 'line' ] !== $this->tokens[ $first_content ][ 'line' ] ) {
421 421
 					$first_content = $next;
422 422
 				}
423 423
 			}
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
 				continue;
429 429
 			}
430 430
 
431
-			if ( $this->tokens[ $end_of_last_item ]['line'] === $this->tokens[ $first_content ]['line'] ) {
431
+			if ( $this->tokens[ $end_of_last_item ][ 'line' ] === $this->tokens[ $first_content ][ 'line' ] ) {
432 432
 
433 433
 				$fix = $this->phpcsFile->addFixableError(
434 434
 					'Each item in a multi-line array must be on a new line',
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
 					$this->phpcsFile->fixer->beginChangeset();
442 442
 
443 443
 					if ( ( $end_of_last_item + 1 ) <= ( $first_content - 1 )
444
-						&& \T_WHITESPACE === $this->tokens[ ( $first_content - 1 ) ]['code']
444
+						&& \T_WHITESPACE === $this->tokens[ ( $first_content - 1 ) ][ 'code' ]
445 445
 					) {
446 446
 						// Remove whitespace which would otherwise becoming trailing
447 447
 						// (as it gives problems with the fixed file).
Please login to merge, or discard this patch.
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.