Completed
Pull Request — develop (#1492)
by
unknown
16:55 queued 12s
created
wpcs/WordPress/Sniffs/DB/PreparedSQLPlaceholdersSniff.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -150,7 +150,7 @@
 block discarded – undo
150 150
 	 *
151 151
 	 * @since 0.14.0
152 152
 	 *
153
-	 * @return array
153
+	 * @return integer[]
154 154
 	 */
155 155
 	public function register() {
156 156
 		return array(
Please login to merge, or discard this patch.
Spacing   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 			return;
180 180
 		}
181 181
 
182
-		$query                    = $parameters[1];
182
+		$query                    = $parameters[ 1 ];
183 183
 		$text_string_tokens_found = false;
184 184
 		$variable_found           = false;
185 185
 		$sql_wildcard_found       = false;
@@ -191,51 +191,51 @@  discard block
 block discarded – undo
191 191
 			'adjustment_count' => 0,
192 192
 		);
193 193
 
194
-		for ( $i = $query['start']; $i <= $query['end']; $i++ ) {
194
+		for ( $i = $query[ 'start' ]; $i <= $query[ 'end' ]; $i++ ) {
195 195
 			// Skip over groups of tokens if they are part of an inline function call.
196 196
 			if ( isset( $skip_from, $skip_to ) && $i >= $skip_from && $i < $skip_to ) {
197 197
 				$i = $skip_to;
198 198
 				continue;
199 199
 			}
200 200
 
201
-			if ( ! isset( Tokens::$textStringTokens[ $this->tokens[ $i ]['code'] ] ) ) {
202
-				if ( \T_VARIABLE === $this->tokens[ $i ]['code'] ) {
203
-					if ( '$wpdb' !== $this->tokens[ $i ]['content'] ) {
201
+			if ( ! isset( Tokens::$textStringTokens[ $this->tokens[ $i ][ 'code' ] ] ) ) {
202
+				if ( \T_VARIABLE === $this->tokens[ $i ][ 'code' ] ) {
203
+					if ( '$wpdb' !== $this->tokens[ $i ][ 'content' ] ) {
204 204
 						$variable_found = true;
205 205
 					}
206 206
 					continue;
207 207
 				}
208 208
 
209 209
 				// Detect a specific pattern for variable replacements in combination with `IN`.
210
-				if ( \T_STRING === $this->tokens[ $i ]['code'] ) {
210
+				if ( \T_STRING === $this->tokens[ $i ][ 'code' ] ) {
211 211
 
212
-					if ( 'sprintf' === strtolower( $this->tokens[ $i ]['content'] ) ) {
212
+					if ( 'sprintf' === strtolower( $this->tokens[ $i ][ 'content' ] ) ) {
213 213
 						$sprintf_parameters = $this->get_function_call_parameters( $i );
214 214
 
215 215
 						if ( ! empty( $sprintf_parameters ) ) {
216
-							$skip_from  = ( $sprintf_parameters[1]['end'] + 1 );
216
+							$skip_from  = ( $sprintf_parameters[ 1 ][ 'end' ] + 1 );
217 217
 							$last_param = end( $sprintf_parameters );
218
-							$skip_to    = ( $last_param['end'] + 1 );
218
+							$skip_to    = ( $last_param[ 'end' ] + 1 );
219 219
 
220
-							$valid_in_clauses['implode_fill']     += $this->analyse_sprintf( $sprintf_parameters );
221
-							$valid_in_clauses['adjustment_count'] += ( \count( $sprintf_parameters ) - 1 );
220
+							$valid_in_clauses[ 'implode_fill' ]     += $this->analyse_sprintf( $sprintf_parameters );
221
+							$valid_in_clauses[ 'adjustment_count' ] += ( \count( $sprintf_parameters ) - 1 );
222 222
 						}
223 223
 						unset( $sprintf_parameters, $last_param );
224 224
 
225
-					} elseif ( 'implode' === strtolower( $this->tokens[ $i ]['content'] ) ) {
225
+					} elseif ( 'implode' === strtolower( $this->tokens[ $i ][ 'content' ] ) ) {
226 226
 						$prev = $this->phpcsFile->findPrevious(
227 227
 							Tokens::$textStringTokens,
228 228
 							( $i - 1 ),
229
-							$query['start']
229
+							$query[ 'start' ]
230 230
 						);
231 231
 
232
-						$prev_content = $this->strip_quotes( $this->tokens[ $prev ]['content'] );
233
-						$regex_quote  = $this->get_regex_quote_snippet( $prev_content, $this->tokens[ $prev ]['content'] );
232
+						$prev_content = $this->strip_quotes( $this->tokens[ $prev ][ 'content' ] );
233
+						$regex_quote  = $this->get_regex_quote_snippet( $prev_content, $this->tokens[ $prev ][ 'content' ] );
234 234
 
235 235
 						// Only examine the implode if preceded by an ` IN (`.
236 236
 						if ( preg_match( '`\s+IN\s*\(\s*(' . $regex_quote . ')?$`i', $prev_content, $match ) > 0 ) {
237 237
 
238
-							if ( isset( $match[1] ) && $regex_quote !== $this->regex_quote ) {
238
+							if ( isset( $match[ 1 ] ) && $regex_quote !== $this->regex_quote ) {
239 239
 								$this->phpcsFile->addError(
240 240
 									'Dynamic placeholder generation should not have surrounding quotes.',
241 241
 									$i,
@@ -244,15 +244,15 @@  discard block
 block discarded – undo
244 244
 							}
245 245
 
246 246
 							if ( $this->analyse_implode( $i ) === true ) {
247
-								++$valid_in_clauses['uses_in'];
248
-								++$valid_in_clauses['implode_fill'];
247
+								++$valid_in_clauses[ 'uses_in' ];
248
+								++$valid_in_clauses[ 'implode_fill' ];
249 249
 
250 250
 								$next = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $i + 1 ), null, true );
251
-								if ( \T_OPEN_PARENTHESIS === $this->tokens[ $next ]['code']
252
-									&& isset( $this->tokens[ $next ]['parenthesis_closer'] )
251
+								if ( \T_OPEN_PARENTHESIS === $this->tokens[ $next ][ 'code' ]
252
+									&& isset( $this->tokens[ $next ][ 'parenthesis_closer' ] )
253 253
 								) {
254 254
 									$skip_from = ( $i + 1 );
255
-									$skip_to   = ( $this->tokens[ $next ]['parenthesis_closer'] + 1 );
255
+									$skip_to   = ( $this->tokens[ $next ][ 'parenthesis_closer' ] + 1 );
256 256
 								}
257 257
 							}
258 258
 						}
@@ -264,16 +264,16 @@  discard block
 block discarded – undo
264 264
 			}
265 265
 
266 266
 			$text_string_tokens_found = true;
267
-			$content                  = $this->tokens[ $i ]['content'];
267
+			$content                  = $this->tokens[ $i ][ 'content' ];
268 268
 
269 269
 			$regex_quote = $this->regex_quote;
270
-			if ( isset( Tokens::$stringTokens[ $this->tokens[ $i ]['code'] ] ) ) {
270
+			if ( isset( Tokens::$stringTokens[ $this->tokens[ $i ][ 'code' ] ] ) ) {
271 271
 				$content     = $this->strip_quotes( $content );
272
-				$regex_quote = $this->get_regex_quote_snippet( $content, $this->tokens[ $i ]['content'] );
272
+				$regex_quote = $this->get_regex_quote_snippet( $content, $this->tokens[ $i ][ 'content' ] );
273 273
 			}
274 274
 
275
-			if ( \T_DOUBLE_QUOTED_STRING === $this->tokens[ $i ]['code']
276
-				|| \T_HEREDOC === $this->tokens[ $i ]['code']
275
+			if ( \T_DOUBLE_QUOTED_STRING === $this->tokens[ $i ][ 'code' ]
276
+				|| \T_HEREDOC === $this->tokens[ $i ][ 'code' ]
277 277
 			) {
278 278
 				// Only interested in actual query text, so strip out variables.
279 279
 				$stripped_content = $this->strip_interpolated_variables( $content );
@@ -305,23 +305,23 @@  discard block
 block discarded – undo
305 305
 			$regex = '`\s+LIKE\s*(?:(' . $regex_quote . ')(?!%s(?:\1|$))(?P<content>.*?)(?:\1|$)|(?:concat\((?![^\)]*%s[^\)]*\))(?P<concat>[^\)]*))\))`i';
306 306
 			if ( preg_match_all( $regex, $content, $matches ) > 0 ) {
307 307
 				$walk = array();
308
-				if ( ! empty( $matches['content'] ) ) {
309
-					$matches['content'] = array_filter( $matches['content'] );
310
-					if ( ! empty( $matches['content'] ) ) {
311
-						$walk[] = 'content';
308
+				if ( ! empty( $matches[ 'content' ] ) ) {
309
+					$matches[ 'content' ] = array_filter( $matches[ 'content' ] );
310
+					if ( ! empty( $matches[ 'content' ] ) ) {
311
+						$walk[ ] = 'content';
312 312
 					}
313 313
 				}
314
-				if ( ! empty( $matches['concat'] ) ) {
315
-					$matches['concat'] = array_filter( $matches['concat'] );
316
-					if ( ! empty( $matches['concat'] ) ) {
317
-						$walk[] = 'concat';
314
+				if ( ! empty( $matches[ 'concat' ] ) ) {
315
+					$matches[ 'concat' ] = array_filter( $matches[ 'concat' ] );
316
+					if ( ! empty( $matches[ 'concat' ] ) ) {
317
+						$walk[ ] = 'concat';
318 318
 					}
319 319
 				}
320 320
 
321 321
 				if ( ! empty( $walk ) ) {
322 322
 					foreach ( $walk as $match_key ) {
323 323
 						foreach ( $matches[ $match_key ] as $index => $match ) {
324
-							$data = array( $matches[0][ $index ] );
324
+							$data = array( $matches[ 0 ][ $index ] );
325 325
 
326 326
 							// Both a `%` as well as a `_` are wildcards in SQL.
327 327
 							if ( strpos( $match, '%' ) === false && strpos( $match, '_' ) === false ) {
@@ -370,8 +370,8 @@  discard block
 block discarded – undo
370 370
 			 * Analyse the query for unsupported placeholders.
371 371
 			 */
372 372
 			if ( preg_match_all( self::UNSUPPORTED_PLACEHOLDER_REGEX, $content, $matches ) > 0 ) {
373
-				if ( ! empty( $matches[0] ) ) {
374
-					foreach ( $matches[0] as $match ) {
373
+				if ( ! empty( $matches[ 0 ] ) ) {
374
+					foreach ( $matches[ 0 ] as $match ) {
375 375
 						if ( '%' === $match ) {
376 376
 							$this->phpcsFile->addError(
377 377
 								'Found unescaped literal "%%" character.',
@@ -397,8 +397,8 @@  discard block
 block discarded – undo
397 397
 			 */
398 398
 			$regex = '`(' . $regex_quote . ')%[dfFs]\1`';
399 399
 			if ( preg_match_all( $regex, $content, $matches ) > 0 ) {
400
-				if ( ! empty( $matches[0] ) ) {
401
-					foreach ( $matches[0] as $match ) {
400
+				if ( ! empty( $matches[ 0 ] ) ) {
401
+					foreach ( $matches[ 0 ] as $match ) {
402 402
 						$this->phpcsFile->addError(
403 403
 							'Simple placeholders should not be quoted in the query string in $wpdb->prepare(). Found: %s.',
404 404
 							$i,
@@ -415,8 +415,8 @@  discard block
 block discarded – undo
415 415
 			 */
416 416
 			$regex = '`(?<!' . $regex_quote . ')' . self::PREPARE_PLACEHOLDER_REGEX . '(?!' . $regex_quote . ')`x';
417 417
 			if ( preg_match_all( $regex, $content, $matches ) > 0 ) {
418
-				if ( ! empty( $matches[0] ) ) {
419
-					foreach ( $matches[0] as $match ) {
418
+				if ( ! empty( $matches[ 0 ] ) ) {
419
+					foreach ( $matches[ 0 ] as $match ) {
420 420
 						if ( preg_match( '`%[dfFs]`', $match ) !== 1 ) {
421 421
 							$this->phpcsFile->addWarning(
422 422
 								'Complex placeholders used for values in the query string in $wpdb->prepare() will NOT be quoted automagically. Found: %s.',
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
 			 */
436 436
 			$found_in = preg_match_all( '`\s+IN\s*\(\s*%s\s*\)`i', $content, $matches );
437 437
 			if ( $found_in > 0 ) {
438
-				$valid_in_clauses['uses_in'] += $found_in;
438
+				$valid_in_clauses[ 'uses_in' ] += $found_in;
439 439
 			}
440 440
 			unset( $found_in );
441 441
 		}
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
 						'UnnecessaryPrepare'
466 466
 					);
467 467
 				}
468
-			} elseif ( false === $count_diff_whitelisted && 0 === $valid_in_clauses['uses_in'] ) {
468
+			} elseif ( false === $count_diff_whitelisted && 0 === $valid_in_clauses[ 'uses_in' ] ) {
469 469
 				$this->phpcsFile->addWarning(
470 470
 					'Replacement variables found, but no valid placeholders found in the query.',
471 471
 					$i,
@@ -494,28 +494,28 @@  discard block
 block discarded – undo
494 494
 		array_shift( $replacements ); // Remove the query.
495 495
 
496 496
 		// The parameters may have been passed as an array in parameter 2.
497
-		if ( isset( $parameters[2] ) && 2 === $total_parameters ) {
497
+		if ( isset( $parameters[ 2 ] ) && 2 === $total_parameters ) {
498 498
 			$next = $this->phpcsFile->findNext(
499 499
 				Tokens::$emptyTokens,
500
-				$parameters[2]['start'],
501
-				( $parameters[2]['end'] + 1 ),
500
+				$parameters[ 2 ][ 'start' ],
501
+				( $parameters[ 2 ][ 'end' ] + 1 ),
502 502
 				true
503 503
 			);
504 504
 
505 505
 			if ( false !== $next
506
-				&& ( \T_ARRAY === $this->tokens[ $next ]['code']
507
-					|| \T_OPEN_SHORT_ARRAY === $this->tokens[ $next ]['code'] )
506
+				&& ( \T_ARRAY === $this->tokens[ $next ][ 'code' ]
507
+					|| \T_OPEN_SHORT_ARRAY === $this->tokens[ $next ][ 'code' ] )
508 508
 			) {
509 509
 				$replacements = $this->get_function_call_parameters( $next );
510 510
 			}
511 511
 		}
512 512
 
513 513
 		$total_replacements  = \count( $replacements );
514
-		$total_placeholders -= $valid_in_clauses['adjustment_count'];
514
+		$total_placeholders -= $valid_in_clauses[ 'adjustment_count' ];
515 515
 
516 516
 		// Bow out when `IN` clauses have been used which appear to be correct.
517
-		if ( $valid_in_clauses['uses_in'] > 0
518
-			&& $valid_in_clauses['uses_in'] === $valid_in_clauses['implode_fill']
517
+		if ( $valid_in_clauses[ 'uses_in' ] > 0
518
+			&& $valid_in_clauses[ 'uses_in' ] === $valid_in_clauses[ 'implode_fill' ]
519 519
 			&& 1 === $total_replacements
520 520
 		) {
521 521
 			return;
@@ -553,7 +553,7 @@  discard block
 block discarded – undo
553 553
 		$regex_quote = $this->regex_quote;
554 554
 
555 555
 		if ( $original_content !== $stripped_content ) {
556
-			$quote_style = $original_content[0];
556
+			$quote_style = $original_content[ 0 ];
557 557
 
558 558
 			if ( '"' === $quote_style ) {
559 559
 				$regex_quote = '\\\\"|\'';
@@ -581,21 +581,21 @@  discard block
 block discarded – undo
581 581
 	protected function analyse_sprintf( $sprintf_params ) {
582 582
 		$found = 0;
583 583
 
584
-		unset( $sprintf_params[1] );
584
+		unset( $sprintf_params[ 1 ] );
585 585
 
586 586
 		foreach ( $sprintf_params as $sprintf_param ) {
587
-			if ( strpos( strtolower( $sprintf_param['raw'] ), 'implode' ) === false ) {
587
+			if ( strpos( strtolower( $sprintf_param[ 'raw' ] ), 'implode' ) === false ) {
588 588
 				continue;
589 589
 			}
590 590
 
591 591
 			$implode = $this->phpcsFile->findNext(
592 592
 				Tokens::$emptyTokens,
593
-				$sprintf_param['start'],
594
-				$sprintf_param['end'],
593
+				$sprintf_param[ 'start' ],
594
+				$sprintf_param[ 'end' ],
595 595
 				true
596 596
 			);
597
-			if ( \T_STRING === $this->tokens[ $implode ]['code']
598
-				&& 'implode' === strtolower( $this->tokens[ $implode ]['content'] )
597
+			if ( \T_STRING === $this->tokens[ $implode ][ 'code' ]
598
+				&& 'implode' === strtolower( $this->tokens[ $implode ][ 'content' ] )
599 599
 			) {
600 600
 				if ( $this->analyse_implode( $implode ) === true ) {
601 601
 					++$found;
@@ -628,23 +628,23 @@  discard block
 block discarded – undo
628 628
 			return false;
629 629
 		}
630 630
 
631
-		if ( preg_match( '`^(["\']), ?\1$`', $implode_params[1]['raw'] ) !== 1 ) {
631
+		if ( preg_match( '`^(["\']), ?\1$`', $implode_params[ 1 ][ 'raw' ] ) !== 1 ) {
632 632
 			return false;
633 633
 		}
634 634
 
635
-		if ( strpos( strtolower( $implode_params[2]['raw'] ), 'array_fill' ) === false ) {
635
+		if ( strpos( strtolower( $implode_params[ 2 ][ 'raw' ] ), 'array_fill' ) === false ) {
636 636
 			return false;
637 637
 		}
638 638
 
639 639
 		$array_fill = $this->phpcsFile->findNext(
640 640
 			Tokens::$emptyTokens,
641
-			$implode_params[2]['start'],
642
-			$implode_params[2]['end'],
641
+			$implode_params[ 2 ][ 'start' ],
642
+			$implode_params[ 2 ][ 'end' ],
643 643
 			true
644 644
 		);
645 645
 
646
-		if ( \T_STRING !== $this->tokens[ $array_fill ]['code']
647
-			|| 'array_fill' !== strtolower( $this->tokens[ $array_fill ]['content'] )
646
+		if ( \T_STRING !== $this->tokens[ $array_fill ][ 'code' ]
647
+			|| 'array_fill' !== strtolower( $this->tokens[ $array_fill ][ 'content' ] )
648 648
 		) {
649 649
 			return false;
650 650
 		}
@@ -655,7 +655,7 @@  discard block
 block discarded – undo
655 655
 			return false;
656 656
 		}
657 657
 
658
-		return (bool) preg_match( '`^(["\'])%[dfFs]\1$`', $array_fill_params[3]['raw'] );
658
+		return (bool)preg_match( '`^(["\'])%[dfFs]\1$`', $array_fill_params[ 3 ][ 'raw' ] );
659 659
 	}
660 660
 
661 661
 }
Please login to merge, or discard this patch.
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/DB/PreparedSQLSniff.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -98,7 +98,7 @@
 block discarded – undo
98 98
 	 *
99 99
 	 * @since 0.8.0
100 100
 	 *
101
-	 * @return array
101
+	 * @return integer[]
102 102
 	 */
103 103
 	public function register() {
104 104
 
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -132,17 +132,17 @@  discard block
 block discarded – undo
132 132
 
133 133
 		for ( $this->i; $this->i < $this->end; $this->i++ ) {
134 134
 
135
-			if ( isset( $this->ignored_tokens[ $this->tokens[ $this->i ]['code'] ] ) ) {
135
+			if ( isset( $this->ignored_tokens[ $this->tokens[ $this->i ][ 'code' ] ] ) ) {
136 136
 				continue;
137 137
 			}
138 138
 
139
-			if ( \T_DOUBLE_QUOTED_STRING === $this->tokens[ $this->i ]['code']
140
-				|| \T_HEREDOC === $this->tokens[ $this->i ]['code']
139
+			if ( \T_DOUBLE_QUOTED_STRING === $this->tokens[ $this->i ][ 'code' ]
140
+				|| \T_HEREDOC === $this->tokens[ $this->i ][ 'code' ]
141 141
 			) {
142 142
 
143 143
 				$bad_variables = array_filter(
144
-					$this->get_interpolated_variables( $this->tokens[ $this->i ]['content'] ),
145
-					function ( $symbol ) {
144
+					$this->get_interpolated_variables( $this->tokens[ $this->i ][ 'content' ] ),
145
+					function( $symbol ) {
146 146
 						return ( 'wpdb' !== $symbol );
147 147
 					}
148 148
 				);
@@ -154,15 +154,15 @@  discard block
 block discarded – undo
154 154
 						'InterpolatedNotPrepared',
155 155
 						array(
156 156
 							$bad_variable,
157
-							$this->tokens[ $this->i ]['content'],
157
+							$this->tokens[ $this->i ][ 'content' ],
158 158
 						)
159 159
 					);
160 160
 				}
161 161
 				continue;
162 162
 			}
163 163
 
164
-			if ( \T_VARIABLE === $this->tokens[ $this->i ]['code'] ) {
165
-				if ( '$wpdb' === $this->tokens[ $this->i ]['content'] ) {
164
+			if ( \T_VARIABLE === $this->tokens[ $this->i ][ 'code' ] ) {
165
+				if ( '$wpdb' === $this->tokens[ $this->i ][ 'content' ] ) {
166 166
 					$this->is_wpdb_method_call( $this->i, $this->methods );
167 167
 					continue;
168 168
 				}
@@ -172,25 +172,25 @@  discard block
 block discarded – undo
172 172
 				}
173 173
 			}
174 174
 
175
-			if ( \T_STRING === $this->tokens[ $this->i ]['code'] ) {
175
+			if ( \T_STRING === $this->tokens[ $this->i ][ 'code' ] ) {
176 176
 
177 177
 				if (
178
-					isset( $this->SQLEscapingFunctions[ $this->tokens[ $this->i ]['content'] ] )
179
-					|| isset( $this->SQLAutoEscapedFunctions[ $this->tokens[ $this->i ]['content'] ] )
178
+					isset( $this->SQLEscapingFunctions[ $this->tokens[ $this->i ][ 'content' ] ] )
179
+					|| isset( $this->SQLAutoEscapedFunctions[ $this->tokens[ $this->i ][ 'content' ] ] )
180 180
 				) {
181 181
 
182 182
 					// Find the opening parenthesis.
183 183
 					$opening_paren = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $this->i + 1 ), null, true, null, true );
184 184
 
185 185
 					if ( false !== $opening_paren
186
-						&& \T_OPEN_PARENTHESIS === $this->tokens[ $opening_paren ]['code']
187
-						&& isset( $this->tokens[ $opening_paren ]['parenthesis_closer'] )
186
+						&& \T_OPEN_PARENTHESIS === $this->tokens[ $opening_paren ][ 'code' ]
187
+						&& isset( $this->tokens[ $opening_paren ][ 'parenthesis_closer' ] )
188 188
 					) {
189 189
 						// Skip past the end of the function.
190
-						$this->i = $this->tokens[ $opening_paren ]['parenthesis_closer'];
190
+						$this->i = $this->tokens[ $opening_paren ][ 'parenthesis_closer' ];
191 191
 						continue;
192 192
 					}
193
-				} elseif ( isset( $this->formattingFunctions[ $this->tokens[ $this->i ]['content'] ] ) ) {
193
+				} elseif ( isset( $this->formattingFunctions[ $this->tokens[ $this->i ][ 'content' ] ] ) ) {
194 194
 					continue;
195 195
 				}
196 196
 			}
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 				'Use placeholders and $wpdb->prepare(); found %s',
200 200
 				$this->i,
201 201
 				'NotPrepared',
202
-				array( $this->tokens[ $this->i ]['content'] )
202
+				array( $this->tokens[ $this->i ][ 'content' ] )
203 203
 			);
204 204
 		}
205 205
 
Please login to merge, or discard this patch.
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/DB/SlowDBQuerySniff.php 1 patch
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@
 block discarded – undo
76 76
 	 * @param  mixed  $val   Assigned value.
77 77
 	 * @param  int    $line  Token line.
78 78
 	 * @param  array  $group Group definition.
79
-	 * @return mixed         FALSE if no match, TRUE if matches, STRING if matches
79
+	 * @return boolean         FALSE if no match, TRUE if matches, STRING if matches
80 80
 	 *                       with custom error message passed to ->process().
81 81
 	 */
82 82
 	public function callback( $key, $val, $line, $group ) {
Please login to merge, or discard this patch.
wp-coding-standards/wpcs/WordPress/Sniffs/PHP/StrictComparisonsSniff.php 2 patches
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.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@
 block discarded – undo
48 48
 	public function process_token( $stackPtr ) {
49 49
 
50 50
 		if ( ! $this->has_whitelist_comment( 'loose comparison', $stackPtr ) ) {
51
-			$error = 'Found: ' . $this->tokens[ $stackPtr ]['content'] . '. Use strict comparisons (=== or !==).';
51
+			$error = 'Found: ' . $this->tokens[ $stackPtr ][ 'content' ] . '. Use strict comparisons (=== or !==).';
52 52
 			$this->phpcsFile->addWarning( $error, $stackPtr, 'LooseComparison' );
53 53
 		}
54 54
 	}
Please login to merge, or discard this patch.
wp-coding-standards/wpcs/WordPress/Sniffs/Security/EscapeOutputSniff.php 2 patches
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.
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.
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/CapitalPDangitSniff.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -270,7 +270,7 @@
 block discarded – undo
270 270
 	/**
271 271
 	 * Retrieve a list of misspellings based on an array of matched variations on the target word.
272 272
 	 *
273
-	 * @param array $match_stack Array of matched variations of the target word.
273
+	 * @param string[] $match_stack Array of matched variations of the target word.
274 274
 	 * @return array Array containing only the misspelled variants.
275 275
 	 */
276 276
 	protected function retrieve_misspellings( $match_stack ) {
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -126,24 +126,24 @@  discard block
 block discarded – undo
126 126
 		 * The return values skip to the end of the array.
127 127
 		 * This prevents the sniff "hanging" on very long configuration arrays.
128 128
 		 */
129
-		if ( \T_OPEN_SHORT_ARRAY === $this->tokens[ $stackPtr ]['code'] && isset( $this->tokens[ $stackPtr ]['bracket_closer'] ) ) {
130
-			return $this->tokens[ $stackPtr ]['bracket_closer'];
131
-		} elseif ( \T_ARRAY === $this->tokens[ $stackPtr ]['code'] && isset( $this->tokens[ $stackPtr ]['parenthesis_closer'] ) ) {
132
-			return $this->tokens[ $stackPtr ]['parenthesis_closer'];
129
+		if ( \T_OPEN_SHORT_ARRAY === $this->tokens[ $stackPtr ][ 'code' ] && isset( $this->tokens[ $stackPtr ][ 'bracket_closer' ] ) ) {
130
+			return $this->tokens[ $stackPtr ][ 'bracket_closer' ];
131
+		} elseif ( \T_ARRAY === $this->tokens[ $stackPtr ][ 'code' ] && isset( $this->tokens[ $stackPtr ][ 'parenthesis_closer' ] ) ) {
132
+			return $this->tokens[ $stackPtr ][ 'parenthesis_closer' ];
133 133
 		}
134 134
 
135 135
 		/*
136 136
 		 * Deal with misspellings in class/interface/trait names.
137 137
 		 * These are not auto-fixable, but need the attention of a developer.
138 138
 		 */
139
-		if ( isset( Tokens::$ooScopeTokens[ $this->tokens[ $stackPtr ]['code'] ] ) ) {
139
+		if ( isset( Tokens::$ooScopeTokens[ $this->tokens[ $stackPtr ][ 'code' ] ] ) ) {
140 140
 			$classname = $this->phpcsFile->getDeclarationName( $stackPtr );
141 141
 			if ( empty( $classname ) ) {
142 142
 				return;
143 143
 			}
144 144
 
145 145
 			if ( preg_match_all( self::WP_CLASSNAME_REGEX, $classname, $matches, \PREG_PATTERN_ORDER ) > 0 ) {
146
-				$mispelled = $this->retrieve_misspellings( $matches[1] );
146
+				$mispelled = $this->retrieve_misspellings( $matches[ 1 ] );
147 147
 
148 148
 				if ( ! empty( $mispelled ) ) {
149 149
 					$this->phpcsFile->addWarning(
@@ -163,14 +163,14 @@  discard block
 block discarded – undo
163 163
 		 */
164 164
 
165 165
 		// Ignore content of docblock @link tags.
166
-		if ( \T_DOC_COMMENT_STRING === $this->tokens[ $stackPtr ]['code']
167
-			|| \T_DOC_COMMENT === $this->tokens[ $stackPtr ]['code']
166
+		if ( \T_DOC_COMMENT_STRING === $this->tokens[ $stackPtr ][ 'code' ]
167
+			|| \T_DOC_COMMENT === $this->tokens[ $stackPtr ][ 'code' ]
168 168
 		) {
169 169
 
170 170
 			$comment_start = $this->phpcsFile->findPrevious( \T_DOC_COMMENT_OPEN_TAG, ( $stackPtr - 1 ) );
171 171
 			if ( false !== $comment_start ) {
172 172
 				$comment_tag = $this->phpcsFile->findPrevious( \T_DOC_COMMENT_TAG, ( $stackPtr - 1 ), $comment_start );
173
-				if ( false !== $comment_tag && '@link' === $this->tokens[ $comment_tag ]['content'] ) {
173
+				if ( false !== $comment_tag && '@link' === $this->tokens[ $comment_tag ][ 'content' ] ) {
174 174
 					// @link tag, so ignore.
175 175
 					return;
176 176
 				}
@@ -178,11 +178,11 @@  discard block
 block discarded – undo
178 178
 		}
179 179
 
180 180
 		// Ignore any text strings which are array keys `$var['key']` as this is a false positive in 80% of all cases.
181
-		if ( \T_CONSTANT_ENCAPSED_STRING === $this->tokens[ $stackPtr ]['code'] ) {
181
+		if ( \T_CONSTANT_ENCAPSED_STRING === $this->tokens[ $stackPtr ][ 'code' ] ) {
182 182
 			$prevToken = $this->phpcsFile->findPrevious( Tokens::$emptyTokens, ( $stackPtr - 1 ), null, true, null, true );
183
-			if ( false !== $prevToken && \T_OPEN_SQUARE_BRACKET === $this->tokens[ $prevToken ]['code'] ) {
183
+			if ( false !== $prevToken && \T_OPEN_SQUARE_BRACKET === $this->tokens[ $prevToken ][ 'code' ] ) {
184 184
 				$nextToken = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true, null, true );
185
-				if ( false !== $nextToken && \T_CLOSE_SQUARE_BRACKET === $this->tokens[ $nextToken ]['code'] ) {
185
+				if ( false !== $nextToken && \T_CLOSE_SQUARE_BRACKET === $this->tokens[ $nextToken ][ 'code' ] ) {
186 186
 					return;
187 187
 				}
188 188
 			}
@@ -202,44 +202,44 @@  discard block
 block discarded – undo
202 202
 			\T_OPEN_CURLY_BRACKET,
203 203
 		);
204 204
 		$maybe_const = $this->phpcsFile->findPrevious( $stop_points, ( $stackPtr - 1 ) );
205
-		if ( false !== $maybe_const && \T_CONST === $this->tokens[ $maybe_const ]['code'] ) {
205
+		if ( false !== $maybe_const && \T_CONST === $this->tokens[ $maybe_const ][ 'code' ] ) {
206 206
 			return;
207 207
 		}
208 208
 
209
-		$content = $this->tokens[ $stackPtr ]['content'];
209
+		$content = $this->tokens[ $stackPtr ][ 'content' ];
210 210
 
211 211
 		if ( preg_match_all( self::WP_REGEX, $content, $matches, ( \PREG_PATTERN_ORDER | \PREG_OFFSET_CAPTURE ) ) > 0 ) {
212 212
 			/*
213 213
 			 * Prevent some typical false positives.
214 214
 			 */
215
-			if ( isset( $this->text_and_comment_tokens[ $this->tokens[ $stackPtr ]['code'] ] ) ) {
215
+			if ( isset( $this->text_and_comment_tokens[ $this->tokens[ $stackPtr ][ 'code' ] ] ) ) {
216 216
 				$offset = 0;
217
-				foreach ( $matches[1] as $key => $match_data ) {
218
-					$next_offset = ( $match_data[1] + \strlen( $match_data[0] ) );
217
+				foreach ( $matches[ 1 ] as $key => $match_data ) {
218
+					$next_offset = ( $match_data[ 1 ] + \strlen( $match_data[ 0 ] ) );
219 219
 
220 220
 					// Prevent matches on part of a URL.
221
-					if ( preg_match( '`http[s]?://[^\s<>\'"()]*' . preg_quote( $match_data[0], '`' ) . '`', $content, $discard, 0, $offset ) === 1 ) {
222
-						unset( $matches[1][ $key ] );
223
-					} elseif ( preg_match( '`[a-z]+=(["\'])' . preg_quote( $match_data[0], '`' ) . '\1`', $content, $discard, 0, $offset ) === 1 ) {
221
+					if ( preg_match( '`http[s]?://[^\s<>\'"()]*' . preg_quote( $match_data[ 0 ], '`' ) . '`', $content, $discard, 0, $offset ) === 1 ) {
222
+						unset( $matches[ 1 ][ $key ] );
223
+					} elseif ( preg_match( '`[a-z]+=(["\'])' . preg_quote( $match_data[ 0 ], '`' ) . '\1`', $content, $discard, 0, $offset ) === 1 ) {
224 224
 						// Prevent matches on html attributes like: `value="wordpress"`.
225
-						unset( $matches[1][ $key ] );
226
-					} elseif ( preg_match( '`\\\\\'' . preg_quote( $match_data[0], '`' ) . '\\\\\'`', $content, $discard, 0, $offset ) === 1 ) {
225
+						unset( $matches[ 1 ][ $key ] );
226
+					} elseif ( preg_match( '`\\\\\'' . preg_quote( $match_data[ 0 ], '`' ) . '\\\\\'`', $content, $discard, 0, $offset ) === 1 ) {
227 227
 						// Prevent matches on xpath queries and such: `\'wordpress\'`.
228
-						unset( $matches[1][ $key ] );
229
-					} elseif ( preg_match( '`(?:\?|&amp;|&)[a-z0-9_]+=' . preg_quote( $match_data[0], '`' ) . '(?:&|$)`', $content, $discard, 0, $offset ) === 1 ) {
228
+						unset( $matches[ 1 ][ $key ] );
229
+					} elseif ( preg_match( '`(?:\?|&amp;|&)[a-z0-9_]+=' . preg_quote( $match_data[ 0 ], '`' ) . '(?:&|$)`', $content, $discard, 0, $offset ) === 1 ) {
230 230
 						// Prevent matches on url query strings: `?something=wordpress`.
231
-						unset( $matches[1][ $key ] );
231
+						unset( $matches[ 1 ][ $key ] );
232 232
 					}
233 233
 
234 234
 					$offset = $next_offset;
235 235
 				}
236 236
 
237
-				if ( empty( $matches[1] ) ) {
237
+				if ( empty( $matches[ 1 ] ) ) {
238 238
 					return;
239 239
 				}
240 240
 			}
241 241
 
242
-			$mispelled = $this->retrieve_misspellings( $matches[1] );
242
+			$mispelled = $this->retrieve_misspellings( $matches[ 1 ] );
243 243
 
244 244
 			if ( empty( $mispelled ) ) {
245 245
 				return;
@@ -258,8 +258,8 @@  discard block
 block discarded – undo
258 258
 			if ( true === $fix ) {
259 259
 				// Apply fixes based on offset to ensure we don't replace false positives.
260 260
 				$replacement = $content;
261
-				foreach ( $matches[1] as $match ) {
262
-					$replacement = substr_replace( $replacement, 'WordPress', $match[1], \strlen( $match[0] ) );
261
+				foreach ( $matches[ 1 ] as $match ) {
262
+					$replacement = substr_replace( $replacement, 'WordPress', $match[ 1 ], \strlen( $match[ 0 ] ) );
263 263
 				}
264 264
 
265 265
 				$this->phpcsFile->fixer->replaceToken( $stackPtr, $replacement );
@@ -278,11 +278,11 @@  discard block
 block discarded – undo
278 278
 		foreach ( $match_stack as $match ) {
279 279
 			// Deal with multi-dimensional arrays when capturing offset.
280 280
 			if ( \is_array( $match ) ) {
281
-				$match = $match[0];
281
+				$match = $match[ 0 ];
282 282
 			}
283 283
 
284 284
 			if ( 'WordPress' !== $match ) {
285
-				$mispelled[] = $match;
285
+				$mispelled[ ] = $match;
286 286
 			}
287 287
 		}
288 288
 
Please login to merge, or discard this patch.
wpcs/WordPress/Sniffs/Arrays/ArrayKeySpacingRestrictionsSniff.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@
 block discarded – undo
28 28
 	/**
29 29
 	 * Returns an array of tokens this test wants to listen for.
30 30
 	 *
31
-	 * @return array
31
+	 * @return string[]
32 32
 	 */
33 33
 	public function register() {
34 34
 		return array(
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	public function process_token( $stackPtr ) {
47 47
 
48 48
 		$token = $this->tokens[ $stackPtr ];
49
-		if ( ! isset( $token['bracket_closer'] ) ) {
49
+		if ( ! isset( $token[ 'bracket_closer' ] ) ) {
50 50
 			$this->phpcsFile->addWarning( 'Missing bracket closer.', $stackPtr, 'MissingBracketCloser' );
51 51
 			return;
52 52
 		}
@@ -54,12 +54,12 @@  discard block
 block discarded – undo
54 54
 		$need_spaces = $this->phpcsFile->findNext(
55 55
 			array( \T_CONSTANT_ENCAPSED_STRING, \T_LNUMBER, \T_WHITESPACE, \T_MINUS ),
56 56
 			( $stackPtr + 1 ),
57
-			$token['bracket_closer'],
57
+			$token[ 'bracket_closer' ],
58 58
 			true
59 59
 		);
60 60
 
61
-		$spaced1 = ( \T_WHITESPACE === $this->tokens[ ( $stackPtr + 1 ) ]['code'] );
62
-		$spaced2 = ( \T_WHITESPACE === $this->tokens[ ( $token['bracket_closer'] - 1 ) ]['code'] );
61
+		$spaced1 = ( \T_WHITESPACE === $this->tokens[ ( $stackPtr + 1 ) ][ 'code' ] );
62
+		$spaced2 = ( \T_WHITESPACE === $this->tokens[ ( $token[ 'bracket_closer' ] - 1 ) ][ 'code' ] );
63 63
 
64 64
 		// It should have spaces unless if it only has strings or numbers as the key.
65 65
 		if ( false !== $need_spaces && ! ( $spaced1 && $spaced2 ) ) {
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 					$this->phpcsFile->fixer->addContentBefore( ( $stackPtr + 1 ), ' ' );
71 71
 				}
72 72
 				if ( ! $spaced2 ) {
73
-					$this->phpcsFile->fixer->addContentBefore( $token['bracket_closer'], ' ' );
73
+					$this->phpcsFile->fixer->addContentBefore( $token[ 'bracket_closer' ], ' ' );
74 74
 				}
75 75
 			}
76 76
 		} elseif ( false === $need_spaces && ( $spaced1 || $spaced2 ) ) {
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 					$this->phpcsFile->fixer->replaceToken( ( $stackPtr + 1 ), '' );
82 82
 				}
83 83
 				if ( $spaced2 ) {
84
-					$this->phpcsFile->fixer->replaceToken( ( $token['bracket_closer'] - 1 ), '' );
84
+					$this->phpcsFile->fixer->replaceToken( ( $token[ 'bracket_closer' ] - 1 ), '' );
85 85
 				}
86 86
 			}
87 87
 		}
Please login to merge, or discard this patch.
wpcs/WordPress/Sniffs/Classes/ClassInstantiationSniff.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@
 block discarded – undo
51 51
 	/**
52 52
 	 * Returns an array of tokens this test wants to listen for.
53 53
 	 *
54
-	 * @return array
54
+	 * @return integer[]
55 55
 	 */
56 56
 	public function register() {
57 57
 		/*
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -91,10 +91,10 @@  discard block
 block discarded – undo
91 91
 	 */
92 92
 	public function process_token( $stackPtr ) {
93 93
 		// Make sure we have the right token, JS vs PHP.
94
-		if ( ( 'PHP' === $this->phpcsFile->tokenizerType && \T_NEW !== $this->tokens[ $stackPtr ]['code'] )
94
+		if ( ( 'PHP' === $this->phpcsFile->tokenizerType && \T_NEW !== $this->tokens[ $stackPtr ][ 'code' ] )
95 95
 			|| ( 'JS' === $this->phpcsFile->tokenizerType
96
-				&& ( \T_STRING !== $this->tokens[ $stackPtr ]['code']
97
-				|| 'new' !== strtolower( $this->tokens[ $stackPtr ]['content'] ) ) )
96
+				&& ( \T_STRING !== $this->tokens[ $stackPtr ][ 'code' ]
97
+				|| 'new' !== strtolower( $this->tokens[ $stackPtr ][ 'content' ] ) ) )
98 98
 		) {
99 99
 			return;
100 100
 		}
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 				true
111 111
 			);
112 112
 
113
-			if ( false !== $prev_non_empty && 'T_BITWISE_AND' === $this->tokens[ $prev_non_empty ]['type'] ) {
113
+			if ( false !== $prev_non_empty && 'T_BITWISE_AND' === $this->tokens[ $prev_non_empty ][ 'type' ] ) {
114 114
 				$this->phpcsFile->recordMetric( $stackPtr, 'Assigning new by reference', 'yes' );
115 115
 
116 116
 				$this->phpcsFile->addError(
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 		// Walk back to the last part of the class name.
144 144
 		$has_comment = false;
145 145
 		for ( $classname_ptr = ( $next_non_empty_after_class_name - 1 ); $classname_ptr >= $stackPtr; $classname_ptr-- ) {
146
-			if ( ! isset( Tokens::$emptyTokens[ $this->tokens[ $classname_ptr ]['code'] ] ) ) {
146
+			if ( ! isset( Tokens::$emptyTokens[ $this->tokens[ $classname_ptr ][ 'code' ] ] ) ) {
147 147
 				// Prevent a false positive on variable variables, disregard them for now.
148 148
 				if ( $stackPtr === $classname_ptr ) {
149 149
 					return;
@@ -152,12 +152,12 @@  discard block
 block discarded – undo
152 152
 				break;
153 153
 			}
154 154
 
155
-			if ( \T_WHITESPACE !== $this->tokens[ $classname_ptr ]['code'] ) {
155
+			if ( \T_WHITESPACE !== $this->tokens[ $classname_ptr ][ 'code' ] ) {
156 156
 				$has_comment = true;
157 157
 			}
158 158
 		}
159 159
 
160
-		if ( \T_OPEN_PARENTHESIS !== $this->tokens[ $next_non_empty_after_class_name ]['code'] ) {
160
+		if ( \T_OPEN_PARENTHESIS !== $this->tokens[ $next_non_empty_after_class_name ][ 'code' ] ) {
161 161
 			$this->phpcsFile->recordMetric( $stackPtr, 'Object instantiation with parenthesis', 'no' );
162 162
 
163 163
 			$fix = $this->phpcsFile->addFixableError(
Please login to merge, or discard this patch.
wpcs/WordPress/Sniffs/Files/FileNameSniff.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -115,7 +115,7 @@
 block discarded – undo
115 115
 	/**
116 116
 	 * Returns an array of tokens this test wants to listen for.
117 117
 	 *
118
-	 * @return array
118
+	 * @return integer[]
119 119
 	 */
120 120
 	public function register() {
121 121
 		if ( \defined( '\PHP_CODESNIFFER_IN_TESTS' ) ) {
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -148,18 +148,18 @@  discard block
 block discarded – undo
148 148
 		if ( \defined( '\T_PHPCS_DISABLE' ) && \defined( '\T_PHPCS_ENABLE' ) ) {
149 149
 			$i = -1;
150 150
 			while ( $i = $this->phpcsFile->findNext( \T_PHPCS_DISABLE, ( $i + 1 ) ) ) {
151
-				if ( empty( $this->tokens[ $i ]['sniffCodes'] )
152
-					|| isset( $this->tokens[ $i ]['sniffCodes']['WordPress'] )
153
-					|| isset( $this->tokens[ $i ]['sniffCodes']['WordPress.Files'] )
154
-					|| isset( $this->tokens[ $i ]['sniffCodes']['WordPress.Files.FileName'] )
151
+				if ( empty( $this->tokens[ $i ][ 'sniffCodes' ] )
152
+					|| isset( $this->tokens[ $i ][ 'sniffCodes' ][ 'WordPress' ] )
153
+					|| isset( $this->tokens[ $i ][ 'sniffCodes' ][ 'WordPress.Files' ] )
154
+					|| isset( $this->tokens[ $i ][ 'sniffCodes' ][ 'WordPress.Files.FileName' ] )
155 155
 				) {
156 156
 					do {
157 157
 						$i = $this->phpcsFile->findNext( \T_PHPCS_ENABLE, ( $i + 1 ) );
158 158
 					} while ( false !== $i
159
-						&& ! empty( $this->tokens[ $i ]['sniffCodes'] )
160
-						&& ! isset( $this->tokens[ $i ]['sniffCodes']['WordPress'] )
161
-						&& ! isset( $this->tokens[ $i ]['sniffCodes']['WordPress.Files'] )
162
-						&& ! isset( $this->tokens[ $i ]['sniffCodes']['WordPress.Files.FileName'] ) );
159
+						&& ! empty( $this->tokens[ $i ][ 'sniffCodes' ] )
160
+						&& ! isset( $this->tokens[ $i ][ 'sniffCodes' ][ 'WordPress' ] )
161
+						&& ! isset( $this->tokens[ $i ][ 'sniffCodes' ][ 'WordPress.Files' ] )
162
+						&& ! isset( $this->tokens[ $i ][ 'sniffCodes' ][ 'WordPress.Files.FileName' ] ) );
163 163
 
164 164
 					if ( false === $i ) {
165 165
 						// The entire (rest of the) file is disabled.
@@ -221,8 +221,8 @@  discard block
 block discarded – undo
221 221
 					$fileName_end = substr( $fileName, -13 );
222 222
 					$has_class    = $this->phpcsFile->findNext( \T_CLASS, $stackPtr );
223 223
 
224
-					if ( ( 'Template' === trim( $this->tokens[ $subpackage ]['content'] )
225
-						&& $this->tokens[ $subpackage_tag ]['line'] === $this->tokens[ $subpackage ]['line'] )
224
+					if ( ( 'Template' === trim( $this->tokens[ $subpackage ][ 'content' ] )
225
+						&& $this->tokens[ $subpackage_tag ][ 'line' ] === $this->tokens[ $subpackage ][ 'line' ] )
226 226
 						&& ( ( ! \defined( '\PHP_CODESNIFFER_IN_TESTS' ) && '-template.php' !== $fileName_end )
227 227
 						|| ( \defined( '\PHP_CODESNIFFER_IN_TESTS' ) && '-template.inc' !== $fileName_end ) )
228 228
 						&& false === $has_class
Please login to merge, or discard this patch.