@@ -96,14 +96,14 @@ discard block |
||
| 96 | 96 | return; |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - $opener = $array_open_close['opener']; |
|
| 100 | - $closer = $array_open_close['closer']; |
|
| 99 | + $opener = $array_open_close[ 'opener' ]; |
|
| 100 | + $closer = $array_open_close[ 'closer' ]; |
|
| 101 | 101 | unset( $array_open_close ); |
| 102 | 102 | |
| 103 | 103 | /* |
| 104 | 104 | * Long arrays only: Check for space between the array keyword and the open parenthesis. |
| 105 | 105 | */ |
| 106 | - if ( \T_ARRAY === $this->tokens[ $stackPtr ]['code'] ) { |
|
| 106 | + if ( \T_ARRAY === $this->tokens[ $stackPtr ][ 'code' ] ) { |
|
| 107 | 107 | |
| 108 | 108 | if ( ( $stackPtr + 1 ) !== $opener ) { |
| 109 | 109 | $error = 'There must be no space between the "array" keyword and the opening parenthesis'; |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | unset( $nextNonWhitespace ); |
| 160 | 160 | |
| 161 | 161 | // Pass off to either the single line or multi-line array analysis. |
| 162 | - if ( $this->tokens[ $opener ]['line'] === $this->tokens[ $closer ]['line'] ) { |
|
| 162 | + if ( $this->tokens[ $opener ][ 'line' ] === $this->tokens[ $closer ][ 'line' ] ) { |
|
| 163 | 163 | $this->process_single_line_array( $stackPtr, $opener, $closer ); |
| 164 | 164 | } else { |
| 165 | 165 | $this->process_multi_line_array( $stackPtr, $opener, $closer ); |
@@ -197,21 +197,21 @@ discard block |
||
| 197 | 197 | */ |
| 198 | 198 | $array_has_keys = false; // Reset before doing more detailed check. |
| 199 | 199 | foreach ( $array_items as $item ) { |
| 200 | - for ( $ptr = $item['start']; $ptr <= $item['end']; $ptr++ ) { |
|
| 201 | - if ( \T_DOUBLE_ARROW === $this->tokens[ $ptr ]['code'] ) { |
|
| 200 | + for ( $ptr = $item[ 'start' ]; $ptr <= $item[ 'end' ]; $ptr++ ) { |
|
| 201 | + if ( \T_DOUBLE_ARROW === $this->tokens[ $ptr ][ 'code' ] ) { |
|
| 202 | 202 | $array_has_keys = true; |
| 203 | 203 | break 2; |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | // Skip passed any nested arrays. |
| 207 | - if ( isset( $this->targets[ $this->tokens[ $ptr ]['code'] ] ) ) { |
|
| 207 | + if ( isset( $this->targets[ $this->tokens[ $ptr ][ 'code' ] ] ) ) { |
|
| 208 | 208 | $nested_array_open_close = $this->find_array_open_close( $ptr ); |
| 209 | 209 | if ( false === $nested_array_open_close ) { |
| 210 | 210 | // Nested array open/close could not be determined. |
| 211 | 211 | continue; |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | - $ptr = $nested_array_open_close['closer']; |
|
| 214 | + $ptr = $nested_array_open_close[ 'closer' ]; |
|
| 215 | 215 | } |
| 216 | 216 | } |
| 217 | 217 | } |
@@ -241,16 +241,16 @@ discard block |
||
| 241 | 241 | */ |
| 242 | 242 | $first_non_empty = $this->phpcsFile->findNext( |
| 243 | 243 | Tokens::$emptyTokens, |
| 244 | - $item['start'], |
|
| 245 | - ( $item['end'] + 1 ), |
|
| 244 | + $item[ 'start' ], |
|
| 245 | + ( $item[ 'end' ] + 1 ), |
|
| 246 | 246 | true |
| 247 | 247 | ); |
| 248 | 248 | if ( false === $first_non_empty ) { |
| 249 | 249 | continue; |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | - if ( $item['start'] <= ( $first_non_empty - 1 ) |
|
| 253 | - && \T_WHITESPACE === $this->tokens[ ( $first_non_empty - 1 ) ]['code'] |
|
| 252 | + if ( $item[ 'start' ] <= ( $first_non_empty - 1 ) |
|
| 253 | + && \T_WHITESPACE === $this->tokens[ ( $first_non_empty - 1 ) ][ 'code' ] |
|
| 254 | 254 | ) { |
| 255 | 255 | // Remove whitespace which would otherwise becoming trailing |
| 256 | 256 | // (as it gives problems with the fixed file). |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | /* |
| 273 | 273 | * Check that there is a single space after the array opener and before the array closer. |
| 274 | 274 | */ |
| 275 | - if ( \T_WHITESPACE !== $this->tokens[ ( $opener + 1 ) ]['code'] ) { |
|
| 275 | + if ( \T_WHITESPACE !== $this->tokens[ ( $opener + 1 ) ][ 'code' ] ) { |
|
| 276 | 276 | |
| 277 | 277 | $fix = $this->phpcsFile->addFixableError( |
| 278 | 278 | 'Missing space after array opener.', |
@@ -283,13 +283,13 @@ discard block |
||
| 283 | 283 | if ( true === $fix ) { |
| 284 | 284 | $this->phpcsFile->fixer->addContent( $opener, ' ' ); |
| 285 | 285 | } |
| 286 | - } elseif ( ' ' !== $this->tokens[ ( $opener + 1 ) ]['content'] ) { |
|
| 286 | + } elseif ( ' ' !== $this->tokens[ ( $opener + 1 ) ][ 'content' ] ) { |
|
| 287 | 287 | |
| 288 | 288 | $fix = $this->phpcsFile->addFixableError( |
| 289 | 289 | 'Expected 1 space after array opener, found %s.', |
| 290 | 290 | $opener, |
| 291 | 291 | 'SpaceAfterArrayOpener', |
| 292 | - array( \strlen( $this->tokens[ ( $opener + 1 ) ]['content'] ) ) |
|
| 292 | + array( \strlen( $this->tokens[ ( $opener + 1 ) ][ 'content' ] ) ) |
|
| 293 | 293 | ); |
| 294 | 294 | |
| 295 | 295 | if ( true === $fix ) { |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | } |
| 298 | 298 | } |
| 299 | 299 | |
| 300 | - if ( \T_WHITESPACE !== $this->tokens[ ( $closer - 1 ) ]['code'] ) { |
|
| 300 | + if ( \T_WHITESPACE !== $this->tokens[ ( $closer - 1 ) ][ 'code' ] ) { |
|
| 301 | 301 | |
| 302 | 302 | $fix = $this->phpcsFile->addFixableError( |
| 303 | 303 | 'Missing space before array closer.', |
@@ -308,13 +308,13 @@ discard block |
||
| 308 | 308 | if ( true === $fix ) { |
| 309 | 309 | $this->phpcsFile->fixer->addContentBefore( $closer, ' ' ); |
| 310 | 310 | } |
| 311 | - } elseif ( ' ' !== $this->tokens[ ( $closer - 1 ) ]['content'] ) { |
|
| 311 | + } elseif ( ' ' !== $this->tokens[ ( $closer - 1 ) ][ 'content' ] ) { |
|
| 312 | 312 | |
| 313 | 313 | $fix = $this->phpcsFile->addFixableError( |
| 314 | 314 | 'Expected 1 space before array closer, found %s.', |
| 315 | 315 | $closer, |
| 316 | 316 | 'SpaceBeforeArrayCloser', |
| 317 | - array( \strlen( $this->tokens[ ( $closer - 1 ) ]['content'] ) ) |
|
| 317 | + array( \strlen( $this->tokens[ ( $closer - 1 ) ][ 'content' ] ) ) |
|
| 318 | 318 | ); |
| 319 | 319 | |
| 320 | 320 | if ( true === $fix ) { |
@@ -341,7 +341,7 @@ discard block |
||
| 341 | 341 | */ |
| 342 | 342 | $last_content = $this->phpcsFile->findPrevious( \T_WHITESPACE, ( $closer - 1 ), $opener, true ); |
| 343 | 343 | if ( false !== $last_content |
| 344 | - && $this->tokens[ $last_content ]['line'] === $this->tokens[ $closer ]['line'] |
|
| 344 | + && $this->tokens[ $last_content ][ 'line' ] === $this->tokens[ $closer ][ 'line' ] |
|
| 345 | 345 | ) { |
| 346 | 346 | $fix = $this->phpcsFile->addFixableError( |
| 347 | 347 | 'Closing parenthesis of array declaration must be on a new line', |
@@ -352,7 +352,7 @@ discard block |
||
| 352 | 352 | $this->phpcsFile->fixer->beginChangeset(); |
| 353 | 353 | |
| 354 | 354 | if ( $last_content < ( $closer - 1 ) |
| 355 | - && \T_WHITESPACE === $this->tokens[ ( $closer - 1 ) ]['code'] |
|
| 355 | + && \T_WHITESPACE === $this->tokens[ ( $closer - 1 ) ][ 'code' ] |
|
| 356 | 356 | ) { |
| 357 | 357 | // Remove whitespace which would otherwise becoming trailing |
| 358 | 358 | // (as it gives problems with the fixed file). |
@@ -371,34 +371,34 @@ discard block |
||
| 371 | 371 | $end_of_last_item = $opener; |
| 372 | 372 | |
| 373 | 373 | foreach ( $array_items as $item ) { |
| 374 | - $end_of_this_item = ( $item['end'] + 1 ); |
|
| 374 | + $end_of_this_item = ( $item[ 'end' ] + 1 ); |
|
| 375 | 375 | |
| 376 | 376 | // Find the line on which the item starts. |
| 377 | 377 | $first_content = $this->phpcsFile->findNext( |
| 378 | 378 | array( \T_WHITESPACE, \T_DOC_COMMENT_WHITESPACE ), |
| 379 | - $item['start'], |
|
| 379 | + $item[ 'start' ], |
|
| 380 | 380 | $end_of_this_item, |
| 381 | 381 | true |
| 382 | 382 | ); |
| 383 | 383 | |
| 384 | 384 | // Ignore comments after array items if the next real content starts on a new line. |
| 385 | - if ( $this->tokens[ $first_content ]['line'] === $this->tokens[ $end_of_last_item ]['line'] |
|
| 386 | - && ( \T_COMMENT === $this->tokens[ $first_content ]['code'] |
|
| 387 | - || isset( Tokens::$phpcsCommentTokens[ $this->tokens[ $first_content ]['code'] ] ) ) |
|
| 385 | + if ( $this->tokens[ $first_content ][ 'line' ] === $this->tokens[ $end_of_last_item ][ 'line' ] |
|
| 386 | + && ( \T_COMMENT === $this->tokens[ $first_content ][ 'code' ] |
|
| 387 | + || isset( Tokens::$phpcsCommentTokens[ $this->tokens[ $first_content ][ 'code' ] ] ) ) |
|
| 388 | 388 | ) { |
| 389 | 389 | $end_of_comment = $first_content; |
| 390 | 390 | |
| 391 | 391 | // Find the end of (multi-line) /* */- style trailing comments. |
| 392 | - if ( substr( ltrim( $this->tokens[ $end_of_comment ]['content'] ), 0, 2 ) === '/*' ) { |
|
| 393 | - while ( ( \T_COMMENT === $this->tokens[ $end_of_comment ]['code'] |
|
| 394 | - || isset( Tokens::$phpcsCommentTokens[ $this->tokens[ $end_of_comment ]['code'] ] ) ) |
|
| 395 | - && substr( rtrim( $this->tokens[ $end_of_comment ]['content'] ), -2 ) !== '*/' |
|
| 392 | + if ( substr( ltrim( $this->tokens[ $end_of_comment ][ 'content' ] ), 0, 2 ) === '/*' ) { |
|
| 393 | + while ( ( \T_COMMENT === $this->tokens[ $end_of_comment ][ 'code' ] |
|
| 394 | + || isset( Tokens::$phpcsCommentTokens[ $this->tokens[ $end_of_comment ][ 'code' ] ] ) ) |
|
| 395 | + && substr( rtrim( $this->tokens[ $end_of_comment ][ 'content' ] ), -2 ) !== '*/' |
|
| 396 | 396 | && ( $end_of_comment + 1 ) < $end_of_this_item |
| 397 | 397 | ) { |
| 398 | 398 | $end_of_comment++; |
| 399 | 399 | } |
| 400 | 400 | |
| 401 | - if ( $this->tokens[ $end_of_comment ]['line'] !== $this->tokens[ $end_of_last_item ]['line'] ) { |
|
| 401 | + if ( $this->tokens[ $end_of_comment ][ 'line' ] !== $this->tokens[ $end_of_last_item ][ 'line' ] ) { |
|
| 402 | 402 | // Multi-line trailing comment. |
| 403 | 403 | $end_of_last_item = $end_of_comment; |
| 404 | 404 | } |
@@ -417,7 +417,7 @@ discard block |
||
| 417 | 417 | continue; |
| 418 | 418 | } |
| 419 | 419 | |
| 420 | - if ( $this->tokens[ $next ]['line'] !== $this->tokens[ $first_content ]['line'] ) { |
|
| 420 | + if ( $this->tokens[ $next ][ 'line' ] !== $this->tokens[ $first_content ][ 'line' ] ) { |
|
| 421 | 421 | $first_content = $next; |
| 422 | 422 | } |
| 423 | 423 | } |
@@ -428,7 +428,7 @@ discard block |
||
| 428 | 428 | continue; |
| 429 | 429 | } |
| 430 | 430 | |
| 431 | - if ( $this->tokens[ $end_of_last_item ]['line'] === $this->tokens[ $first_content ]['line'] ) { |
|
| 431 | + if ( $this->tokens[ $end_of_last_item ][ 'line' ] === $this->tokens[ $first_content ][ 'line' ] ) { |
|
| 432 | 432 | |
| 433 | 433 | $fix = $this->phpcsFile->addFixableError( |
| 434 | 434 | 'Each item in a multi-line array must be on a new line', |
@@ -441,7 +441,7 @@ discard block |
||
| 441 | 441 | $this->phpcsFile->fixer->beginChangeset(); |
| 442 | 442 | |
| 443 | 443 | if ( ( $end_of_last_item + 1 ) <= ( $first_content - 1 ) |
| 444 | - && \T_WHITESPACE === $this->tokens[ ( $first_content - 1 ) ]['code'] |
|
| 444 | + && \T_WHITESPACE === $this->tokens[ ( $first_content - 1 ) ][ 'code' ] |
|
| 445 | 445 | ) { |
| 446 | 446 | // Remove whitespace which would otherwise becoming trailing |
| 447 | 447 | // (as it gives problems with the fixed file). |
@@ -60,8 +60,8 @@ discard block |
||
| 60 | 60 | return; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - $opener = $array_open_close['opener']; |
|
| 64 | - $closer = $array_open_close['closer']; |
|
| 63 | + $opener = $array_open_close[ 'opener' ]; |
|
| 64 | + $closer = $array_open_close[ 'closer' ]; |
|
| 65 | 65 | unset( $array_open_close ); |
| 66 | 66 | |
| 67 | 67 | // This array is empty, so the below checks aren't necessary. |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | $single_line = true; |
| 73 | - if ( $this->tokens[ $opener ]['line'] !== $this->tokens[ $closer ]['line'] ) { |
|
| 73 | + if ( $this->tokens[ $opener ][ 'line' ] !== $this->tokens[ $closer ][ 'line' ] ) { |
|
| 74 | 74 | $single_line = false; |
| 75 | 75 | } |
| 76 | 76 | |
@@ -84,9 +84,9 @@ discard block |
||
| 84 | 84 | |
| 85 | 85 | // Note: $item_index is 1-based and the array items are split on the commas! |
| 86 | 86 | foreach ( $array_items as $item_index => $item ) { |
| 87 | - $maybe_comma = ( $item['end'] + 1 ); |
|
| 87 | + $maybe_comma = ( $item[ 'end' ] + 1 ); |
|
| 88 | 88 | $is_comma = false; |
| 89 | - if ( isset( $this->tokens[ $maybe_comma ] ) && \T_COMMA === $this->tokens[ $maybe_comma ]['code'] ) { |
|
| 89 | + if ( isset( $this->tokens[ $maybe_comma ] ) && \T_COMMA === $this->tokens[ $maybe_comma ][ 'code' ] ) { |
|
| 90 | 90 | $is_comma = true; |
| 91 | 91 | } |
| 92 | 92 | |
@@ -116,8 +116,8 @@ discard block |
||
| 116 | 116 | |
| 117 | 117 | $last_content = $this->phpcsFile->findPrevious( |
| 118 | 118 | Tokens::$emptyTokens, |
| 119 | - $item['end'], |
|
| 120 | - $item['start'], |
|
| 119 | + $item[ 'end' ], |
|
| 120 | + $item[ 'start' ], |
|
| 121 | 121 | true |
| 122 | 122 | ); |
| 123 | 123 | |
@@ -153,23 +153,23 @@ discard block |
||
| 153 | 153 | /* |
| 154 | 154 | * Check for whitespace at the end of the array item. |
| 155 | 155 | */ |
| 156 | - if ( $last_content !== $item['end'] |
|
| 156 | + if ( $last_content !== $item[ 'end' ] |
|
| 157 | 157 | // Ignore whitespace at the end of a multi-line item if it is the end of a heredoc/nowdoc. |
| 158 | 158 | && ( true === $single_line |
| 159 | - || ! isset( Tokens::$heredocTokens[ $this->tokens[ $last_content ]['code'] ] ) ) |
|
| 159 | + || ! isset( Tokens::$heredocTokens[ $this->tokens[ $last_content ][ 'code' ] ] ) ) |
|
| 160 | 160 | ) { |
| 161 | 161 | $newlines = 0; |
| 162 | 162 | $spaces = 0; |
| 163 | - for ( $i = $item['end']; $i > $last_content; $i-- ) { |
|
| 163 | + for ( $i = $item[ 'end' ]; $i > $last_content; $i-- ) { |
|
| 164 | 164 | |
| 165 | - if ( \T_WHITESPACE === $this->tokens[ $i ]['code'] ) { |
|
| 166 | - if ( $this->tokens[ $i ]['content'] === $this->phpcsFile->eolChar ) { |
|
| 165 | + if ( \T_WHITESPACE === $this->tokens[ $i ][ 'code' ] ) { |
|
| 166 | + if ( $this->tokens[ $i ][ 'content' ] === $this->phpcsFile->eolChar ) { |
|
| 167 | 167 | $newlines++; |
| 168 | 168 | } else { |
| 169 | - $spaces += $this->tokens[ $i ]['length']; |
|
| 169 | + $spaces += $this->tokens[ $i ][ 'length' ]; |
|
| 170 | 170 | } |
| 171 | - } elseif ( \T_COMMENT === $this->tokens[ $i ]['code'] |
|
| 172 | - || isset( Tokens::$phpcsCommentTokens[ $this->tokens[ $i ]['code'] ] ) |
|
| 171 | + } elseif ( \T_COMMENT === $this->tokens[ $i ][ 'code' ] |
|
| 172 | + || isset( Tokens::$phpcsCommentTokens[ $this->tokens[ $i ][ 'code' ] ] ) |
|
| 173 | 173 | ) { |
| 174 | 174 | break; |
| 175 | 175 | } |
@@ -177,10 +177,10 @@ discard block |
||
| 177 | 177 | |
| 178 | 178 | $space_phrases = array(); |
| 179 | 179 | if ( $spaces > 0 ) { |
| 180 | - $space_phrases[] = $spaces . ' spaces'; |
|
| 180 | + $space_phrases[ ] = $spaces . ' spaces'; |
|
| 181 | 181 | } |
| 182 | 182 | if ( $newlines > 0 ) { |
| 183 | - $space_phrases[] = $newlines . ' newlines'; |
|
| 183 | + $space_phrases[ ] = $newlines . ' newlines'; |
|
| 184 | 184 | } |
| 185 | 185 | unset( $newlines, $spaces ); |
| 186 | 186 | |
@@ -189,20 +189,20 @@ discard block |
||
| 189 | 189 | $maybe_comma, |
| 190 | 190 | 'SpaceBeforeComma', |
| 191 | 191 | array( |
| 192 | - $this->tokens[ $last_content ]['content'], |
|
| 192 | + $this->tokens[ $last_content ][ 'content' ], |
|
| 193 | 193 | implode( ' and ', $space_phrases ), |
| 194 | 194 | ) |
| 195 | 195 | ); |
| 196 | 196 | |
| 197 | 197 | if ( true === $fix ) { |
| 198 | 198 | $this->phpcsFile->fixer->beginChangeset(); |
| 199 | - for ( $i = $item['end']; $i > $last_content; $i-- ) { |
|
| 199 | + for ( $i = $item[ 'end' ]; $i > $last_content; $i-- ) { |
|
| 200 | 200 | |
| 201 | - if ( \T_WHITESPACE === $this->tokens[ $i ]['code'] ) { |
|
| 201 | + if ( \T_WHITESPACE === $this->tokens[ $i ][ 'code' ] ) { |
|
| 202 | 202 | $this->phpcsFile->fixer->replaceToken( $i, '' ); |
| 203 | 203 | |
| 204 | - } elseif ( \T_COMMENT === $this->tokens[ $i ]['code'] |
|
| 205 | - || isset( Tokens::$phpcsCommentTokens[ $this->tokens[ $i ]['code'] ] ) |
|
| 204 | + } elseif ( \T_COMMENT === $this->tokens[ $i ][ 'code' ] |
|
| 205 | + || isset( Tokens::$phpcsCommentTokens[ $this->tokens[ $i ][ 'code' ] ] ) |
|
| 206 | 206 | ) { |
| 207 | 207 | // We need to move the comma to before the comment. |
| 208 | 208 | $this->phpcsFile->fixer->addContent( $last_content, ',' ); |
@@ -231,9 +231,9 @@ discard block |
||
| 231 | 231 | */ |
| 232 | 232 | $next_token = $this->tokens[ ( $maybe_comma + 1 ) ]; |
| 233 | 233 | |
| 234 | - if ( \T_WHITESPACE === $next_token['code'] ) { |
|
| 234 | + if ( \T_WHITESPACE === $next_token[ 'code' ] ) { |
|
| 235 | 235 | |
| 236 | - if ( false === $single_line && $this->phpcsFile->eolChar === $next_token['content'] ) { |
|
| 236 | + if ( false === $single_line && $this->phpcsFile->eolChar === $next_token[ 'content' ] ) { |
|
| 237 | 237 | continue; |
| 238 | 238 | } |
| 239 | 239 | |
@@ -246,14 +246,14 @@ discard block |
||
| 246 | 246 | |
| 247 | 247 | if ( false === $next_non_whitespace |
| 248 | 248 | || ( false === $single_line |
| 249 | - && $this->tokens[ $next_non_whitespace ]['line'] === $this->tokens[ $maybe_comma ]['line'] |
|
| 250 | - && ( \T_COMMENT === $this->tokens[ $next_non_whitespace ]['code'] |
|
| 251 | - || isset( Tokens::$phpcsCommentTokens[ $this->tokens[ $next_non_whitespace ]['code'] ] ) ) ) |
|
| 249 | + && $this->tokens[ $next_non_whitespace ][ 'line' ] === $this->tokens[ $maybe_comma ][ 'line' ] |
|
| 250 | + && ( \T_COMMENT === $this->tokens[ $next_non_whitespace ][ 'code' ] |
|
| 251 | + || isset( Tokens::$phpcsCommentTokens[ $this->tokens[ $next_non_whitespace ][ 'code' ] ] ) ) ) |
|
| 252 | 252 | ) { |
| 253 | 253 | continue; |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | - $space_length = $next_token['length']; |
|
| 256 | + $space_length = $next_token[ 'length' ]; |
|
| 257 | 257 | if ( 1 === $space_length ) { |
| 258 | 258 | continue; |
| 259 | 259 | } |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | $maybe_comma, |
| 264 | 264 | 'SpaceAfterComma', |
| 265 | 265 | array( |
| 266 | - $this->tokens[ $next_non_whitespace ]['content'], |
|
| 266 | + $this->tokens[ $next_non_whitespace ][ 'content' ], |
|
| 267 | 267 | $space_length, |
| 268 | 268 | ) |
| 269 | 269 | ); |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | 'Expected 1 space between comma and "%s"; 0 found', |
| 279 | 279 | $maybe_comma, |
| 280 | 280 | 'NoSpaceAfterComma', |
| 281 | - array( $next_token['content'] ) |
|
| 281 | + array( $next_token[ 'content' ] ) |
|
| 282 | 282 | ); |
| 283 | 283 | |
| 284 | 284 | if ( true === $fix ) { |
@@ -173,8 +173,8 @@ discard block |
||
| 173 | 173 | return; |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - $opener = $array_open_close['opener']; |
|
| 177 | - $closer = $array_open_close['closer']; |
|
| 176 | + $opener = $array_open_close[ 'opener' ]; |
|
| 177 | + $closer = $array_open_close[ 'closer' ]; |
|
| 178 | 178 | |
| 179 | 179 | $array_items = $this->get_function_call_parameters( $stackPtr ); |
| 180 | 180 | if ( empty( $array_items ) ) { |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | // Pass off to either the single line or multi-line array analysis. |
| 185 | - if ( $this->tokens[ $opener ]['line'] === $this->tokens[ $closer ]['line'] ) { |
|
| 185 | + if ( $this->tokens[ $opener ][ 'line' ] === $this->tokens[ $closer ][ 'line' ] ) { |
|
| 186 | 186 | return $this->process_single_line_array( $stackPtr, $array_items, $opener, $closer ); |
| 187 | 187 | } else { |
| 188 | 188 | return $this->process_multi_line_array( $stackPtr, $array_items, $opener, $closer ); |
@@ -222,12 +222,12 @@ discard block |
||
| 222 | 222 | ); |
| 223 | 223 | |
| 224 | 224 | while ( false !== $next_arrow ) { |
| 225 | - if ( \T_WHITESPACE === $this->tokens[ ( $next_arrow - 1 ) ]['code'] ) { |
|
| 226 | - $space_length = $this->tokens[ ( $next_arrow - 1 ) ]['length']; |
|
| 225 | + if ( \T_WHITESPACE === $this->tokens[ ( $next_arrow - 1 ) ][ 'code' ] ) { |
|
| 226 | + $space_length = $this->tokens[ ( $next_arrow - 1 ) ][ 'length' ]; |
|
| 227 | 227 | if ( 1 !== $space_length ) { |
| 228 | 228 | $error = 'Expected 1 space between "%s" and double arrow; %s found'; |
| 229 | 229 | $data = array( |
| 230 | - $this->tokens[ ( $next_arrow - 2 ) ]['content'], |
|
| 230 | + $this->tokens[ ( $next_arrow - 2 ) ][ 'content' ], |
|
| 231 | 231 | $space_length, |
| 232 | 232 | ); |
| 233 | 233 | |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | */ |
| 265 | 265 | protected function process_multi_line_array( $stackPtr, $items, $opener, $closer ) { |
| 266 | 266 | |
| 267 | - $this->maxColumn = (int) $this->maxColumn; |
|
| 267 | + $this->maxColumn = (int)$this->maxColumn; |
|
| 268 | 268 | $this->validate_align_multiline_items(); |
| 269 | 269 | |
| 270 | 270 | /* |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | $total_items = \count( $items ); |
| 286 | 286 | |
| 287 | 287 | foreach ( $items as $key => $item ) { |
| 288 | - if ( strpos( $item['raw'], '=>' ) === false ) { |
|
| 288 | + if ( strpos( $item[ 'raw' ], '=>' ) === false ) { |
|
| 289 | 289 | // Ignore items without assignment operators. |
| 290 | 290 | unset( $items[ $key ] ); |
| 291 | 291 | continue; |
@@ -294,8 +294,8 @@ discard block |
||
| 294 | 294 | // Find the position of the first double arrow. |
| 295 | 295 | $double_arrow = $this->phpcsFile->findNext( |
| 296 | 296 | \T_DOUBLE_ARROW, |
| 297 | - $item['start'], |
|
| 298 | - ( $item['end'] + 1 ) |
|
| 297 | + $item[ 'start' ], |
|
| 298 | + ( $item[ 'end' ] + 1 ) |
|
| 299 | 299 | ); |
| 300 | 300 | |
| 301 | 301 | if ( false === $double_arrow ) { |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | // Make sure the arrow is for this item and not for a nested array value assignment. |
| 308 | 308 | $has_array_opener = $this->phpcsFile->findNext( |
| 309 | 309 | $this->register(), |
| 310 | - $item['start'], |
|
| 310 | + $item[ 'start' ], |
|
| 311 | 311 | $double_arrow |
| 312 | 312 | ); |
| 313 | 313 | |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | $last_index_token = $this->phpcsFile->findPrevious( |
| 322 | 322 | \T_WHITESPACE, |
| 323 | 323 | ( $double_arrow - 1 ), |
| 324 | - $item['start'], |
|
| 324 | + $item[ 'start' ], |
|
| 325 | 325 | true |
| 326 | 326 | ); |
| 327 | 327 | |
@@ -332,33 +332,33 @@ discard block |
||
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | if ( true === $this->ignoreNewlines |
| 335 | - && $this->tokens[ $last_index_token ]['line'] !== $this->tokens[ $double_arrow ]['line'] |
|
| 335 | + && $this->tokens[ $last_index_token ][ 'line' ] !== $this->tokens[ $double_arrow ][ 'line' ] |
|
| 336 | 336 | ) { |
| 337 | 337 | // Ignore this item as it has a new line between the item key and the double arrow. |
| 338 | 338 | unset( $items[ $key ] ); |
| 339 | 339 | continue; |
| 340 | 340 | } |
| 341 | 341 | |
| 342 | - $index_end_position = ( $this->tokens[ $last_index_token ]['column'] + ( $this->tokens[ $last_index_token ]['length'] - 1 ) ); |
|
| 343 | - $items[ $key ]['operatorPtr'] = $double_arrow; |
|
| 344 | - $items[ $key ]['last_index_token'] = $last_index_token; |
|
| 345 | - $items[ $key ]['last_index_col'] = $index_end_position; |
|
| 342 | + $index_end_position = ( $this->tokens[ $last_index_token ][ 'column' ] + ( $this->tokens[ $last_index_token ][ 'length' ] - 1 ) ); |
|
| 343 | + $items[ $key ][ 'operatorPtr' ] = $double_arrow; |
|
| 344 | + $items[ $key ][ 'last_index_token' ] = $last_index_token; |
|
| 345 | + $items[ $key ][ 'last_index_col' ] = $index_end_position; |
|
| 346 | 346 | |
| 347 | - if ( $this->tokens[ $last_index_token ]['line'] === $this->tokens[ $item['end'] ]['line'] ) { |
|
| 348 | - $items[ $key ]['single_line'] = true; |
|
| 347 | + if ( $this->tokens[ $last_index_token ][ 'line' ] === $this->tokens[ $item[ 'end' ] ][ 'line' ] ) { |
|
| 348 | + $items[ $key ][ 'single_line' ] = true; |
|
| 349 | 349 | } else { |
| 350 | - $items[ $key ]['single_line'] = false; |
|
| 350 | + $items[ $key ][ 'single_line' ] = false; |
|
| 351 | 351 | $multi_line_count++; |
| 352 | 352 | } |
| 353 | 353 | |
| 354 | 354 | if ( ( $index_end_position + 2 ) <= $this->maxColumn ) { |
| 355 | - $index_end_cols[] = $index_end_position; |
|
| 355 | + $index_end_cols[ ] = $index_end_position; |
|
| 356 | 356 | } |
| 357 | 357 | |
| 358 | - if ( ! isset( $double_arrow_cols[ $this->tokens[ $double_arrow ]['column'] ] ) ) { |
|
| 359 | - $double_arrow_cols[ $this->tokens[ $double_arrow ]['column'] ] = 1; |
|
| 358 | + if ( ! isset( $double_arrow_cols[ $this->tokens[ $double_arrow ][ 'column' ] ] ) ) { |
|
| 359 | + $double_arrow_cols[ $this->tokens[ $double_arrow ][ 'column' ] ] = 1; |
|
| 360 | 360 | } else { |
| 361 | - $double_arrow_cols[ $this->tokens[ $double_arrow ]['column'] ]++; |
|
| 361 | + $double_arrow_cols[ $this->tokens[ $double_arrow ][ 'column' ] ]++; |
|
| 362 | 362 | } |
| 363 | 363 | } |
| 364 | 364 | unset( $key, $item, $double_arrow, $has_array_opener, $last_index_token ); |
@@ -376,7 +376,7 @@ discard block |
||
| 376 | 376 | } elseif ( 'never' === $this->alignMultilineItems ) { |
| 377 | 377 | $alignMultilineItems = false; |
| 378 | 378 | } else { |
| 379 | - $percentage = (string) round( ( $multi_line_count / $total_items ) * 100, 0 ); |
|
| 379 | + $percentage = (string)round( ( $multi_line_count / $total_items ) * 100, 0 ); |
|
| 380 | 380 | |
| 381 | 381 | // Bit hacky, but this is the only comparison function in PHP which allows to |
| 382 | 382 | // pass the comparison operator. And hey, it works ;-). |
@@ -392,18 +392,18 @@ discard block |
||
| 392 | 392 | $double_arrow_cols = array(); |
| 393 | 393 | |
| 394 | 394 | foreach ( $items as $item ) { |
| 395 | - if ( false === $item['single_line'] ) { |
|
| 395 | + if ( false === $item[ 'single_line' ] ) { |
|
| 396 | 396 | continue; |
| 397 | 397 | } |
| 398 | 398 | |
| 399 | - if ( ( $item['last_index_col'] + 2 ) <= $this->maxColumn ) { |
|
| 400 | - $select_index_end_cols[] = $item['last_index_col']; |
|
| 399 | + if ( ( $item[ 'last_index_col' ] + 2 ) <= $this->maxColumn ) { |
|
| 400 | + $select_index_end_cols[ ] = $item[ 'last_index_col' ]; |
|
| 401 | 401 | } |
| 402 | 402 | |
| 403 | - if ( ! isset( $double_arrow_cols[ $this->tokens[ $item['operatorPtr'] ]['column'] ] ) ) { |
|
| 404 | - $double_arrow_cols[ $this->tokens[ $item['operatorPtr'] ]['column'] ] = 1; |
|
| 403 | + if ( ! isset( $double_arrow_cols[ $this->tokens[ $item[ 'operatorPtr' ] ][ 'column' ] ] ) ) { |
|
| 404 | + $double_arrow_cols[ $this->tokens[ $item[ 'operatorPtr' ] ][ 'column' ] ] = 1; |
|
| 405 | 405 | } else { |
| 406 | - $double_arrow_cols[ $this->tokens[ $item['operatorPtr'] ]['column'] ]++; |
|
| 406 | + $double_arrow_cols[ $this->tokens[ $item[ 'operatorPtr' ] ][ 'column' ] ]++; |
|
| 407 | 407 | } |
| 408 | 408 | } |
| 409 | 409 | } |
@@ -446,20 +446,20 @@ discard block |
||
| 446 | 446 | * Verify and correct the spacing around the double arrows. |
| 447 | 447 | */ |
| 448 | 448 | foreach ( $items as $item ) { |
| 449 | - if ( $this->tokens[ $item['operatorPtr'] ]['column'] === $expected_col |
|
| 450 | - && $this->tokens[ $item['operatorPtr'] ]['line'] === $this->tokens[ $item['last_index_token'] ]['line'] |
|
| 449 | + if ( $this->tokens[ $item[ 'operatorPtr' ] ][ 'column' ] === $expected_col |
|
| 450 | + && $this->tokens[ $item[ 'operatorPtr' ] ][ 'line' ] === $this->tokens[ $item[ 'last_index_token' ] ][ 'line' ] |
|
| 451 | 451 | ) { |
| 452 | 452 | // Already correctly aligned. |
| 453 | 453 | continue; |
| 454 | 454 | } |
| 455 | 455 | |
| 456 | - if ( \T_WHITESPACE !== $this->tokens[ ( $item['operatorPtr'] - 1 ) ]['code'] ) { |
|
| 456 | + if ( \T_WHITESPACE !== $this->tokens[ ( $item[ 'operatorPtr' ] - 1 ) ][ 'code' ] ) { |
|
| 457 | 457 | $before = 0; |
| 458 | 458 | } else { |
| 459 | - if ( $this->tokens[ $item['last_index_token'] ]['line'] !== $this->tokens[ $item['operatorPtr'] ]['line'] ) { |
|
| 459 | + if ( $this->tokens[ $item[ 'last_index_token' ] ][ 'line' ] !== $this->tokens[ $item[ 'operatorPtr' ] ][ 'line' ] ) { |
|
| 460 | 460 | $before = 'newline'; |
| 461 | 461 | } else { |
| 462 | - $before = $this->tokens[ ( $item['operatorPtr'] - 1 ) ]['length']; |
|
| 462 | + $before = $this->tokens[ ( $item[ 'operatorPtr' ] - 1 ) ][ 'length' ]; |
|
| 463 | 463 | } |
| 464 | 464 | } |
| 465 | 465 | |
@@ -467,19 +467,19 @@ discard block |
||
| 467 | 467 | * Deal with index sizes larger than maxColumn and with multi-line |
| 468 | 468 | * array items which should not be aligned. |
| 469 | 469 | */ |
| 470 | - if ( ( $item['last_index_col'] + 2 ) > $this->maxColumn |
|
| 471 | - || ( false === $alignMultilineItems && false === $item['single_line'] ) |
|
| 470 | + if ( ( $item[ 'last_index_col' ] + 2 ) > $this->maxColumn |
|
| 471 | + || ( false === $alignMultilineItems && false === $item[ 'single_line' ] ) |
|
| 472 | 472 | ) { |
| 473 | 473 | |
| 474 | - if ( ( $item['last_index_col'] + 2 ) === $this->tokens[ $item['operatorPtr'] ]['column'] |
|
| 475 | - && $this->tokens[ $item['operatorPtr'] ]['line'] === $this->tokens[ $item['last_index_token'] ]['line'] |
|
| 474 | + if ( ( $item[ 'last_index_col' ] + 2 ) === $this->tokens[ $item[ 'operatorPtr' ] ][ 'column' ] |
|
| 475 | + && $this->tokens[ $item[ 'operatorPtr' ] ][ 'line' ] === $this->tokens[ $item[ 'last_index_token' ] ][ 'line' ] |
|
| 476 | 476 | ) { |
| 477 | 477 | // MaxColumn/Multi-line item exception, already correctly aligned. |
| 478 | 478 | continue; |
| 479 | 479 | } |
| 480 | 480 | |
| 481 | 481 | $prefix = 'LongIndex'; |
| 482 | - if ( false === $alignMultilineItems && false === $item['single_line'] ) { |
|
| 482 | + if ( false === $alignMultilineItems && false === $item[ 'single_line' ] ) { |
|
| 483 | 483 | $prefix = 'MultilineItem'; |
| 484 | 484 | } |
| 485 | 485 | |
@@ -490,10 +490,10 @@ discard block |
||
| 490 | 490 | |
| 491 | 491 | $fix = $this->phpcsFile->addFixableWarning( |
| 492 | 492 | 'Expected 1 space between "%s" and double arrow; %s found.', |
| 493 | - $item['operatorPtr'], |
|
| 493 | + $item[ 'operatorPtr' ], |
|
| 494 | 494 | $error_code, |
| 495 | 495 | array( |
| 496 | - $this->tokens[ $item['last_index_token'] ]['content'], |
|
| 496 | + $this->tokens[ $item[ 'last_index_token' ] ][ 'content' ], |
|
| 497 | 497 | $before, |
| 498 | 498 | ) |
| 499 | 499 | ); |
@@ -502,12 +502,12 @@ discard block |
||
| 502 | 502 | $this->phpcsFile->fixer->beginChangeset(); |
| 503 | 503 | |
| 504 | 504 | // Remove whitespace tokens between the end of the index and the arrow, if any. |
| 505 | - for ( $i = ( $item['last_index_token'] + 1 ); $i < $item['operatorPtr']; $i++ ) { |
|
| 505 | + for ( $i = ( $item[ 'last_index_token' ] + 1 ); $i < $item[ 'operatorPtr' ]; $i++ ) { |
|
| 506 | 506 | $this->phpcsFile->fixer->replaceToken( $i, '' ); |
| 507 | 507 | } |
| 508 | 508 | |
| 509 | 509 | // Add the correct whitespace. |
| 510 | - $this->phpcsFile->fixer->addContent( $item['last_index_token'], ' ' ); |
|
| 510 | + $this->phpcsFile->fixer->addContent( $item[ 'last_index_token' ], ' ' ); |
|
| 511 | 511 | |
| 512 | 512 | $this->phpcsFile->fixer->endChangeset(); |
| 513 | 513 | } |
@@ -517,15 +517,15 @@ discard block |
||
| 517 | 517 | /* |
| 518 | 518 | * Deal with the space before double arrows in all other cases. |
| 519 | 519 | */ |
| 520 | - $expected_whitespace = $expected_col - ( $this->tokens[ $item['last_index_token'] ]['column'] + $this->tokens[ $item['last_index_token'] ]['length'] ); |
|
| 520 | + $expected_whitespace = $expected_col - ( $this->tokens[ $item[ 'last_index_token' ] ][ 'column' ] + $this->tokens[ $item[ 'last_index_token' ] ][ 'length' ] ); |
|
| 521 | 521 | |
| 522 | 522 | $fix = $this->phpcsFile->addFixableWarning( |
| 523 | 523 | 'Array double arrow not aligned correctly; expected %s space(s) between "%s" and double arrow, but found %s.', |
| 524 | - $item['operatorPtr'], |
|
| 524 | + $item[ 'operatorPtr' ], |
|
| 525 | 525 | 'DoubleArrowNotAligned', |
| 526 | 526 | array( |
| 527 | 527 | $expected_whitespace, |
| 528 | - $this->tokens[ $item['last_index_token'] ]['content'], |
|
| 528 | + $this->tokens[ $item[ 'last_index_token' ] ][ 'content' ], |
|
| 529 | 529 | $before, |
| 530 | 530 | ) |
| 531 | 531 | ); |
@@ -535,13 +535,13 @@ discard block |
||
| 535 | 535 | $this->phpcsFile->fixer->beginChangeset(); |
| 536 | 536 | |
| 537 | 537 | // Remove whitespace tokens between the end of the index and the arrow, if any. |
| 538 | - for ( $i = ( $item['last_index_token'] + 1 ); $i < $item['operatorPtr']; $i++ ) { |
|
| 538 | + for ( $i = ( $item[ 'last_index_token' ] + 1 ); $i < $item[ 'operatorPtr' ]; $i++ ) { |
|
| 539 | 539 | $this->phpcsFile->fixer->replaceToken( $i, '' ); |
| 540 | 540 | } |
| 541 | 541 | |
| 542 | 542 | // Add the correct whitespace. |
| 543 | 543 | $this->phpcsFile->fixer->addContent( |
| 544 | - $item['last_index_token'], |
|
| 544 | + $item[ 'last_index_token' ], |
|
| 545 | 545 | str_repeat( ' ', $expected_whitespace ) |
| 546 | 546 | ); |
| 547 | 547 | |
@@ -550,13 +550,13 @@ discard block |
||
| 550 | 550 | // Add to the existing whitespace to prevent replacing tabs with spaces. |
| 551 | 551 | // That's the concern of another sniff. |
| 552 | 552 | $this->phpcsFile->fixer->addContent( |
| 553 | - ( $item['operatorPtr'] - 1 ), |
|
| 553 | + ( $item[ 'operatorPtr' ] - 1 ), |
|
| 554 | 554 | str_repeat( ' ', ( $expected_whitespace - $before ) ) |
| 555 | 555 | ); |
| 556 | 556 | } else { |
| 557 | 557 | // Too much whitespace found. |
| 558 | 558 | $this->phpcsFile->fixer->replaceToken( |
| 559 | - ( $item['operatorPtr'] - 1 ), |
|
| 559 | + ( $item[ 'operatorPtr' ] - 1 ), |
|
| 560 | 560 | str_repeat( ' ', $expected_whitespace ) |
| 561 | 561 | ); |
| 562 | 562 | } |
@@ -581,14 +581,14 @@ discard block |
||
| 581 | 581 | $alignMultilineItems = rtrim( $alignMultilineItems, '%' ); |
| 582 | 582 | |
| 583 | 583 | if ( preg_match( '`^([=<>!]{1,2})(100|[0-9]{1,2})$`', $alignMultilineItems, $matches ) > 0 ) { |
| 584 | - $operator = $matches[1]; |
|
| 585 | - $number = (int) $matches[2]; |
|
| 584 | + $operator = $matches[ 1 ]; |
|
| 585 | + $number = (int)$matches[ 2 ]; |
|
| 586 | 586 | |
| 587 | 587 | if ( \in_array( $operator, array( '<', '<=', '>', '>=', '==', '=', '!=', '<>' ), true ) === true |
| 588 | 588 | && ( $number >= 0 && $number <= 100 ) |
| 589 | 589 | ) { |
| 590 | 590 | $this->alignMultilineItems = $alignMultilineItems; |
| 591 | - $this->number = (string) $number; |
|
| 591 | + $this->number = (string)$number; |
|
| 592 | 592 | $this->operator = $operator; |
| 593 | 593 | return; |
| 594 | 594 | } |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | public function process_parameters( $stackPtr, $group_name, $matched_content, $parameters ) { |
| 121 | 121 | |
| 122 | 122 | // Check to see if a source ($src) is specified. |
| 123 | - if ( ! isset( $parameters[2] ) ) { |
|
| 123 | + if ( ! isset( $parameters[ 2 ] ) ) { |
|
| 124 | 124 | return; |
| 125 | 125 | } |
| 126 | 126 | |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | * Version Check: Check to make sure the version is set explicitly. |
| 129 | 129 | */ |
| 130 | 130 | |
| 131 | - if ( ! isset( $parameters[4] ) || 'null' === $parameters[4]['raw'] ) { |
|
| 131 | + if ( ! isset( $parameters[ 4 ] ) || 'null' === $parameters[ 4 ][ 'raw' ] ) { |
|
| 132 | 132 | $type = 'script'; |
| 133 | 133 | if ( strpos( $matched_content, '_style' ) !== false ) { |
| 134 | 134 | $type = 'style'; |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | ); |
| 143 | 143 | } else { |
| 144 | 144 | // The version argument should have a non-false value. |
| 145 | - if ( $this->is_falsy( $parameters[4]['start'], $parameters[4]['end'] ) ) { |
|
| 145 | + if ( $this->is_falsy( $parameters[ 4 ][ 'start' ], $parameters[ 4 ][ 'end' ] ) ) { |
|
| 146 | 146 | $this->phpcsFile->addError( |
| 147 | 147 | 'Version parameter is not explicitly set or has been set to an equivalent of "false" for %s; ' . |
| 148 | 148 | 'This means that the WordPress core version will be used which is not recommended for plugin or theme development.', |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | return; |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - if ( ! isset( $parameters[5] ) ) { |
|
| 169 | + if ( ! isset( $parameters[ 5 ] ) ) { |
|
| 170 | 170 | // If in footer is not set, throw a warning about the default. |
| 171 | 171 | $this->phpcsFile->addWarning( |
| 172 | 172 | 'In footer ($in_footer) is not set explicitly %s; ' . |
@@ -199,17 +199,17 @@ discard block |
||
| 199 | 199 | |
| 200 | 200 | $code_string = ''; |
| 201 | 201 | for ( $i = $start; $i <= $end; $i++ ) { |
| 202 | - if ( isset( $this->safe_tokens[ $this->tokens[ $i ]['code'] ] ) === false ) { |
|
| 202 | + if ( isset( $this->safe_tokens[ $this->tokens[ $i ][ 'code' ] ] ) === false ) { |
|
| 203 | 203 | // Function call/variable or other token which makes it neigh impossible |
| 204 | 204 | // to determine whether the actual value would evaluate to false. |
| 205 | 205 | return false; |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | - if ( isset( Tokens::$emptyTokens[ $this->tokens[ $i ]['code'] ] ) === true ) { |
|
| 208 | + if ( isset( Tokens::$emptyTokens[ $this->tokens[ $i ][ 'code' ] ] ) === true ) { |
|
| 209 | 209 | continue; |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | - $code_string .= $this->tokens[ $i ]['content']; |
|
| 212 | + $code_string .= $this->tokens[ $i ][ 'content' ]; |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | if ( '' === $code_string ) { |
@@ -86,18 +86,18 @@ |
||
| 86 | 86 | $message = 'The %s class has been deprecated since WordPress version %s.'; |
| 87 | 87 | $data = array( |
| 88 | 88 | ltrim( $matched_content, '\\' ), |
| 89 | - $this->deprecated_classes[ $class_name ]['version'], |
|
| 89 | + $this->deprecated_classes[ $class_name ][ 'version' ], |
|
| 90 | 90 | ); |
| 91 | 91 | |
| 92 | - if ( ! empty( $this->deprecated_classes[ $class_name ]['alt'] ) ) { |
|
| 92 | + if ( ! empty( $this->deprecated_classes[ $class_name ][ 'alt' ] ) ) { |
|
| 93 | 93 | $message .= ' Use %s instead.'; |
| 94 | - $data[] = $this->deprecated_classes[ $class_name ]['alt']; |
|
| 94 | + $data[ ] = $this->deprecated_classes[ $class_name ][ 'alt' ]; |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | $this->addMessage( |
| 98 | 98 | $message, |
| 99 | 99 | $stackPtr, |
| 100 | - ( version_compare( $this->deprecated_classes[ $class_name ]['version'], $this->minimum_supported_version, '<' ) ), |
|
| 100 | + ( version_compare( $this->deprecated_classes[ $class_name ][ 'version' ], $this->minimum_supported_version, '<' ) ), |
|
| 101 | 101 | $this->string_to_errorcode( $class_name . 'Found' ), |
| 102 | 102 | $data |
| 103 | 103 | ); |
@@ -216,34 +216,34 @@ discard block |
||
| 216 | 216 | */ |
| 217 | 217 | $params = $this->get_function_call_parameters( $stackPtr ); |
| 218 | 218 | |
| 219 | - if ( isset( $params[2] ) && 'true' === $params[2]['raw'] ) { |
|
| 219 | + if ( isset( $params[ 2 ] ) && 'true' === $params[ 2 ][ 'raw' ] ) { |
|
| 220 | 220 | // Setting `$use_include_path` to `true` is only relevant for local files. |
| 221 | 221 | return; |
| 222 | 222 | } |
| 223 | 223 | |
| 224 | - if ( isset( $params[1] ) === false ) { |
|
| 224 | + if ( isset( $params[ 1 ] ) === false ) { |
|
| 225 | 225 | // If the file to get is not set, this is a non-issue anyway. |
| 226 | 226 | return; |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | - if ( strpos( $params[1]['raw'], 'http:' ) !== false |
|
| 230 | - || strpos( $params[1]['raw'], 'https:' ) !== false |
|
| 229 | + if ( strpos( $params[ 1 ][ 'raw' ], 'http:' ) !== false |
|
| 230 | + || strpos( $params[ 1 ][ 'raw' ], 'https:' ) !== false |
|
| 231 | 231 | ) { |
| 232 | 232 | // Definitely a URL, throw notice. |
| 233 | 233 | break; |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | - if ( preg_match( '`\b(?:ABSPATH|WP_(?:CONTENT|PLUGIN)_DIR|WPMU_PLUGIN_DIR|TEMPLATEPATH|STYLESHEETPATH|(?:MU)?PLUGINDIR)\b`', $params[1]['raw'] ) === 1 ) { |
|
| 236 | + if ( preg_match( '`\b(?:ABSPATH|WP_(?:CONTENT|PLUGIN)_DIR|WPMU_PLUGIN_DIR|TEMPLATEPATH|STYLESHEETPATH|(?:MU)?PLUGINDIR)\b`', $params[ 1 ][ 'raw' ] ) === 1 ) { |
|
| 237 | 237 | // Using any of the constants matched in this regex is an indicator of a local file. |
| 238 | 238 | return; |
| 239 | 239 | } |
| 240 | 240 | |
| 241 | - if ( preg_match( '`(?:get_home_path|plugin_dir_path|get_(?:stylesheet|template)_directory|wp_upload_dir)\s*\(`i', $params[1]['raw'] ) === 1 ) { |
|
| 241 | + if ( preg_match( '`(?:get_home_path|plugin_dir_path|get_(?:stylesheet|template)_directory|wp_upload_dir)\s*\(`i', $params[ 1 ][ 'raw' ] ) === 1 ) { |
|
| 242 | 242 | // Using any of the functions matched in the regex is an indicator of a local file. |
| 243 | 243 | return; |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | - if ( $this->is_local_data_stream( $params[1]['raw'] ) === true ) { |
|
| 246 | + if ( $this->is_local_data_stream( $params[ 1 ][ 'raw' ] ) === true ) { |
|
| 247 | 247 | // Local data stream. |
| 248 | 248 | return; |
| 249 | 249 | } |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | break; |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | - if ( $this->is_local_data_stream( $first_param['raw'] ) === true ) { |
|
| 268 | + if ( $this->is_local_data_stream( $first_param[ 'raw' ] ) === true ) { |
|
| 269 | 269 | // Local data stream. |
| 270 | 270 | return; |
| 271 | 271 | } |
@@ -279,12 +279,12 @@ discard block |
||
| 279 | 279 | return; |
| 280 | 280 | } |
| 281 | 281 | |
| 282 | - if ( ! isset( $this->groups[ $group_name ]['since'] ) ) { |
|
| 282 | + if ( ! isset( $this->groups[ $group_name ][ 'since' ] ) ) { |
|
| 283 | 283 | return parent::process_matched_token( $stackPtr, $group_name, $matched_content ); |
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | // Verify if the alternative is available in the minimum supported WP version. |
| 287 | - if ( version_compare( $this->groups[ $group_name ]['since'], $this->minimum_supported_version, '<=' ) ) { |
|
| 287 | + if ( version_compare( $this->groups[ $group_name ][ 'since' ], $this->minimum_supported_version, '<=' ) ) { |
|
| 288 | 288 | return parent::process_matched_token( $stackPtr, $group_name, $matched_content ); |
| 289 | 289 | } |
| 290 | 290 | } |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | * normal file processing. |
| 86 | 86 | */ |
| 87 | 87 | public function process_token( $stackPtr ) { |
| 88 | - if ( isset( $this->target_functions[ strtolower( $this->tokens[ $stackPtr ]['content'] ) ] ) ) { |
|
| 88 | + if ( isset( $this->target_functions[ strtolower( $this->tokens[ $stackPtr ][ 'content' ] ) ] ) ) { |
|
| 89 | 89 | // Disallow excluding function groups for this sniff. |
| 90 | 90 | $this->exclude = array(); |
| 91 | 91 | |
@@ -106,20 +106,20 @@ discard block |
||
| 106 | 106 | * @return void |
| 107 | 107 | */ |
| 108 | 108 | public function process_arbitrary_tstring( $stackPtr ) { |
| 109 | - $content = $this->tokens[ $stackPtr ]['content']; |
|
| 109 | + $content = $this->tokens[ $stackPtr ][ 'content' ]; |
|
| 110 | 110 | |
| 111 | 111 | if ( ! isset( $this->discouraged_constants[ $content ] ) ) { |
| 112 | 112 | return; |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | $next = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true ); |
| 116 | - if ( false !== $next && \T_OPEN_PARENTHESIS === $this->tokens[ $next ]['code'] ) { |
|
| 116 | + if ( false !== $next && \T_OPEN_PARENTHESIS === $this->tokens[ $next ][ 'code' ] ) { |
|
| 117 | 117 | // Function call or declaration. |
| 118 | 118 | return; |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | $prev = $this->phpcsFile->findPrevious( Tokens::$emptyTokens, ( $stackPtr - 1 ), null, true ); |
| 122 | - if ( false !== $prev && isset( $this->preceding_tokens_to_ignore[ $this->tokens[ $prev ]['code'] ] ) ) { |
|
| 122 | + if ( false !== $prev && isset( $this->preceding_tokens_to_ignore[ $this->tokens[ $prev ][ 'code' ] ] ) ) { |
|
| 123 | 123 | // Not the use of a constant. |
| 124 | 124 | return; |
| 125 | 125 | } |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | if ( false !== $prev |
| 133 | - && \T_CONST === $this->tokens[ $prev ]['code'] |
|
| 133 | + && \T_CONST === $this->tokens[ $prev ][ 'code' ] |
|
| 134 | 134 | && true === $this->is_class_constant( $prev ) |
| 135 | 135 | ) { |
| 136 | 136 | // Class constant of the same name. |
@@ -141,18 +141,18 @@ discard block |
||
| 141 | 141 | * Deal with a number of variations of use statements. |
| 142 | 142 | */ |
| 143 | 143 | for ( $i = $stackPtr; $i > 0; $i-- ) { |
| 144 | - if ( $this->tokens[ $i ]['line'] !== $this->tokens[ $stackPtr ]['line'] ) { |
|
| 144 | + if ( $this->tokens[ $i ][ 'line' ] !== $this->tokens[ $stackPtr ][ 'line' ] ) { |
|
| 145 | 145 | break; |
| 146 | 146 | } |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | $first_on_line = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $i + 1 ), null, true ); |
| 150 | - if ( false !== $first_on_line && \T_USE === $this->tokens[ $first_on_line ]['code'] ) { |
|
| 150 | + if ( false !== $first_on_line && \T_USE === $this->tokens[ $first_on_line ][ 'code' ] ) { |
|
| 151 | 151 | $next_on_line = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $first_on_line + 1 ), null, true ); |
| 152 | 152 | if ( false !== $next_on_line ) { |
| 153 | - if ( ( \T_STRING === $this->tokens[ $next_on_line ]['code'] |
|
| 154 | - && 'const' === $this->tokens[ $next_on_line ]['content'] ) |
|
| 155 | - || \T_CONST === $this->tokens[ $next_on_line ]['code'] // Happens in some PHPCS versions. |
|
| 153 | + if ( ( \T_STRING === $this->tokens[ $next_on_line ][ 'code' ] |
|
| 154 | + && 'const' === $this->tokens[ $next_on_line ][ 'content' ] ) |
|
| 155 | + || \T_CONST === $this->tokens[ $next_on_line ][ 'code' ] // Happens in some PHPCS versions. |
|
| 156 | 156 | ) { |
| 157 | 157 | $has_ns_sep = $this->phpcsFile->findNext( \T_NS_SEPARATOR, ( $next_on_line + 1 ), $stackPtr ); |
| 158 | 158 | if ( false !== $has_ns_sep ) { |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | return; |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | - $raw_content = $this->strip_quotes( $parameters[ $target_param ]['raw'] ); |
|
| 202 | + $raw_content = $this->strip_quotes( $parameters[ $target_param ][ 'raw' ] ); |
|
| 203 | 203 | |
| 204 | 204 | if ( isset( $this->discouraged_constants[ $raw_content ] ) ) { |
| 205 | 205 | $this->phpcsFile->addWarning( |
@@ -97,14 +97,14 @@ discard block |
||
| 97 | 97 | $token = $this->tokens[ $stackPtr ]; |
| 98 | 98 | |
| 99 | 99 | // Ignore variable overrides in test classes. |
| 100 | - if ( isset( Tokens::$ooScopeTokens[ $token['code'] ] ) ) { |
|
| 100 | + if ( isset( Tokens::$ooScopeTokens[ $token[ 'code' ] ] ) ) { |
|
| 101 | 101 | |
| 102 | 102 | if ( true === $this->is_test_class( $stackPtr ) |
| 103 | - && $token['scope_condition'] === $stackPtr |
|
| 104 | - && isset( $token['scope_closer'] ) |
|
| 103 | + && $token[ 'scope_condition' ] === $stackPtr |
|
| 104 | + && isset( $token[ 'scope_closer' ] ) |
|
| 105 | 105 | ) { |
| 106 | 106 | // Skip forward to end of test class. |
| 107 | - return $token['scope_closer']; |
|
| 107 | + return $token[ 'scope_closer' ]; |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | // Otherwise ignore the tokens as they were only registered to enable skipping over test classes. |
@@ -119,12 +119,12 @@ discard block |
||
| 119 | 119 | */ |
| 120 | 120 | $in_function_scope = $this->phpcsFile->hasCondition( $stackPtr, array( \T_FUNCTION, \T_CLOSURE ) ); |
| 121 | 121 | |
| 122 | - if ( \T_VARIABLE === $token['code'] |
|
| 123 | - && ( '$GLOBALS' === $token['content'] |
|
| 122 | + if ( \T_VARIABLE === $token[ 'code' ] |
|
| 123 | + && ( '$GLOBALS' === $token[ 'content' ] |
|
| 124 | 124 | || ( false === $in_function_scope && false === $this->treat_files_as_scoped ) ) |
| 125 | 125 | ) { |
| 126 | 126 | return $this->process_variable_assignment( $stackPtr ); |
| 127 | - } elseif ( \T_GLOBAL === $token['code'] |
|
| 127 | + } elseif ( \T_GLOBAL === $token[ 'code' ] |
|
| 128 | 128 | && ( true === $in_function_scope || true === $this->treat_files_as_scoped ) |
| 129 | 129 | ) { |
| 130 | 130 | return $this->process_global_statement( $stackPtr, $in_function_scope ); |
@@ -147,34 +147,34 @@ discard block |
||
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | $token = $this->tokens[ $stackPtr ]; |
| 150 | - $var_name = substr( $token['content'], 1 ); // Strip the dollar sign. |
|
| 150 | + $var_name = substr( $token[ 'content' ], 1 ); // Strip the dollar sign. |
|
| 151 | 151 | $data = array(); |
| 152 | 152 | |
| 153 | 153 | // Determine the variable name for `$GLOBALS['array_key']`. |
| 154 | 154 | if ( 'GLOBALS' === $var_name ) { |
| 155 | 155 | $bracketPtr = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true ); |
| 156 | 156 | |
| 157 | - if ( false === $bracketPtr || \T_OPEN_SQUARE_BRACKET !== $this->tokens[ $bracketPtr ]['code'] || ! isset( $this->tokens[ $bracketPtr ]['bracket_closer'] ) ) { |
|
| 157 | + if ( false === $bracketPtr || \T_OPEN_SQUARE_BRACKET !== $this->tokens[ $bracketPtr ][ 'code' ] || ! isset( $this->tokens[ $bracketPtr ][ 'bracket_closer' ] ) ) { |
|
| 158 | 158 | return; |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | // Retrieve the array key and avoid getting tripped up by some simple obfuscation. |
| 162 | 162 | $var_name = ''; |
| 163 | 163 | $start = ( $bracketPtr + 1 ); |
| 164 | - for ( $ptr = $start; $ptr < $this->tokens[ $bracketPtr ]['bracket_closer']; $ptr++ ) { |
|
| 164 | + for ( $ptr = $start; $ptr < $this->tokens[ $bracketPtr ][ 'bracket_closer' ]; $ptr++ ) { |
|
| 165 | 165 | /* |
| 166 | 166 | * If the globals array key contains a variable, constant, function call |
| 167 | 167 | * or interpolated variable, bow out. |
| 168 | 168 | */ |
| 169 | - if ( \T_VARIABLE === $this->tokens[ $ptr ]['code'] |
|
| 170 | - || \T_STRING === $this->tokens[ $ptr ]['code'] |
|
| 171 | - || \T_DOUBLE_QUOTED_STRING === $this->tokens[ $ptr ]['code'] |
|
| 169 | + if ( \T_VARIABLE === $this->tokens[ $ptr ][ 'code' ] |
|
| 170 | + || \T_STRING === $this->tokens[ $ptr ][ 'code' ] |
|
| 171 | + || \T_DOUBLE_QUOTED_STRING === $this->tokens[ $ptr ][ 'code' ] |
|
| 172 | 172 | ) { |
| 173 | 173 | return; |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - if ( \T_CONSTANT_ENCAPSED_STRING === $this->tokens[ $ptr ]['code'] ) { |
|
| 177 | - $var_name .= $this->strip_quotes( $this->tokens[ $ptr ]['content'] ); |
|
| 176 | + if ( \T_CONSTANT_ENCAPSED_STRING === $this->tokens[ $ptr ][ 'code' ] ) { |
|
| 177 | + $var_name .= $this->strip_quotes( $this->tokens[ $ptr ][ 'content' ] ); |
|
| 178 | 178 | } |
| 179 | 179 | } |
| 180 | 180 | |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | // Set up the data for the error message. |
| 187 | - $data[] = '$GLOBALS[\'' . $var_name . '\']'; |
|
| 187 | + $data[ ] = '$GLOBALS[\'' . $var_name . '\']'; |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | /* |
@@ -207,11 +207,11 @@ discard block |
||
| 207 | 207 | * Function parameters with the same name as a WP global variable are fine, |
| 208 | 208 | * including when they are being assigned a default value. |
| 209 | 209 | */ |
| 210 | - if ( isset( $this->tokens[ $stackPtr ]['nested_parenthesis'] ) ) { |
|
| 211 | - foreach ( $this->tokens[ $stackPtr ]['nested_parenthesis'] as $opener => $closer ) { |
|
| 212 | - if ( isset( $this->tokens[ $opener ]['parenthesis_owner'] ) |
|
| 213 | - && ( \T_FUNCTION === $this->tokens[ $this->tokens[ $opener ]['parenthesis_owner'] ]['code'] |
|
| 214 | - || \T_CLOSURE === $this->tokens[ $this->tokens[ $opener ]['parenthesis_owner'] ]['code'] ) |
|
| 210 | + if ( isset( $this->tokens[ $stackPtr ][ 'nested_parenthesis' ] ) ) { |
|
| 211 | + foreach ( $this->tokens[ $stackPtr ][ 'nested_parenthesis' ] as $opener => $closer ) { |
|
| 212 | + if ( isset( $this->tokens[ $opener ][ 'parenthesis_owner' ] ) |
|
| 213 | + && ( \T_FUNCTION === $this->tokens[ $this->tokens[ $opener ][ 'parenthesis_owner' ] ][ 'code' ] |
|
| 214 | + || \T_CLOSURE === $this->tokens[ $this->tokens[ $opener ][ 'parenthesis_owner' ] ][ 'code' ] ) |
|
| 215 | 215 | ) { |
| 216 | 216 | return; |
| 217 | 217 | } |
@@ -251,13 +251,13 @@ discard block |
||
| 251 | 251 | $var = $this->tokens[ $ptr ]; |
| 252 | 252 | |
| 253 | 253 | // Halt the loop at end of statement. |
| 254 | - if ( \T_SEMICOLON === $var['code'] ) { |
|
| 254 | + if ( \T_SEMICOLON === $var[ 'code' ] ) { |
|
| 255 | 255 | break; |
| 256 | 256 | } |
| 257 | 257 | |
| 258 | - if ( \T_VARIABLE === $var['code'] ) { |
|
| 259 | - if ( isset( $this->wp_globals[ substr( $var['content'], 1 ) ] ) ) { |
|
| 260 | - $search[] = $var['content']; |
|
| 258 | + if ( \T_VARIABLE === $var[ 'code' ] ) { |
|
| 259 | + if ( isset( $this->wp_globals[ substr( $var[ 'content' ], 1 ) ] ) ) { |
|
| 260 | + $search[ ] = $var[ 'content' ]; |
|
| 261 | 261 | } |
| 262 | 262 | } |
| 263 | 263 | |
@@ -277,11 +277,11 @@ discard block |
||
| 277 | 277 | $function_cond = $this->phpcsFile->getCondition( $stackPtr, \T_FUNCTION ); |
| 278 | 278 | $closure_cond = $this->phpcsFile->getCondition( $stackPtr, \T_CLOSURE ); |
| 279 | 279 | $scope_cond = max( $function_cond, $closure_cond ); // If false, it will evaluate as zero, so this is fine. |
| 280 | - if ( isset( $this->tokens[ $scope_cond ]['scope_closer'] ) === false ) { |
|
| 280 | + if ( isset( $this->tokens[ $scope_cond ][ 'scope_closer' ] ) === false ) { |
|
| 281 | 281 | // Live coding or parse error. |
| 282 | 282 | return; |
| 283 | 283 | } |
| 284 | - $end = $this->tokens[ $scope_cond ]['scope_closer']; |
|
| 284 | + $end = $this->tokens[ $scope_cond ][ 'scope_closer' ]; |
|
| 285 | 285 | } else { |
| 286 | 286 | // Global statement in the global namespace with file is being treated as scoped. |
| 287 | 287 | $end = ( $this->phpcsFile->numTokens + 1 ); |
@@ -290,21 +290,21 @@ discard block |
||
| 290 | 290 | for ( $ptr = $start; $ptr < $end; $ptr++ ) { |
| 291 | 291 | |
| 292 | 292 | // Skip over nested functions, classes and the likes. |
| 293 | - if ( isset( $this->skip_over[ $this->tokens[ $ptr ]['code'] ] ) ) { |
|
| 294 | - if ( ! isset( $this->tokens[ $ptr ]['scope_closer'] ) ) { |
|
| 293 | + if ( isset( $this->skip_over[ $this->tokens[ $ptr ][ 'code' ] ] ) ) { |
|
| 294 | + if ( ! isset( $this->tokens[ $ptr ][ 'scope_closer' ] ) ) { |
|
| 295 | 295 | // Live coding or parse error. |
| 296 | 296 | break; |
| 297 | 297 | } |
| 298 | 298 | |
| 299 | - $ptr = $this->tokens[ $ptr ]['scope_closer']; |
|
| 299 | + $ptr = $this->tokens[ $ptr ][ 'scope_closer' ]; |
|
| 300 | 300 | continue; |
| 301 | 301 | } |
| 302 | 302 | |
| 303 | - if ( \T_VARIABLE !== $this->tokens[ $ptr ]['code'] ) { |
|
| 303 | + if ( \T_VARIABLE !== $this->tokens[ $ptr ][ 'code' ] ) { |
|
| 304 | 304 | continue; |
| 305 | 305 | } |
| 306 | 306 | |
| 307 | - if ( \in_array( $this->tokens[ $ptr ]['content'], $search, true ) === false ) { |
|
| 307 | + if ( \in_array( $this->tokens[ $ptr ][ 'content' ], $search, true ) === false ) { |
|
| 308 | 308 | // Not one of the variables we're interested in. |
| 309 | 309 | continue; |
| 310 | 310 | } |
@@ -357,7 +357,7 @@ discard block |
||
| 357 | 357 | */ |
| 358 | 358 | protected function add_error( $stackPtr, $data = array() ) { |
| 359 | 359 | if ( empty( $data ) ) { |
| 360 | - $data[] = $this->tokens[ $stackPtr ]['content']; |
|
| 360 | + $data[ ] = $this->tokens[ $stackPtr ][ 'content' ]; |
|
| 361 | 361 | } |
| 362 | 362 | |
| 363 | 363 | $this->phpcsFile->addError( |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | } |
| 291 | 291 | |
| 292 | 292 | // The list will need to updated if the default value is not supported. |
| 293 | - switch ( $parameters[ $position ]['raw'] ) { |
|
| 293 | + switch ( $parameters[ $position ][ 'raw' ] ) { |
|
| 294 | 294 | case 'true': |
| 295 | 295 | $matched_parameter = true; |
| 296 | 296 | break; |
@@ -305,28 +305,28 @@ discard block |
||
| 305 | 305 | $matched_parameter = array(); |
| 306 | 306 | break; |
| 307 | 307 | default: |
| 308 | - $matched_parameter = $this->strip_quotes( $parameters[ $position ]['raw'] ); |
|
| 308 | + $matched_parameter = $this->strip_quotes( $parameters[ $position ][ 'raw' ] ); |
|
| 309 | 309 | break; |
| 310 | 310 | } |
| 311 | 311 | |
| 312 | - if ( $parameter_args['value'] === $matched_parameter ) { |
|
| 312 | + if ( $parameter_args[ 'value' ] === $matched_parameter ) { |
|
| 313 | 313 | continue; |
| 314 | 314 | } |
| 315 | 315 | |
| 316 | 316 | $message = 'The parameter "%s" at position #%s of %s() has been deprecated since WordPress version %s.'; |
| 317 | - $is_error = version_compare( $parameter_args['version'], $this->minimum_supported_version, '<' ); |
|
| 317 | + $is_error = version_compare( $parameter_args[ 'version' ], $this->minimum_supported_version, '<' ); |
|
| 318 | 318 | $code = $this->string_to_errorcode( ucfirst( $matched_content ) . 'Param' . $position . 'Found' ); |
| 319 | 319 | |
| 320 | 320 | $data = array( |
| 321 | - $parameters[ $position ]['raw'], |
|
| 321 | + $parameters[ $position ][ 'raw' ], |
|
| 322 | 322 | $position, |
| 323 | 323 | $matched_content, |
| 324 | - $parameter_args['version'], |
|
| 324 | + $parameter_args[ 'version' ], |
|
| 325 | 325 | ); |
| 326 | 326 | |
| 327 | - if ( isset( $parameter_args['value'] ) && $position < $paramCount ) { |
|
| 327 | + if ( isset( $parameter_args[ 'value' ] ) && $position < $paramCount ) { |
|
| 328 | 328 | $message .= ' Use "%s" instead.'; |
| 329 | - $data[] = (string) $parameter_args['value']; |
|
| 329 | + $data[ ] = (string)$parameter_args[ 'value' ]; |
|
| 330 | 330 | } else { |
| 331 | 331 | $message .= ' Instead do not pass the parameter.'; |
| 332 | 332 | } |