Completed
Pull Request — develop (#1492)
by Zack
33:18 queued 12:17
created
wpcs/WordPress/Sniffs/CodeAnalysis/AssignmentInConditionSniff.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -93,18 +93,18 @@  discard block
 block discarded – undo
93 93
 		$token = $this->tokens[ $stackPtr ];
94 94
 
95 95
 		// Find the condition opener/closer.
96
-		if ( \T_FOR === $token['code'] ) {
97
-			if ( isset( $token['parenthesis_opener'], $token['parenthesis_closer'] ) === false ) {
96
+		if ( \T_FOR === $token[ 'code' ] ) {
97
+			if ( isset( $token[ 'parenthesis_opener' ], $token[ 'parenthesis_closer' ] ) === false ) {
98 98
 				return;
99 99
 			}
100 100
 
101
-			$semicolon = $this->phpcsFile->findNext( \T_SEMICOLON, ( $token['parenthesis_opener'] + 1 ), $token['parenthesis_closer'] );
101
+			$semicolon = $this->phpcsFile->findNext( \T_SEMICOLON, ( $token[ 'parenthesis_opener' ] + 1 ), $token[ 'parenthesis_closer' ] );
102 102
 			if ( false === $semicolon ) {
103 103
 				return;
104 104
 			}
105 105
 
106 106
 			$opener    = $semicolon;
107
-			$semicolon = $this->phpcsFile->findNext( \T_SEMICOLON, ( $opener + 1 ), $token['parenthesis_closer'] );
107
+			$semicolon = $this->phpcsFile->findNext( \T_SEMICOLON, ( $opener + 1 ), $token[ 'parenthesis_closer' ] );
108 108
 			if ( false === $semicolon ) {
109 109
 				return;
110 110
 			}
@@ -112,15 +112,15 @@  discard block
 block discarded – undo
112 112
 			$closer = $semicolon;
113 113
 			unset( $semicolon );
114 114
 
115
-		} elseif ( \T_CASE === $token['code'] ) {
116
-			if ( isset( $token['scope_opener'] ) === false ) {
115
+		} elseif ( \T_CASE === $token[ 'code' ] ) {
116
+			if ( isset( $token[ 'scope_opener' ] ) === false ) {
117 117
 				return;
118 118
 			}
119 119
 
120 120
 			$opener = $stackPtr;
121
-			$closer = $token['scope_opener'];
121
+			$closer = $token[ 'scope_opener' ];
122 122
 
123
-		} elseif ( \T_INLINE_THEN === $token['code'] ) {
123
+		} elseif ( \T_INLINE_THEN === $token[ 'code' ] ) {
124 124
 			// Check if the condition for the ternary is bracketed.
125 125
 			$prev = $this->phpcsFile->findPrevious( Tokens::$emptyTokens, ( $stackPtr - 1 ), null, true );
126 126
 			if ( false === $prev ) {
@@ -128,16 +128,16 @@  discard block
 block discarded – undo
128 128
 				return;
129 129
 			}
130 130
 
131
-			if ( \T_CLOSE_PARENTHESIS === $this->tokens[ $prev ]['code'] ) {
132
-				if ( ! isset( $this->tokens[ $prev ]['parenthesis_opener'] ) ) {
131
+			if ( \T_CLOSE_PARENTHESIS === $this->tokens[ $prev ][ 'code' ] ) {
132
+				if ( ! isset( $this->tokens[ $prev ][ 'parenthesis_opener' ] ) ) {
133 133
 					return;
134 134
 				}
135 135
 
136
-				$opener = $this->tokens[ $prev ]['parenthesis_opener'];
136
+				$opener = $this->tokens[ $prev ][ 'parenthesis_opener' ];
137 137
 				$closer = $prev;
138
-			} elseif ( isset( $token['nested_parenthesis'] ) ) {
139
-				$closer = end( $token['nested_parenthesis'] );
140
-				$opener = key( $token['nested_parenthesis'] );
138
+			} elseif ( isset( $token[ 'nested_parenthesis' ] ) ) {
139
+				$closer = end( $token[ 'nested_parenthesis' ] );
140
+				$opener = key( $token[ 'nested_parenthesis' ] );
141 141
 
142 142
 				$next_statement_closer = $this->phpcsFile->findEndOfStatement( $stackPtr, array( \T_COLON, \T_CLOSE_PARENTHESIS, \T_CLOSE_SQUARE_BRACKET ) );
143 143
 				if ( false !== $next_statement_closer && $next_statement_closer < $closer ) {
@@ -159,12 +159,12 @@  discard block
 block discarded – undo
159 159
 				return;
160 160
 			}
161 161
 		} else {
162
-			if ( isset( $token['parenthesis_opener'], $token['parenthesis_closer'] ) === false ) {
162
+			if ( isset( $token[ 'parenthesis_opener' ], $token[ 'parenthesis_closer' ] ) === false ) {
163 163
 				return;
164 164
 			}
165 165
 
166
-			$opener = $token['parenthesis_opener'];
167
-			$closer = $token['parenthesis_closer'];
166
+			$opener = $token[ 'parenthesis_opener' ];
167
+			$closer = $token[ 'parenthesis_closer' ];
168 168
 		}
169 169
 
170 170
 		$startPos = $opener;
@@ -188,29 +188,29 @@  discard block
 block discarded – undo
188 188
 			}
189 189
 
190 190
 			for ( $i = $hasAssignment; $i > $conditionStart; $i-- ) {
191
-				if ( isset( Tokens::$emptyTokens[ $this->tokens[ $i ]['code'] ] ) ) {
191
+				if ( isset( Tokens::$emptyTokens[ $this->tokens[ $i ][ 'code' ] ] ) ) {
192 192
 					continue;
193 193
 				}
194 194
 
195 195
 				// If this is a variable or array, we've seen all we need to see.
196
-				if ( \T_VARIABLE === $this->tokens[ $i ]['code']
197
-					|| \T_CLOSE_SQUARE_BRACKET === $this->tokens[ $i ]['code']
196
+				if ( \T_VARIABLE === $this->tokens[ $i ][ 'code' ]
197
+					|| \T_CLOSE_SQUARE_BRACKET === $this->tokens[ $i ][ 'code' ]
198 198
 				) {
199 199
 					$hasVariable = true;
200 200
 					break;
201 201
 				}
202 202
 
203 203
 				// If this is a function call or something, we are OK.
204
-				if ( \T_CLOSE_PARENTHESIS === $this->tokens[ $i ]['code'] ) {
204
+				if ( \T_CLOSE_PARENTHESIS === $this->tokens[ $i ][ 'code' ] ) {
205 205
 					break;
206 206
 				}
207 207
 			}
208 208
 
209 209
 			if ( true === $hasVariable ) {
210 210
 				$errorCode = 'Found';
211
-				if ( \T_WHILE === $token['code'] ) {
211
+				if ( \T_WHILE === $token[ 'code' ] ) {
212 212
 					$errorCode = 'FoundInWhileCondition';
213
-				} elseif ( \T_INLINE_THEN === $token['code'] ) {
213
+				} elseif ( \T_INLINE_THEN === $token[ 'code' ] ) {
214 214
 					$errorCode = 'FoundInTernaryCondition';
215 215
 				}
216 216
 
Please login to merge, or discard this patch.
wpcs/WordPress/Sniffs/CodeAnalysis/EmptyStatementSniff.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	 */
53 53
 	public function process_token( $stackPtr ) {
54 54
 
55
-		switch ( $this->tokens[ $stackPtr ]['type'] ) {
55
+		switch ( $this->tokens[ $stackPtr ][ 'type' ] ) {
56 56
 			/*
57 57
 			 * Detect `something();;`.
58 58
 			 */
@@ -65,18 +65,18 @@  discard block
 block discarded – undo
65 65
 				);
66 66
 
67 67
 				if ( false === $prevNonEmpty
68
-					|| ( \T_SEMICOLON !== $this->tokens[ $prevNonEmpty ]['code']
69
-						&& \T_OPEN_TAG !== $this->tokens[ $prevNonEmpty ]['code']
70
-						&& \T_OPEN_TAG_WITH_ECHO !== $this->tokens[ $prevNonEmpty ]['code'] )
68
+					|| ( \T_SEMICOLON !== $this->tokens[ $prevNonEmpty ][ 'code' ]
69
+						&& \T_OPEN_TAG !== $this->tokens[ $prevNonEmpty ][ 'code' ]
70
+						&& \T_OPEN_TAG_WITH_ECHO !== $this->tokens[ $prevNonEmpty ][ 'code' ] )
71 71
 				) {
72 72
 					return;
73 73
 				}
74 74
 
75
-				if ( isset( $this->tokens[ $stackPtr ]['nested_parenthesis'] ) ) {
76
-					$nested      = $this->tokens[ $stackPtr ]['nested_parenthesis'];
75
+				if ( isset( $this->tokens[ $stackPtr ][ 'nested_parenthesis' ] ) ) {
76
+					$nested      = $this->tokens[ $stackPtr ][ 'nested_parenthesis' ];
77 77
 					$last_closer = array_pop( $nested );
78
-					if ( isset( $this->tokens[ $last_closer ]['parenthesis_owner'] )
79
-						&& \T_FOR === $this->tokens[ $this->tokens[ $last_closer ]['parenthesis_owner'] ]['code']
78
+					if ( isset( $this->tokens[ $last_closer ][ 'parenthesis_owner' ] )
79
+						&& \T_FOR === $this->tokens[ $this->tokens[ $last_closer ][ 'parenthesis_owner' ] ][ 'code' ]
80 80
 					) {
81 81
 						// Empty for() condition.
82 82
 						return;
@@ -91,8 +91,8 @@  discard block
 block discarded – undo
91 91
 				if ( true === $fix ) {
92 92
 					$this->phpcsFile->fixer->beginChangeset();
93 93
 
94
-					if ( \T_OPEN_TAG === $this->tokens[ $prevNonEmpty ]['code']
95
-						|| \T_OPEN_TAG_WITH_ECHO === $this->tokens[ $prevNonEmpty ]['code']
94
+					if ( \T_OPEN_TAG === $this->tokens[ $prevNonEmpty ][ 'code' ]
95
+						|| \T_OPEN_TAG_WITH_ECHO === $this->tokens[ $prevNonEmpty ][ 'code' ]
96 96
 					) {
97 97
 						/*
98 98
 						 * Check for superfluous whitespace after the semi-colon which will be
@@ -100,15 +100,15 @@  discard block
 block discarded – undo
100 100
 						 * either a space or a new line and in case of a new line, the indentation
101 101
 						 * should be done via tabs, so spaces can be safely removed.
102 102
 						 */
103
-						if ( \T_WHITESPACE === $this->tokens[ ( $stackPtr + 1 ) ]['code'] ) {
104
-							$replacement = str_replace( ' ', '', $this->tokens[ ( $stackPtr + 1 ) ]['content'] );
103
+						if ( \T_WHITESPACE === $this->tokens[ ( $stackPtr + 1 ) ][ 'code' ] ) {
104
+							$replacement = str_replace( ' ', '', $this->tokens[ ( $stackPtr + 1 ) ][ 'content' ] );
105 105
 							$this->phpcsFile->fixer->replaceToken( ( $stackPtr + 1 ), $replacement );
106 106
 						}
107 107
 					}
108 108
 
109 109
 					for ( $i = $stackPtr; $i > $prevNonEmpty; $i-- ) {
110
-						if ( \T_SEMICOLON !== $this->tokens[ $i ]['code']
111
-							&& \T_WHITESPACE !== $this->tokens[ $i ]['code']
110
+						if ( \T_SEMICOLON !== $this->tokens[ $i ][ 'code' ]
111
+							&& \T_WHITESPACE !== $this->tokens[ $i ][ 'code' ]
112 112
 						) {
113 113
 							break;
114 114
 						}
@@ -131,8 +131,8 @@  discard block
 block discarded – undo
131 131
 				);
132 132
 
133 133
 				if ( false === $prevNonEmpty
134
-					|| ( \T_OPEN_TAG !== $this->tokens[ $prevNonEmpty ]['code']
135
-						&& \T_OPEN_TAG_WITH_ECHO !== $this->tokens[ $prevNonEmpty ]['code'] )
134
+					|| ( \T_OPEN_TAG !== $this->tokens[ $prevNonEmpty ][ 'code' ]
135
+						&& \T_OPEN_TAG_WITH_ECHO !== $this->tokens[ $prevNonEmpty ][ 'code' ] )
136 136
 				) {
137 137
 					return;
138 138
 				}
Please login to merge, or discard this patch.
wpcs/WordPress/Sniffs/Utils/I18nTextDomainFixerSniff.php 1 patch
Spacing   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -239,14 +239,14 @@  discard block
 block discarded – undo
239 239
 	 * @return array
240 240
 	 */
241 241
 	public function register() {
242
-		$headers                  = array_map(
242
+		$headers = array_map(
243 243
 			'preg_quote',
244 244
 			array_keys( $this->theme_headers ),
245 245
 			array_fill( 0, \count( $this->theme_headers ), '`' )
246 246
 		);
247 247
 		$this->theme_header_regex = sprintf( $this->header_regex_template, implode( '|', $headers ) );
248 248
 
249
-		$headers                   = array_map(
249
+		$headers = array_map(
250 250
 			'preg_quote',
251 251
 			array_keys( $this->plugin_headers ),
252 252
 			array_fill( 0, \count( $this->plugin_headers ), '`' )
@@ -255,8 +255,8 @@  discard block
 block discarded – undo
255 255
 
256 256
 		$targets = parent::register();
257 257
 
258
-		$targets[] = \T_DOC_COMMENT_OPEN_TAG;
259
-		$targets[] = \T_COMMENT;
258
+		$targets[ ] = \T_DOC_COMMENT_OPEN_TAG;
259
+		$targets[ ] = \T_COMMENT;
260 260
 
261 261
 		return $targets;
262 262
 	}
@@ -335,8 +335,8 @@  discard block
 block discarded – undo
335 335
 			}
336 336
 		}
337 337
 
338
-		if ( \T_DOC_COMMENT_OPEN_TAG === $this->tokens[ $stackPtr ]['code']
339
-			|| \T_COMMENT === $this->tokens[ $stackPtr ]['code']
338
+		if ( \T_DOC_COMMENT_OPEN_TAG === $this->tokens[ $stackPtr ][ 'code' ]
339
+			|| \T_COMMENT === $this->tokens[ $stackPtr ][ 'code' ]
340 340
 		) {
341 341
 			// Examine for plugin/theme file header.
342 342
 			return $this->process_comments( $stackPtr );
@@ -371,22 +371,22 @@  discard block
 block discarded – undo
371 371
 				$fix = $this->phpcsFile->addFixableError( $error_msg, $stackPtr, $error_code );
372 372
 
373 373
 				if ( true === $fix ) {
374
-					$start_previous = $parameters[ ( $target_param - 1 ) ]['start'];
375
-					$end_previous   = $parameters[ ( $target_param - 1 ) ]['end'];
376
-					if ( \T_WHITESPACE === $this->tokens[ $start_previous ]['code']
377
-						&& $this->tokens[ $start_previous ]['content'] === $this->phpcsFile->eolChar
374
+					$start_previous = $parameters[ ( $target_param - 1 ) ][ 'start' ];
375
+					$end_previous   = $parameters[ ( $target_param - 1 ) ][ 'end' ];
376
+					if ( \T_WHITESPACE === $this->tokens[ $start_previous ][ 'code' ]
377
+						&& $this->tokens[ $start_previous ][ 'content' ] === $this->phpcsFile->eolChar
378 378
 					) {
379 379
 						// Replicate the new line + indentation of the previous item.
380 380
 						$replacement = ',';
381 381
 						for ( $i = $start_previous; $i <= $end_previous; $i++ ) {
382
-							if ( \T_WHITESPACE !== $this->tokens[ $i ]['code'] ) {
382
+							if ( \T_WHITESPACE !== $this->tokens[ $i ][ 'code' ] ) {
383 383
 								break;
384 384
 							}
385 385
 
386
-							if ( isset( $this->tokens[ $i ]['orig_content'] ) ) {
387
-								$replacement .= $this->tokens[ $i ]['orig_content'];
386
+							if ( isset( $this->tokens[ $i ][ 'orig_content' ] ) ) {
387
+								$replacement .= $this->tokens[ $i ][ 'orig_content' ];
388 388
 							} else {
389
-								$replacement .= $this->tokens[ $i ]['content'];
389
+								$replacement .= $this->tokens[ $i ][ 'content' ];
390 390
 							}
391 391
 						}
392 392
 
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
 						$replacement = ", '{$this->new_text_domain}'";
396 396
 					}
397 397
 
398
-					if ( \T_WHITESPACE === $this->tokens[ $end_previous ]['code'] ) {
398
+					if ( \T_WHITESPACE === $this->tokens[ $end_previous ][ 'code' ] ) {
399 399
 						$this->phpcsFile->fixer->addContentBefore( $end_previous, $replacement );
400 400
 					} else {
401 401
 						$this->phpcsFile->fixer->addContent( $end_previous, $replacement );
@@ -413,16 +413,16 @@  discard block
 block discarded – undo
413 413
 		}
414 414
 
415 415
 		// Target parameter found. Let's examine it.
416
-		$domain_param_start = $parameters[ $target_param ]['start'];
417
-		$domain_param_end   = $parameters[ $target_param ]['end'];
416
+		$domain_param_start = $parameters[ $target_param ][ 'start' ];
417
+		$domain_param_end   = $parameters[ $target_param ][ 'end' ];
418 418
 		$domain_token       = null;
419 419
 
420 420
 		for ( $i = $domain_param_start; $i <= $domain_param_end; $i++ ) {
421
-			if ( isset( Tokens::$emptyTokens[ $this->tokens[ $i ]['code'] ] ) ) {
421
+			if ( isset( Tokens::$emptyTokens[ $this->tokens[ $i ][ 'code' ] ] ) ) {
422 422
 				continue;
423 423
 			}
424 424
 
425
-			if ( \T_CONSTANT_ENCAPSED_STRING !== $this->tokens[ $i ]['code'] ) {
425
+			if ( \T_CONSTANT_ENCAPSED_STRING !== $this->tokens[ $i ][ 'code' ] ) {
426 426
 				// Unexpected token found, not our concern. This is handled by the I18n sniff.
427 427
 				return;
428 428
 			}
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 		}
437 437
 
438 438
 		// If we're still here, this means only one T_CONSTANT_ENCAPSED_STRING was found.
439
-		$old_domain = $this->strip_quotes( $this->tokens[ $domain_token ]['content'] );
439
+		$old_domain = $this->strip_quotes( $this->tokens[ $domain_token ][ 'content' ] );
440 440
 
441 441
 		if ( ! \in_array( $old_domain, $this->old_text_domain, true ) ) {
442 442
 			// Not a text domain targetted for replacement, ignore.
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
 		);
452 452
 
453 453
 		if ( true === $fix ) {
454
-			$replacement = str_replace( $old_domain, $this->new_text_domain, $this->tokens[ $domain_token ]['content'] );
454
+			$replacement = str_replace( $old_domain, $this->new_text_domain, $this->tokens[ $domain_token ][ 'content' ] );
455 455
 			$this->phpcsFile->fixer->replaceToken( $domain_token, $replacement );
456 456
 		}
457 457
 	}
@@ -478,8 +478,8 @@  discard block
 block discarded – undo
478 478
 		}
479 479
 
480 480
 		$opener = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true );
481
-		if ( \T_OPEN_PARENTHESIS !== $this->tokens[ $opener ]['code']
482
-			|| isset( $this->tokens[ $opener ]['parenthesis_closer'] ) === false
481
+		if ( \T_OPEN_PARENTHESIS !== $this->tokens[ $opener ][ 'code' ]
482
+			|| isset( $this->tokens[ $opener ][ 'parenthesis_closer' ] ) === false
483 483
 		) {
484 484
 			// Parse error or live coding.
485 485
 			return;
@@ -487,21 +487,21 @@  discard block
 block discarded – undo
487 487
 
488 488
 		$fix = $this->phpcsFile->addFixableError( 'Missing $domain arg', $stackPtr, 'MissingArgDomain' );
489 489
 		if ( true === $fix ) {
490
-			$closer      = $this->tokens[ $opener ]['parenthesis_closer'];
490
+			$closer      = $this->tokens[ $opener ][ 'parenthesis_closer' ];
491 491
 			$replacement = " '{$this->new_text_domain}' ";
492 492
 
493
-			if ( $this->tokens[ $opener ]['line'] !== $this->tokens[ $closer ]['line'] ) {
493
+			if ( $this->tokens[ $opener ][ 'line' ] !== $this->tokens[ $closer ][ 'line' ] ) {
494 494
 				$replacement = trim( $replacement );
495 495
 				$addBefore   = ( $closer - 1 );
496
-				if ( \T_WHITESPACE === $this->tokens[ ( $closer - 1 ) ]['code']
497
-					&& $this->tokens[ $closer - 1 ]['line'] === $this->tokens[ $closer ]['line']
496
+				if ( \T_WHITESPACE === $this->tokens[ ( $closer - 1 ) ][ 'code' ]
497
+					&& $this->tokens[ $closer - 1 ][ 'line' ] === $this->tokens[ $closer ][ 'line' ]
498 498
 				) {
499
-					if ( isset( $this->tokens[ ( $closer - 1 ) ]['orig_content'] ) ) {
500
-						$replacement = $this->tokens[ ( $closer - 1 ) ]['orig_content']
499
+					if ( isset( $this->tokens[ ( $closer - 1 ) ][ 'orig_content' ] ) ) {
500
+						$replacement = $this->tokens[ ( $closer - 1 ) ][ 'orig_content' ]
501 501
 							. "\t"
502 502
 							. $replacement;
503 503
 					} else {
504
-						$replacement = $this->tokens[ ( $closer - 1 ) ]['content']
504
+						$replacement = $this->tokens[ ( $closer - 1 ) ][ 'content' ]
505 505
 							. str_repeat( ' ', $this->tab_width )
506 506
 							. $replacement;
507 507
 					}
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
 
517 517
 				$this->phpcsFile->fixer->addContentBefore( $addBefore, $replacement );
518 518
 
519
-			} elseif ( \T_WHITESPACE === $this->tokens[ ( $closer - 1 ) ]['code'] ) {
519
+			} elseif ( \T_WHITESPACE === $this->tokens[ ( $closer - 1 ) ][ 'code' ] ) {
520 520
 				$this->phpcsFile->fixer->replaceToken( ( $closer - 1 ), $replacement );
521 521
 			} else {
522 522
 				$this->phpcsFile->fixer->addContentBefore( $closer, $replacement );
@@ -570,45 +570,45 @@  discard block
 block discarded – undo
570 570
 			'last_header_matches'   => array(),
571 571
 		);
572 572
 
573
-		if ( \T_COMMENT === $this->tokens[ $stackPtr ]['code'] ) {
573
+		if ( \T_COMMENT === $this->tokens[ $stackPtr ][ 'code' ] ) {
574 574
 			$block_comment = false;
575
-			if ( substr( $this->tokens[ $stackPtr ]['content'], 0, 2 ) === '/*' ) {
575
+			if ( substr( $this->tokens[ $stackPtr ][ 'content' ], 0, 2 ) === '/*' ) {
576 576
 				$block_comment = true;
577 577
 			}
578 578
 
579 579
 			$current = $stackPtr;
580 580
 			do {
581
-				if ( false === $comment_details['text_domain_ptr']
582
-					|| false === $comment_details['required_header_found']
583
-					|| $comment_details['headers_found'] < 3
581
+				if ( false === $comment_details[ 'text_domain_ptr' ]
582
+					|| false === $comment_details[ 'required_header_found' ]
583
+					|| $comment_details[ 'headers_found' ] < 3
584 584
 				) {
585 585
 					$comment_details = $this->examine_comment_line( $current, $regex, $headers, $comment_details );
586 586
 				}
587 587
 
588
-				if ( true === $block_comment && substr( $this->tokens[ $current ]['content'], -2 ) === '*/' ) {
588
+				if ( true === $block_comment && substr( $this->tokens[ $current ][ 'content' ], -2 ) === '*/' ) {
589 589
 					++$current;
590 590
 					break;
591 591
 				}
592 592
 
593 593
 				++$current;
594
-			} while ( isset( $this->tokens[ $current ] ) && \T_COMMENT === $this->tokens[ $current ]['code'] );
594
+			} while ( isset( $this->tokens[ $current ] ) && \T_COMMENT === $this->tokens[ $current ][ 'code' ] );
595 595
 
596 596
 			$skip_to = $current;
597 597
 
598 598
 		} else {
599
-			if ( ! isset( $this->tokens[ $stackPtr ]['comment_closer'] ) ) {
599
+			if ( ! isset( $this->tokens[ $stackPtr ][ 'comment_closer' ] ) ) {
600 600
 				return;
601 601
 			}
602 602
 
603
-			$closer  = $this->tokens[ $stackPtr ]['comment_closer'];
603
+			$closer  = $this->tokens[ $stackPtr ][ 'comment_closer' ];
604 604
 			$current = $stackPtr;
605 605
 
606 606
 			while ( ( $current = $this->phpcsFile->findNext( \T_DOC_COMMENT_STRING, ( $current + 1 ), $closer ) ) !== false ) {
607 607
 				$comment_details = $this->examine_comment_line( $current, $regex, $headers, $comment_details );
608 608
 
609
-				if ( false !== $comment_details['text_domain_ptr']
610
-					&& true === $comment_details['required_header_found']
611
-					&& $comment_details['headers_found'] >= 3
609
+				if ( false !== $comment_details[ 'text_domain_ptr' ]
610
+					&& true === $comment_details[ 'required_header_found' ]
611
+					&& $comment_details[ 'headers_found' ] >= 3
612 612
 				) {
613 613
 					// No need to look at the rest of the docblock.
614 614
 					break;
@@ -619,13 +619,13 @@  discard block
 block discarded – undo
619 619
 		}
620 620
 
621 621
 		// So, was this the plugin/theme header ?
622
-		if ( true === $comment_details['required_header_found']
623
-			&& $comment_details['headers_found'] >= 3
622
+		if ( true === $comment_details[ 'required_header_found' ]
623
+			&& $comment_details[ 'headers_found' ] >= 3
624 624
 		) {
625 625
 			$this->header_found = true;
626 626
 
627
-			$text_domain_ptr   = $comment_details['text_domain_ptr'];
628
-			$text_domain_found = $comment_details['text_domain_found'];
627
+			$text_domain_ptr   = $comment_details[ 'text_domain_ptr' ];
628
+			$text_domain_found = $comment_details[ 'text_domain_found' ];
629 629
 
630 630
 			if ( false !== $text_domain_ptr ) {
631 631
 				if ( $this->new_text_domain !== $text_domain_found
@@ -643,10 +643,10 @@  discard block
 block discarded – undo
643 643
 					);
644 644
 
645 645
 					if ( true === $fix ) {
646
-						if ( isset( $this->tokens[ $text_domain_ptr ]['orig_content'] ) ) {
647
-							$replacement = $this->tokens[ $text_domain_ptr ]['orig_content'];
646
+						if ( isset( $this->tokens[ $text_domain_ptr ][ 'orig_content' ] ) ) {
647
+							$replacement = $this->tokens[ $text_domain_ptr ][ 'orig_content' ];
648 648
 						} else {
649
-							$replacement = $this->tokens[ $text_domain_ptr ]['content'];
649
+							$replacement = $this->tokens[ $text_domain_ptr ][ 'content' ];
650 650
 						}
651 651
 
652 652
 						$replacement = str_replace( $text_domain_found, $this->new_text_domain, $replacement );
@@ -655,8 +655,8 @@  discard block
 block discarded – undo
655 655
 					}
656 656
 				}
657 657
 			} else {
658
-				$last_header_ptr     = $comment_details['last_header_ptr'];
659
-				$last_header_matches = $comment_details['last_header_matches'];
658
+				$last_header_ptr     = $comment_details[ 'last_header_ptr' ];
659
+				$last_header_matches = $comment_details[ 'last_header_matches' ];
660 660
 
661 661
 				$fix = $this->phpcsFile->addFixableError(
662 662
 					'Missing "Text Domain" in %s header',
@@ -666,18 +666,18 @@  discard block
 block discarded – undo
666 666
 				);
667 667
 
668 668
 				if ( true === $fix ) {
669
-					if ( isset( $this->tokens[ $last_header_ptr ]['orig_content'] ) ) {
670
-						$replacement = $this->tokens[ $last_header_ptr ]['orig_content'];
669
+					if ( isset( $this->tokens[ $last_header_ptr ][ 'orig_content' ] ) ) {
670
+						$replacement = $this->tokens[ $last_header_ptr ][ 'orig_content' ];
671 671
 					} else {
672
-						$replacement = $this->tokens[ $last_header_ptr ]['content'];
672
+						$replacement = $this->tokens[ $last_header_ptr ][ 'content' ];
673 673
 					}
674 674
 
675
-					$replacement = str_replace( $last_header_matches[1], 'Text Domain', $replacement );
676
-					$replacement = str_replace( $last_header_matches[2], $this->new_text_domain, $replacement );
675
+					$replacement = str_replace( $last_header_matches[ 1 ], 'Text Domain', $replacement );
676
+					$replacement = str_replace( $last_header_matches[ 2 ], $this->new_text_domain, $replacement );
677 677
 
678
-					if ( \T_DOC_COMMENT_OPEN_TAG === $this->tokens[ $stackPtr ]['code'] ) {
678
+					if ( \T_DOC_COMMENT_OPEN_TAG === $this->tokens[ $stackPtr ][ 'code' ] ) {
679 679
 						for ( $i = ( $last_header_ptr - 1 ); ; $i-- ) {
680
-							if ( $this->tokens[ $i ]['line'] !== $this->tokens[ $last_header_ptr ]['line'] ) {
680
+							if ( $this->tokens[ $i ][ 'line' ] !== $this->tokens[ $last_header_ptr ][ 'line' ] ) {
681 681
 								++$i;
682 682
 								break;
683 683
 							}
@@ -688,7 +688,7 @@  discard block
 block discarded – undo
688 688
 							. $replacement;
689 689
 					}
690 690
 
691
-					$this->phpcsFile->fixer->addContent( $comment_details['last_header_ptr'], $replacement );
691
+					$this->phpcsFile->fixer->addContent( $comment_details[ 'last_header_ptr' ], $replacement );
692 692
 				}
693 693
 			}
694 694
 		}
@@ -709,20 +709,20 @@  discard block
 block discarded – undo
709 709
 	 * @return array Adjusted $comment_details array
710 710
 	 */
711 711
 	protected function examine_comment_line( $stackPtr, $regex, $headers, $comment_details ) {
712
-		if ( preg_match( $regex, $this->tokens[ $stackPtr ]['content'], $matches ) === 1 ) {
713
-			++$comment_details['headers_found'];
712
+		if ( preg_match( $regex, $this->tokens[ $stackPtr ][ 'content' ], $matches ) === 1 ) {
713
+			++$comment_details[ 'headers_found' ];
714 714
 
715
-			if ( true === $headers[ $matches[1] ] ) {
716
-				$comment_details['required_header_found'] = true;
715
+			if ( true === $headers[ $matches[ 1 ] ] ) {
716
+				$comment_details[ 'required_header_found' ] = true;
717 717
 			}
718 718
 
719
-			if ( 'Text Domain' === $matches[1] ) {
720
-				$comment_details['text_domain_ptr']   = $stackPtr;
721
-				$comment_details['text_domain_found'] = trim( $matches[2] );
719
+			if ( 'Text Domain' === $matches[ 1 ] ) {
720
+				$comment_details[ 'text_domain_ptr' ]   = $stackPtr;
721
+				$comment_details[ 'text_domain_found' ] = trim( $matches[ 2 ] );
722 722
 			}
723 723
 
724
-			$comment_details['last_header_ptr']     = $stackPtr;
725
-			$comment_details['last_header_matches'] = $matches;
724
+			$comment_details[ 'last_header_ptr' ]     = $stackPtr;
725
+			$comment_details[ 'last_header_matches' ] = $matches;
726 726
 		}
727 727
 
728 728
 		return $comment_details;
Please login to merge, or discard this patch.
wpcs/WordPress/Sniffs/Security/EscapeOutputSniff.php 2 patches
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -190,26 +190,26 @@  discard block
 block discarded – undo
190 190
 
191 191
 		$this->mergeFunctionLists();
192 192
 
193
-		$function = $this->tokens[ $stackPtr ]['content'];
193
+		$function = $this->tokens[ $stackPtr ][ 'content' ];
194 194
 
195 195
 		// Find the opening parenthesis (if present; T_ECHO might not have it).
196 196
 		$open_paren = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true );
197 197
 
198 198
 		// If function, not T_ECHO nor T_PRINT.
199
-		if ( \T_STRING === $this->tokens[ $stackPtr ]['code'] ) {
199
+		if ( \T_STRING === $this->tokens[ $stackPtr ][ 'code' ] ) {
200 200
 			// Skip if it is a function but is not one of the printing functions.
201
-			if ( ! isset( $this->printingFunctions[ $this->tokens[ $stackPtr ]['content'] ] ) ) {
201
+			if ( ! isset( $this->printingFunctions[ $this->tokens[ $stackPtr ][ 'content' ] ] ) ) {
202 202
 				return;
203 203
 			}
204 204
 
205
-			if ( isset( $this->tokens[ $open_paren ]['parenthesis_closer'] ) ) {
206
-				$end_of_statement = $this->tokens[ $open_paren ]['parenthesis_closer'];
205
+			if ( isset( $this->tokens[ $open_paren ][ 'parenthesis_closer' ] ) ) {
206
+				$end_of_statement = $this->tokens[ $open_paren ][ 'parenthesis_closer' ];
207 207
 			}
208 208
 
209 209
 			// These functions only need to have the first argument escaped.
210 210
 			if ( \in_array( $function, array( 'trigger_error', 'user_error' ), true ) ) {
211 211
 				$first_param      = $this->get_function_call_parameter( $stackPtr, 1 );
212
-				$end_of_statement = ( $first_param['end'] + 1 );
212
+				$end_of_statement = ( $first_param[ 'end' ] + 1 );
213 213
 				unset( $first_param );
214 214
 			}
215 215
 		}
@@ -243,13 +243,13 @@  discard block
 block discarded – undo
243 243
 
244 244
 			// Check for the ternary operator. We only need to do this here if this
245 245
 			// echo is lacking parenthesis. Otherwise it will be handled below.
246
-			if ( \T_OPEN_PARENTHESIS !== $this->tokens[ $open_paren ]['code'] || \T_CLOSE_PARENTHESIS !== $this->tokens[ $last_token ]['code'] ) {
246
+			if ( \T_OPEN_PARENTHESIS !== $this->tokens[ $open_paren ][ 'code' ] || \T_CLOSE_PARENTHESIS !== $this->tokens[ $last_token ][ 'code' ] ) {
247 247
 
248 248
 				$ternary = $this->phpcsFile->findNext( \T_INLINE_THEN, $stackPtr, $end_of_statement );
249 249
 
250 250
 				// If there is a ternary skip over the part before the ?. However, if
251 251
 				// the ternary is within parentheses, it will be handled in the loop.
252
-				if ( false !== $ternary && empty( $this->tokens[ $ternary ]['nested_parenthesis'] ) ) {
252
+				if ( false !== $ternary && empty( $this->tokens[ $ternary ][ 'nested_parenthesis' ] ) ) {
253 253
 					$stackPtr = $ternary;
254 254
 				}
255 255
 			}
@@ -265,18 +265,18 @@  discard block
 block discarded – undo
265 265
 		for ( $i = $stackPtr; $i < $end_of_statement; $i++ ) {
266 266
 
267 267
 			// Ignore whitespaces and comments.
268
-			if ( isset( Tokens::$emptyTokens[ $this->tokens[ $i ]['code'] ] ) ) {
268
+			if ( isset( Tokens::$emptyTokens[ $this->tokens[ $i ][ 'code' ] ] ) ) {
269 269
 				continue;
270 270
 			}
271 271
 
272 272
 			// Ignore namespace separators.
273
-			if ( \T_NS_SEPARATOR === $this->tokens[ $i ]['code'] ) {
273
+			if ( \T_NS_SEPARATOR === $this->tokens[ $i ][ 'code' ] ) {
274 274
 				continue;
275 275
 			}
276 276
 
277
-			if ( \T_OPEN_PARENTHESIS === $this->tokens[ $i ]['code'] ) {
277
+			if ( \T_OPEN_PARENTHESIS === $this->tokens[ $i ][ 'code' ] ) {
278 278
 
279
-				if ( ! isset( $this->tokens[ $i ]['parenthesis_closer'] ) ) {
279
+				if ( ! isset( $this->tokens[ $i ][ 'parenthesis_closer' ] ) ) {
280 280
 					// Live coding or parse error.
281 281
 					break;
282 282
 				}
@@ -284,20 +284,20 @@  discard block
 block discarded – undo
284 284
 				if ( $in_cast ) {
285 285
 
286 286
 					// Skip to the end of a function call if it has been casted to a safe value.
287
-					$i       = $this->tokens[ $i ]['parenthesis_closer'];
287
+					$i       = $this->tokens[ $i ][ 'parenthesis_closer' ];
288 288
 					$in_cast = false;
289 289
 
290 290
 				} else {
291 291
 
292 292
 					// Skip over the condition part of a ternary (i.e., to after the ?).
293
-					$ternary = $this->phpcsFile->findNext( \T_INLINE_THEN, $i, $this->tokens[ $i ]['parenthesis_closer'] );
293
+					$ternary = $this->phpcsFile->findNext( \T_INLINE_THEN, $i, $this->tokens[ $i ][ 'parenthesis_closer' ] );
294 294
 
295 295
 					if ( false !== $ternary ) {
296 296
 
297
-						$next_paren = $this->phpcsFile->findNext( \T_OPEN_PARENTHESIS, ( $i + 1 ), $this->tokens[ $i ]['parenthesis_closer'] );
297
+						$next_paren = $this->phpcsFile->findNext( \T_OPEN_PARENTHESIS, ( $i + 1 ), $this->tokens[ $i ][ 'parenthesis_closer' ] );
298 298
 
299 299
 						// We only do it if the ternary isn't within a subset of parentheses.
300
-						if ( false === $next_paren || ( isset( $this->tokens[ $next_paren ]['parenthesis_closer'] ) && $ternary > $this->tokens[ $next_paren ]['parenthesis_closer'] ) ) {
300
+						if ( false === $next_paren || ( isset( $this->tokens[ $next_paren ][ 'parenthesis_closer' ] ) && $ternary > $this->tokens[ $next_paren ][ 'parenthesis_closer' ] ) ) {
301 301
 							$i = $ternary;
302 302
 						}
303 303
 					}
@@ -307,48 +307,48 @@  discard block
 block discarded – undo
307 307
 			}
308 308
 
309 309
 			// Handle arrays for those functions that accept them.
310
-			if ( \T_ARRAY === $this->tokens[ $i ]['code'] ) {
310
+			if ( \T_ARRAY === $this->tokens[ $i ][ 'code' ] ) {
311 311
 				$i++; // Skip the opening parenthesis.
312 312
 				continue;
313 313
 			}
314 314
 
315
-			if ( \T_OPEN_SHORT_ARRAY === $this->tokens[ $i ]['code']
316
-				|| \T_CLOSE_SHORT_ARRAY === $this->tokens[ $i ]['code']
315
+			if ( \T_OPEN_SHORT_ARRAY === $this->tokens[ $i ][ 'code' ]
316
+				|| \T_CLOSE_SHORT_ARRAY === $this->tokens[ $i ][ 'code' ]
317 317
 			) {
318 318
 				continue;
319 319
 			}
320 320
 
321
-			if ( \in_array( $this->tokens[ $i ]['code'], array( \T_DOUBLE_ARROW, \T_CLOSE_PARENTHESIS ), true ) ) {
321
+			if ( \in_array( $this->tokens[ $i ][ 'code' ], array( \T_DOUBLE_ARROW, \T_CLOSE_PARENTHESIS ), true ) ) {
322 322
 				continue;
323 323
 			}
324 324
 
325 325
 			// Handle magic constants for debug functions.
326
-			if ( isset( $this->magic_constant_tokens[ $this->tokens[ $i ]['type'] ] ) ) {
326
+			if ( isset( $this->magic_constant_tokens[ $this->tokens[ $i ][ 'type' ] ] ) ) {
327 327
 				continue;
328 328
 			}
329 329
 
330 330
 			// Handle safe PHP native constants.
331
-			if ( \T_STRING === $this->tokens[ $i ]['code']
332
-				&& isset( $this->safe_php_constants[ $this->tokens[ $i ]['content'] ] )
331
+			if ( \T_STRING === $this->tokens[ $i ][ 'code' ]
332
+				&& isset( $this->safe_php_constants[ $this->tokens[ $i ][ 'content' ] ] )
333 333
 				&& $this->is_use_of_global_constant( $i )
334 334
 			) {
335 335
 				continue;
336 336
 			}
337 337
 
338 338
 			// Wake up on concatenation characters, another part to check.
339
-			if ( \T_STRING_CONCAT === $this->tokens[ $i ]['code'] ) {
339
+			if ( \T_STRING_CONCAT === $this->tokens[ $i ][ 'code' ] ) {
340 340
 				$watch = true;
341 341
 				continue;
342 342
 			}
343 343
 
344 344
 			// Wake up after a ternary else (:).
345
-			if ( false !== $ternary && \T_INLINE_ELSE === $this->tokens[ $i ]['code'] ) {
345
+			if ( false !== $ternary && \T_INLINE_ELSE === $this->tokens[ $i ][ 'code' ] ) {
346 346
 				$watch = true;
347 347
 				continue;
348 348
 			}
349 349
 
350 350
 			// Wake up for commas.
351
-			if ( \T_COMMA === $this->tokens[ $i ]['code'] ) {
351
+			if ( \T_COMMA === $this->tokens[ $i ][ 'code' ] ) {
352 352
 				$in_cast = false;
353 353
 				$watch   = true;
354 354
 				continue;
@@ -360,23 +360,23 @@  discard block
 block discarded – undo
360 360
 
361 361
 			// Allow T_CONSTANT_ENCAPSED_STRING eg: echo 'Some String';
362 362
 			// Also T_LNUMBER, e.g.: echo 45; exit -1; and booleans.
363
-			if ( isset( $this->safe_components[ $this->tokens[ $i ]['type'] ] ) ) {
363
+			if ( isset( $this->safe_components[ $this->tokens[ $i ][ 'type' ] ] ) ) {
364 364
 				continue;
365 365
 			}
366 366
 
367 367
 			$watch = false;
368 368
 
369 369
 			// Allow int/double/bool casted variables.
370
-			if ( isset( $this->safe_cast_tokens[ $this->tokens[ $i ]['type'] ] ) ) {
370
+			if ( isset( $this->safe_cast_tokens[ $this->tokens[ $i ][ 'type' ] ] ) ) {
371 371
 				$in_cast = true;
372 372
 				continue;
373 373
 			}
374 374
 
375 375
 			// Now check that next token is a function call.
376
-			if ( \T_STRING === $this->tokens[ $i ]['code'] ) {
376
+			if ( \T_STRING === $this->tokens[ $i ][ 'code' ] ) {
377 377
 
378 378
 				$ptr                    = $i;
379
-				$functionName           = $this->tokens[ $i ]['content'];
379
+				$functionName           = $this->tokens[ $i ][ 'content' ];
380 380
 				$function_opener        = $this->phpcsFile->findNext( \T_OPEN_PARENTHESIS, ( $i + 1 ), null, false, null, true );
381 381
 				$is_formatting_function = isset( $this->formattingFunctions[ $functionName ] );
382 382
 
@@ -397,15 +397,15 @@  discard block
 block discarded – undo
397 397
 							 */
398 398
 							$mapped_function = $this->phpcsFile->findNext(
399 399
 								Tokens::$emptyTokens,
400
-								$callback['start'],
401
-								( $callback['end'] + 1 ),
400
+								$callback[ 'start' ],
401
+								( $callback[ 'end' ] + 1 ),
402 402
 								true
403 403
 							);
404 404
 
405 405
 							if ( false !== $mapped_function
406
-								&& \T_CONSTANT_ENCAPSED_STRING === $this->tokens[ $mapped_function ]['code']
406
+								&& \T_CONSTANT_ENCAPSED_STRING === $this->tokens[ $mapped_function ][ 'code' ]
407 407
 							) {
408
-								$functionName = $this->strip_quotes( $this->tokens[ $mapped_function ]['content'] );
408
+								$functionName = $this->strip_quotes( $this->tokens[ $mapped_function ][ 'content' ] );
409 409
 								$ptr          = $mapped_function;
410 410
 							}
411 411
 						}
@@ -418,8 +418,8 @@  discard block
 block discarded – undo
418 418
 						$i     = ( $function_opener + 1 );
419 419
 						$watch = true;
420 420
 					} else {
421
-						if ( isset( $this->tokens[ $function_opener ]['parenthesis_closer'] ) ) {
422
-							$i = $this->tokens[ $function_opener ]['parenthesis_closer'];
421
+						if ( isset( $this->tokens[ $function_opener ][ 'parenthesis_closer' ] ) ) {
422
+							$i = $this->tokens[ $function_opener ][ 'parenthesis_closer' ];
423 423
 						} else {
424 424
 							// Live coding or parse error.
425 425
 							break;
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
 				$content = $functionName;
440 440
 
441 441
 			} else {
442
-				$content = $this->tokens[ $i ]['content'];
442
+				$content = $this->tokens[ $i ][ 'content' ];
443 443
 				$ptr     = $i;
444 444
 			}
445 445
 
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
 	 * @return void
463 463
 	 */
464 464
 	protected function mergeFunctionLists() {
465
-		if ( $this->customEscapingFunctions !== $this->addedCustomFunctions['escape'] ) {
465
+		if ( $this->customEscapingFunctions !== $this->addedCustomFunctions[ 'escape' ] ) {
466 466
 			$customEscapeFunctions = $this->merge_custom_array( $this->customEscapingFunctions, array(), false );
467 467
 
468 468
 			$this->escapingFunctions = $this->merge_custom_array(
@@ -470,26 +470,26 @@  discard block
 block discarded – undo
470 470
 				$this->escapingFunctions
471 471
 			);
472 472
 
473
-			$this->addedCustomFunctions['escape'] = $this->customEscapingFunctions;
473
+			$this->addedCustomFunctions[ 'escape' ] = $this->customEscapingFunctions;
474 474
 		}
475 475
 
476
-		if ( $this->customAutoEscapedFunctions !== $this->addedCustomFunctions['autoescape'] ) {
476
+		if ( $this->customAutoEscapedFunctions !== $this->addedCustomFunctions[ 'autoescape' ] ) {
477 477
 			$this->autoEscapedFunctions = $this->merge_custom_array(
478 478
 				$this->customAutoEscapedFunctions,
479 479
 				$this->autoEscapedFunctions
480 480
 			);
481 481
 
482
-			$this->addedCustomFunctions['autoescape'] = $this->customAutoEscapedFunctions;
482
+			$this->addedCustomFunctions[ 'autoescape' ] = $this->customAutoEscapedFunctions;
483 483
 		}
484 484
 
485
-		if ( $this->customPrintingFunctions !== $this->addedCustomFunctions['print'] ) {
485
+		if ( $this->customPrintingFunctions !== $this->addedCustomFunctions[ 'print' ] ) {
486 486
 
487 487
 			$this->printingFunctions = $this->merge_custom_array(
488 488
 				$this->customPrintingFunctions,
489 489
 				$this->printingFunctions
490 490
 			);
491 491
 
492
-			$this->addedCustomFunctions['print'] = $this->customPrintingFunctions;
492
+			$this->addedCustomFunctions[ 'print' ] = $this->customPrintingFunctions;
493 493
 		}
494 494
 	}
495 495
 
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -165,7 +165,7 @@
 block discarded – undo
165 165
 	/**
166 166
 	 * Returns an array of tokens this test wants to listen for.
167 167
 	 *
168
-	 * @return array
168
+	 * @return integer[]
169 169
 	 */
170 170
 	public function register() {
171 171
 
Please login to merge, or discard this patch.
wpcs/WordPress/Sniffs/Security/NonceVerificationSniff.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 
108 108
 		$instance = $this->tokens[ $stackPtr ];
109 109
 
110
-		if ( ! isset( $this->superglobals[ $instance['content'] ] ) ) {
110
+		if ( ! isset( $this->superglobals[ $instance[ 'content' ] ] ) ) {
111 111
 			return;
112 112
 		}
113 113
 
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 		}
127 127
 
128 128
 		$error_code = 'Missing';
129
-		if ( false === $this->superglobals[ $instance['content'] ] ) {
129
+		if ( false === $this->superglobals[ $instance[ 'content' ] ] ) {
130 130
 			$error_code = 'Recommended';
131 131
 		}
132 132
 
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 		$this->addMessage(
135 135
 			'Processing form data without nonce verification.',
136 136
 			$stackPtr,
137
-			$this->superglobals[ $instance['content'] ],
137
+			$this->superglobals[ $instance[ 'content' ] ],
138 138
 			$error_code
139 139
 		);
140 140
 	}
@@ -147,31 +147,31 @@  discard block
 block discarded – undo
147 147
 	 * @return void
148 148
 	 */
149 149
 	protected function mergeFunctionLists() {
150
-		if ( $this->customNonceVerificationFunctions !== $this->addedCustomFunctions['nonce'] ) {
150
+		if ( $this->customNonceVerificationFunctions !== $this->addedCustomFunctions[ 'nonce' ] ) {
151 151
 			$this->nonceVerificationFunctions = $this->merge_custom_array(
152 152
 				$this->customNonceVerificationFunctions,
153 153
 				$this->nonceVerificationFunctions
154 154
 			);
155 155
 
156
-			$this->addedCustomFunctions['nonce'] = $this->customNonceVerificationFunctions;
156
+			$this->addedCustomFunctions[ 'nonce' ] = $this->customNonceVerificationFunctions;
157 157
 		}
158 158
 
159
-		if ( $this->customSanitizingFunctions !== $this->addedCustomFunctions['sanitize'] ) {
159
+		if ( $this->customSanitizingFunctions !== $this->addedCustomFunctions[ 'sanitize' ] ) {
160 160
 			$this->sanitizingFunctions = $this->merge_custom_array(
161 161
 				$this->customSanitizingFunctions,
162 162
 				$this->sanitizingFunctions
163 163
 			);
164 164
 
165
-			$this->addedCustomFunctions['sanitize'] = $this->customSanitizingFunctions;
165
+			$this->addedCustomFunctions[ 'sanitize' ] = $this->customSanitizingFunctions;
166 166
 		}
167 167
 
168
-		if ( $this->customUnslashingSanitizingFunctions !== $this->addedCustomFunctions['unslashsanitize'] ) {
168
+		if ( $this->customUnslashingSanitizingFunctions !== $this->addedCustomFunctions[ 'unslashsanitize' ] ) {
169 169
 			$this->unslashingSanitizingFunctions = $this->merge_custom_array(
170 170
 				$this->customUnslashingSanitizingFunctions,
171 171
 				$this->unslashingSanitizingFunctions
172 172
 			);
173 173
 
174
-			$this->addedCustomFunctions['unslashsanitize'] = $this->customUnslashingSanitizingFunctions;
174
+			$this->addedCustomFunctions[ 'unslashsanitize' ] = $this->customUnslashingSanitizingFunctions;
175 175
 		}
176 176
 	}
177 177
 
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -165,7 +165,7 @@
 block discarded – undo
165 165
 	/**
166 166
 	 * Returns an array of tokens this test wants to listen for.
167 167
 	 *
168
-	 * @return array
168
+	 * @return integer[]
169 169
 	 */
170 170
 	public function register() {
171 171
 
Please login to merge, or discard this patch.
wpcs/WordPress/Sniffs/Security/ValidatedSanitizedInputSniff.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -93,24 +93,24 @@  discard block
 block discarded – undo
93 93
 		$superglobals = $this->input_superglobals;
94 94
 
95 95
 		// Handling string interpolation.
96
-		if ( \T_DOUBLE_QUOTED_STRING === $this->tokens[ $stackPtr ]['code']
97
-			|| \T_HEREDOC === $this->tokens[ $stackPtr ]['code']
96
+		if ( \T_DOUBLE_QUOTED_STRING === $this->tokens[ $stackPtr ][ 'code' ]
97
+			|| \T_HEREDOC === $this->tokens[ $stackPtr ][ 'code' ]
98 98
 		) {
99 99
 			$interpolated_variables = array_map(
100
-				function ( $symbol ) {
100
+				function( $symbol ) {
101 101
 					return '$' . $symbol;
102 102
 				},
103
-				$this->get_interpolated_variables( $this->tokens[ $stackPtr ]['content'] )
103
+				$this->get_interpolated_variables( $this->tokens[ $stackPtr ][ 'content' ] )
104 104
 			);
105 105
 			foreach ( array_intersect( $interpolated_variables, $superglobals ) as $bad_variable ) {
106
-				$this->phpcsFile->addError( 'Detected usage of a non-sanitized, non-validated input variable %s: %s', $stackPtr, 'InputNotValidatedNotSanitized', array( $bad_variable, $this->tokens[ $stackPtr ]['content'] ) );
106
+				$this->phpcsFile->addError( 'Detected usage of a non-sanitized, non-validated input variable %s: %s', $stackPtr, 'InputNotValidatedNotSanitized', array( $bad_variable, $this->tokens[ $stackPtr ][ 'content' ] ) );
107 107
 			}
108 108
 
109 109
 			return;
110 110
 		}
111 111
 
112 112
 		// Check if this is a superglobal.
113
-		if ( ! \in_array( $this->tokens[ $stackPtr ]['content'], $superglobals, true ) ) {
113
+		if ( ! \in_array( $this->tokens[ $stackPtr ][ 'content' ], $superglobals, true ) ) {
114 114
 			return;
115 115
 		}
116 116
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 			return;
131 131
 		}
132 132
 
133
-		$error_data = array( $this->tokens[ $stackPtr ]['content'] . '[' . implode( '][', $array_keys ) . ']' );
133
+		$error_data = array( $this->tokens[ $stackPtr ][ 'content' ] . '[' . implode( '][', $array_keys ) . ']' );
134 134
 
135 135
 		/*
136 136
 		 * Check for validation first.
@@ -138,19 +138,19 @@  discard block
 block discarded – undo
138 138
 		$validated = false;
139 139
 
140 140
 		for ( $i = ( $stackPtr + 1 ); $i < $this->phpcsFile->numTokens; $i++ ) {
141
-			if ( isset( Tokens::$emptyTokens[ $this->tokens[ $i ]['code'] ] ) ) {
141
+			if ( isset( Tokens::$emptyTokens[ $this->tokens[ $i ][ 'code' ] ] ) ) {
142 142
 				continue;
143 143
 			}
144 144
 
145
-			if ( \T_OPEN_SQUARE_BRACKET === $this->tokens[ $i ]['code']
146
-				&& isset( $this->tokens[ $i ]['bracket_closer'] )
145
+			if ( \T_OPEN_SQUARE_BRACKET === $this->tokens[ $i ][ 'code' ]
146
+				&& isset( $this->tokens[ $i ][ 'bracket_closer' ] )
147 147
 			) {
148 148
 				// Skip over array keys.
149
-				$i = $this->tokens[ $i ]['bracket_closer'];
149
+				$i = $this->tokens[ $i ][ 'bracket_closer' ];
150 150
 				continue;
151 151
 			}
152 152
 
153
-			if ( \T_COALESCE === $this->tokens[ $i ]['code'] ) {
153
+			if ( \T_COALESCE === $this->tokens[ $i ][ 'code' ] ) {
154 154
 				$validated = true;
155 155
 			}
156 156
 
@@ -211,22 +211,22 @@  discard block
 block discarded – undo
211 211
 	 * @return void
212 212
 	 */
213 213
 	protected function mergeFunctionLists() {
214
-		if ( $this->customSanitizingFunctions !== $this->addedCustomFunctions['sanitize'] ) {
214
+		if ( $this->customSanitizingFunctions !== $this->addedCustomFunctions[ 'sanitize' ] ) {
215 215
 			$this->sanitizingFunctions = $this->merge_custom_array(
216 216
 				$this->customSanitizingFunctions,
217 217
 				$this->sanitizingFunctions
218 218
 			);
219 219
 
220
-			$this->addedCustomFunctions['sanitize'] = $this->customSanitizingFunctions;
220
+			$this->addedCustomFunctions[ 'sanitize' ] = $this->customSanitizingFunctions;
221 221
 		}
222 222
 
223
-		if ( $this->customUnslashingSanitizingFunctions !== $this->addedCustomFunctions['unslashsanitize'] ) {
223
+		if ( $this->customUnslashingSanitizingFunctions !== $this->addedCustomFunctions[ 'unslashsanitize' ] ) {
224 224
 			$this->unslashingSanitizingFunctions = $this->merge_custom_array(
225 225
 				$this->customUnslashingSanitizingFunctions,
226 226
 				$this->unslashingSanitizingFunctions
227 227
 			);
228 228
 
229
-			$this->addedCustomFunctions['unslashsanitize'] = $this->customUnslashingSanitizingFunctions;
229
+			$this->addedCustomFunctions[ 'unslashsanitize' ] = $this->customUnslashingSanitizingFunctions;
230 230
 		}
231 231
 	}
232 232
 
Please login to merge, or discard this patch.
wpcs/WordPress/Sniffs/Security/PluginMenuSlugSniff.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@
 block discarded – undo
77 77
 	public function process_parameters( $stackPtr, $group_name, $matched_content, $parameters ) {
78 78
 		foreach ( $this->target_functions[ $matched_content ] as $position ) {
79 79
 			if ( isset( $parameters[ $position ] ) ) {
80
-				$file_constant = $this->phpcsFile->findNext( \T_FILE, $parameters[ $position ]['start'], ( $parameters[ $position ]['end'] + 1 ) );
80
+				$file_constant = $this->phpcsFile->findNext( \T_FILE, $parameters[ $position ][ 'start' ], ( $parameters[ $position ][ 'end' ] + 1 ) );
81 81
 
82 82
 				if ( false !== $file_constant ) {
83 83
 					$this->phpcsFile->addWarning( 'Using __FILE__ for menu slugs risks exposing filesystem structure.', $stackPtr, 'Using__FILE__' );
Please login to merge, or discard this patch.
wpcs/WordPress/Sniffs/NamingConventions/ValidVariableNameSniff.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 	protected function processVariable( File $phpcs_file, $stack_ptr ) {
108 108
 
109 109
 		$tokens   = $phpcs_file->getTokens();
110
-		$var_name = ltrim( $tokens[ $stack_ptr ]['content'], '$' );
110
+		$var_name = ltrim( $tokens[ $stack_ptr ][ 'content' ], '$' );
111 111
 
112 112
 		// If it's a php reserved var, then its ok.
113 113
 		if ( isset( $this->phpReservedVars[ $var_name ] ) ) {
@@ -123,13 +123,13 @@  discard block
 block discarded – undo
123 123
 		}
124 124
 
125 125
 		$obj_operator = $phpcs_file->findNext( Tokens::$emptyTokens, ( $stack_ptr + 1 ), null, true );
126
-		if ( \T_OBJECT_OPERATOR === $tokens[ $obj_operator ]['code'] ) {
126
+		if ( \T_OBJECT_OPERATOR === $tokens[ $obj_operator ][ 'code' ] ) {
127 127
 			// Check to see if we are using a variable from an object.
128 128
 			$var = $phpcs_file->findNext( Tokens::$emptyTokens, ( $obj_operator + 1 ), null, true );
129
-			if ( \T_STRING === $tokens[ $var ]['code'] ) {
129
+			if ( \T_STRING === $tokens[ $var ][ 'code' ] ) {
130 130
 				$bracket = $phpcs_file->findNext( Tokens::$emptyTokens, ( $var + 1 ), null, true );
131
-				if ( \T_OPEN_PARENTHESIS !== $tokens[ $bracket ]['code'] ) {
132
-					$obj_var_name = $tokens[ $var ]['content'];
131
+				if ( \T_OPEN_PARENTHESIS !== $tokens[ $bracket ][ 'code' ] ) {
132
+					$obj_var_name = $tokens[ $var ][ 'content' ];
133 133
 
134 134
 					// There is no way for us to know if the var is public or
135 135
 					// private, so we have to ignore a leading underscore if there is
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 
154 154
 		$in_class     = false;
155 155
 		$obj_operator = $phpcs_file->findPrevious( Tokens::$emptyTokens, ( $stack_ptr - 1 ), null, true );
156
-		if ( \T_DOUBLE_COLON === $tokens[ $obj_operator ]['code'] || \T_OBJECT_OPERATOR === $tokens[ $obj_operator ]['code'] ) {
156
+		if ( \T_DOUBLE_COLON === $tokens[ $obj_operator ][ 'code' ] || \T_OBJECT_OPERATOR === $tokens[ $obj_operator ][ 'code' ] ) {
157 157
 			// The variable lives within a class, and is referenced like
158 158
 			// this: MyClass::$_variable or $class->variable.
159 159
 			$in_class = true;
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 
200 200
 		$tokens = $phpcs_file->getTokens();
201 201
 
202
-		$var_name     = ltrim( $tokens[ $stack_ptr ]['content'], '$' );
202
+		$var_name     = ltrim( $tokens[ $stack_ptr ][ 'content' ], '$' );
203 203
 		$member_props = $phpcs_file->getMemberProperties( $stack_ptr );
204 204
 		if ( empty( $member_props ) ) {
205 205
 			// Couldn't get any info about this variable, which
@@ -235,12 +235,12 @@  discard block
 block discarded – undo
235 235
 
236 236
 		$tokens = $phpcs_file->getTokens();
237 237
 
238
-		if ( preg_match_all( '|[^\\\]\${?([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)|', $tokens[ $stack_ptr ]['content'], $matches ) > 0 ) {
238
+		if ( preg_match_all( '|[^\\\]\${?([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)|', $tokens[ $stack_ptr ][ 'content' ], $matches ) > 0 ) {
239 239
 
240 240
 			// Merge any custom variables with the defaults.
241 241
 			$this->mergeWhiteList();
242 242
 
243
-			foreach ( $matches[1] as $var_name ) {
243
+			foreach ( $matches[ 1 ] as $var_name ) {
244 244
 				// If it's a php reserved var, then its ok.
245 245
 				if ( isset( $this->phpReservedVars[ $var_name ] ) ) {
246 246
 					continue;
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 	 * @return bool
271 271
 	 */
272 272
 	public static function isSnakeCase( $var_name ) {
273
-		return (bool) preg_match( '/^[a-z0-9_]+$/', $var_name );
273
+		return (bool)preg_match( '/^[a-z0-9_]+$/', $var_name );
274 274
 	}
275 275
 
276 276
 	/**
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 	 * @return void
284 284
 	 */
285 285
 	protected function mergeWhiteList() {
286
-		if ( $this->customPropertiesWhitelist !== $this->addedCustomProperties['properties'] ) {
286
+		if ( $this->customPropertiesWhitelist !== $this->addedCustomProperties[ 'properties' ] ) {
287 287
 			// Fix property potentially passed as comma-delimited string.
288 288
 			$customProperties = Sniff::merge_custom_array( $this->customPropertiesWhitelist, array(), false );
289 289
 
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 				$this->whitelisted_mixed_case_member_var_names
293 293
 			);
294 294
 
295
-			$this->addedCustomProperties['properties'] = $this->customPropertiesWhitelist;
295
+			$this->addedCustomProperties[ 'properties' ] = $this->customPropertiesWhitelist;
296 296
 		}
297 297
 	}
298 298
 
Please login to merge, or discard this patch.
wpcs/WordPress/Sniffs/NamingConventions/ValidHookNameSniff.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 			return;
94 94
 		}
95 95
 
96
-		if ( ! isset( $parameters[1] ) ) {
96
+		if ( ! isset( $parameters[ 1 ] ) ) {
97 97
 			return;
98 98
 		}
99 99
 
@@ -104,18 +104,18 @@  discard block
 block discarded – undo
104 104
 		$content     = array();
105 105
 		$expected    = array();
106 106
 
107
-		for ( $i = $parameters[1]['start']; $i <= $parameters[1]['end']; $i++ ) {
108
-			$content[ $i ]  = $this->tokens[ $i ]['content'];
109
-			$expected[ $i ] = $this->tokens[ $i ]['content'];
107
+		for ( $i = $parameters[ 1 ][ 'start' ]; $i <= $parameters[ 1 ][ 'end' ]; $i++ ) {
108
+			$content[ $i ]  = $this->tokens[ $i ][ 'content' ];
109
+			$expected[ $i ] = $this->tokens[ $i ][ 'content' ];
110 110
 
111
-			if ( \in_array( $this->tokens[ $i ]['code'], array( \T_CONSTANT_ENCAPSED_STRING, \T_DOUBLE_QUOTED_STRING ), true ) ) {
112
-				$string = $this->strip_quotes( $this->tokens[ $i ]['content'] );
111
+			if ( \in_array( $this->tokens[ $i ][ 'code' ], array( \T_CONSTANT_ENCAPSED_STRING, \T_DOUBLE_QUOTED_STRING ), true ) ) {
112
+				$string = $this->strip_quotes( $this->tokens[ $i ][ 'content' ] );
113 113
 
114 114
 				/*
115 115
 				 * Here be dragons - a double quoted string can contain extrapolated variables
116 116
 				 * which don't have to comply with these rules.
117 117
 				 */
118
-				if ( \T_DOUBLE_QUOTED_STRING === $this->tokens[ $i ]['code'] ) {
118
+				if ( \T_DOUBLE_QUOTED_STRING === $this->tokens[ $i ][ 'code' ] ) {
119 119
 					$transform       = $this->transform_complex_string( $string, $regex );
120 120
 					$case_transform  = $this->transform_complex_string( $string, $regex, 'case' );
121 121
 					$punct_transform = $this->transform_complex_string( $string, $regex, 'punctuation' );
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 					continue;
130 130
 				}
131 131
 
132
-				if ( \T_DOUBLE_QUOTED_STRING === $this->tokens[ $i ]['code'] ) {
132
+				if ( \T_DOUBLE_QUOTED_STRING === $this->tokens[ $i ][ 'code' ] ) {
133 133
 					$expected[ $i ] = '"' . $transform . '"';
134 134
 				} else {
135 135
 					$expected[ $i ] = '\'' . $transform . '\'';
Please login to merge, or discard this patch.