Completed
Pull Request — develop (#1492)
by Zack
28:58 queued 09:00
created
src/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php 1 patch
Spacing   +667 added lines, -667 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
      *
73 73
      * @var int[]
74 74
      */
75
-    public $ignoreIndentationTokens = [];
75
+    public $ignoreIndentationTokens = [ ];
76 76
 
77 77
     /**
78 78
      * List of tokens not needing to be checked for indentation.
@@ -82,14 +82,14 @@  discard block
 block discarded – undo
82 82
      *
83 83
      * @var int[]
84 84
      */
85
-    private $ignoreIndentation = [];
85
+    private $ignoreIndentation = [ ];
86 86
 
87 87
     /**
88 88
      * Any scope openers that should not cause an indent.
89 89
      *
90 90
      * @var int[]
91 91
      */
92
-    protected $nonIndentingScopes = [];
92
+    protected $nonIndentingScopes = [ ];
93 93
 
94 94
     /**
95 95
      * Show debug output for this sniff.
@@ -106,11 +106,11 @@  discard block
 block discarded – undo
106 106
      */
107 107
     public function register()
108 108
     {
109
-        if (defined('PHP_CODESNIFFER_IN_TESTS') === true) {
109
+        if ( defined( 'PHP_CODESNIFFER_IN_TESTS' ) === true ) {
110 110
             $this->debug = false;
111 111
         }
112 112
 
113
-        return [T_OPEN_TAG];
113
+        return [ T_OPEN_TAG ];
114 114
 
115 115
     }//end register()
116 116
 
@@ -124,15 +124,15 @@  discard block
 block discarded – undo
124 124
      *
125 125
      * @return void
126 126
      */
127
-    public function process(File $phpcsFile, $stackPtr)
127
+    public function process( File $phpcsFile, $stackPtr )
128 128
     {
129
-        $debug = Config::getConfigData('scope_indent_debug');
130
-        if ($debug !== null) {
131
-            $this->debug = (bool) $debug;
129
+        $debug = Config::getConfigData( 'scope_indent_debug' );
130
+        if ( $debug !== null ) {
131
+            $this->debug = (bool)$debug;
132 132
         }
133 133
 
134
-        if ($this->tabWidth === null) {
135
-            if (isset($phpcsFile->config->tabWidth) === false || $phpcsFile->config->tabWidth === 0) {
134
+        if ( $this->tabWidth === null ) {
135
+            if ( isset( $phpcsFile->config->tabWidth ) === false || $phpcsFile->config->tabWidth === 0 ) {
136 136
                 // We have no idea how wide tabs are, so assume 4 spaces for fixing.
137 137
                 // It shouldn't really matter because indent checks elsewhere in the
138 138
                 // standard should fix things up.
@@ -144,77 +144,77 @@  discard block
 block discarded – undo
144 144
 
145 145
         $lastOpenTag     = $stackPtr;
146 146
         $lastCloseTag    = null;
147
-        $openScopes      = [];
148
-        $adjustments     = [];
149
-        $setIndents      = [];
147
+        $openScopes      = [ ];
148
+        $adjustments     = [ ];
149
+        $setIndents      = [ ];
150 150
         $disableExactEnd = 0;
151 151
 
152 152
         $tokens  = $phpcsFile->getTokens();
153
-        $first   = $phpcsFile->findFirstOnLine(T_INLINE_HTML, $stackPtr);
154
-        $trimmed = ltrim($tokens[$first]['content']);
155
-        if ($trimmed === '') {
156
-            $currentIndent = ($tokens[$stackPtr]['column'] - 1);
153
+        $first   = $phpcsFile->findFirstOnLine( T_INLINE_HTML, $stackPtr );
154
+        $trimmed = ltrim( $tokens[ $first ][ 'content' ] );
155
+        if ( $trimmed === '' ) {
156
+            $currentIndent = ( $tokens[ $stackPtr ][ 'column' ] - 1 );
157 157
         } else {
158
-            $currentIndent = (strlen($tokens[$first]['content']) - strlen($trimmed));
158
+            $currentIndent = ( strlen( $tokens[ $first ][ 'content' ] ) - strlen( $trimmed ) );
159 159
         }
160 160
 
161
-        if ($this->debug === true) {
162
-            $line = $tokens[$stackPtr]['line'];
163
-            echo "Start with token $stackPtr on line $line with indent $currentIndent".PHP_EOL;
161
+        if ( $this->debug === true ) {
162
+            $line = $tokens[ $stackPtr ][ 'line' ];
163
+            echo "Start with token $stackPtr on line $line with indent $currentIndent" . PHP_EOL;
164 164
         }
165 165
 
166
-        if (empty($this->ignoreIndentation) === true) {
167
-            $this->ignoreIndentation = [T_INLINE_HTML => true];
168
-            foreach ($this->ignoreIndentationTokens as $token) {
169
-                if (is_int($token) === false) {
170
-                    if (defined($token) === false) {
166
+        if ( empty( $this->ignoreIndentation ) === true ) {
167
+            $this->ignoreIndentation = [ T_INLINE_HTML => true ];
168
+            foreach ( $this->ignoreIndentationTokens as $token ) {
169
+                if ( is_int( $token ) === false ) {
170
+                    if ( defined( $token ) === false ) {
171 171
                         continue;
172 172
                     }
173 173
 
174
-                    $token = constant($token);
174
+                    $token = constant( $token );
175 175
                 }
176 176
 
177
-                $this->ignoreIndentation[$token] = true;
177
+                $this->ignoreIndentation[ $token ] = true;
178 178
             }
179 179
         }//end if
180 180
 
181
-        $this->exact     = (bool) $this->exact;
182
-        $this->tabIndent = (bool) $this->tabIndent;
181
+        $this->exact     = (bool)$this->exact;
182
+        $this->tabIndent = (bool)$this->tabIndent;
183 183
 
184 184
         $checkAnnotations = $phpcsFile->config->annotations;
185 185
 
186
-        for ($i = ($stackPtr + 1); $i < $phpcsFile->numTokens; $i++) {
187
-            if ($i === false) {
186
+        for ( $i = ( $stackPtr + 1 ); $i < $phpcsFile->numTokens; $i++ ) {
187
+            if ( $i === false ) {
188 188
                 // Something has gone very wrong; maybe a parse error.
189 189
                 break;
190 190
             }
191 191
 
192
-            if ($checkAnnotations === true
193
-                && $tokens[$i]['code'] === T_PHPCS_SET
194
-                && isset($tokens[$i]['sniffCode']) === true
195
-                && $tokens[$i]['sniffCode'] === 'Generic.WhiteSpace.ScopeIndent'
196
-                && $tokens[$i]['sniffProperty'] === 'exact'
192
+            if ( $checkAnnotations === true
193
+                && $tokens[ $i ][ 'code' ] === T_PHPCS_SET
194
+                && isset( $tokens[ $i ][ 'sniffCode' ] ) === true
195
+                && $tokens[ $i ][ 'sniffCode' ] === 'Generic.WhiteSpace.ScopeIndent'
196
+                && $tokens[ $i ][ 'sniffProperty' ] === 'exact'
197 197
             ) {
198
-                $value = $tokens[$i]['sniffPropertyValue'];
199
-                if ($value === 'true') {
198
+                $value = $tokens[ $i ][ 'sniffPropertyValue' ];
199
+                if ( $value === 'true' ) {
200 200
                     $value = true;
201
-                } else if ($value === 'false') {
201
+                } else if ( $value === 'false' ) {
202 202
                     $value = false;
203 203
                 } else {
204
-                    $value = (bool) $value;
204
+                    $value = (bool)$value;
205 205
                 }
206 206
 
207 207
                 $this->exact = $value;
208 208
 
209
-                if ($this->debug === true) {
210
-                    $line = $tokens[$i]['line'];
211
-                    if ($this->exact === true) {
209
+                if ( $this->debug === true ) {
210
+                    $line = $tokens[ $i ][ 'line' ];
211
+                    if ( $this->exact === true ) {
212 212
                         $value = 'true';
213 213
                     } else {
214 214
                         $value = 'false';
215 215
                     }
216 216
 
217
-                    echo "* token $i on line $line set exact flag to $value *".PHP_EOL;
217
+                    echo "* token $i on line $line set exact flag to $value *" . PHP_EOL;
218 218
                 }
219 219
             }//end if
220 220
 
@@ -229,96 +229,96 @@  discard block
 block discarded – undo
229 229
 
230 230
             $exact = $this->exact;
231 231
 
232
-            if ($tokens[$i]['code'] === T_OPEN_SHORT_ARRAY) {
233
-                $disableExactEnd = max($disableExactEnd, $tokens[$i]['bracket_closer']);
232
+            if ( $tokens[ $i ][ 'code' ] === T_OPEN_SHORT_ARRAY ) {
233
+                $disableExactEnd = max( $disableExactEnd, $tokens[ $i ][ 'bracket_closer' ] );
234 234
             }
235 235
 
236
-            if ($tokens[$i]['code'] === T_OPEN_PARENTHESIS
237
-                && isset($tokens[$i]['parenthesis_closer']) === true
236
+            if ( $tokens[ $i ][ 'code' ] === T_OPEN_PARENTHESIS
237
+                && isset( $tokens[ $i ][ 'parenthesis_closer' ] ) === true
238 238
             ) {
239
-                $disableExactEnd = max($disableExactEnd, $tokens[$i]['parenthesis_closer']);
239
+                $disableExactEnd = max( $disableExactEnd, $tokens[ $i ][ 'parenthesis_closer' ] );
240 240
             }
241 241
 
242
-            if ($exact === true && $i < $disableExactEnd) {
242
+            if ( $exact === true && $i < $disableExactEnd ) {
243 243
                 $exact = false;
244 244
             }
245 245
 
246 246
             // Detect line changes and figure out where the indent is.
247
-            if ($tokens[$i]['column'] === 1) {
248
-                $trimmed = ltrim($tokens[$i]['content']);
249
-                if ($trimmed === '') {
250
-                    if (isset($tokens[($i + 1)]) === true
251
-                        && $tokens[$i]['line'] === $tokens[($i + 1)]['line']
247
+            if ( $tokens[ $i ][ 'column' ] === 1 ) {
248
+                $trimmed = ltrim( $tokens[ $i ][ 'content' ] );
249
+                if ( $trimmed === '' ) {
250
+                    if ( isset( $tokens[ ( $i + 1 ) ] ) === true
251
+                        && $tokens[ $i ][ 'line' ] === $tokens[ ( $i + 1 ) ][ 'line' ]
252 252
                     ) {
253
-                        $checkToken  = ($i + 1);
254
-                        $tokenIndent = ($tokens[($i + 1)]['column'] - 1);
253
+                        $checkToken  = ( $i + 1 );
254
+                        $tokenIndent = ( $tokens[ ( $i + 1 ) ][ 'column' ] - 1 );
255 255
                     }
256 256
                 } else {
257 257
                     $checkToken  = $i;
258
-                    $tokenIndent = (strlen($tokens[$i]['content']) - strlen($trimmed));
258
+                    $tokenIndent = ( strlen( $tokens[ $i ][ 'content' ] ) - strlen( $trimmed ) );
259 259
                 }
260 260
             }
261 261
 
262 262
             // Closing parenthesis should just be indented to at least
263 263
             // the same level as where they were opened (but can be more).
264
-            if (($checkToken !== null
265
-                && $tokens[$checkToken]['code'] === T_CLOSE_PARENTHESIS
266
-                && isset($tokens[$checkToken]['parenthesis_opener']) === true)
267
-                || ($tokens[$i]['code'] === T_CLOSE_PARENTHESIS
268
-                && isset($tokens[$i]['parenthesis_opener']) === true)
264
+            if ( ( $checkToken !== null
265
+                && $tokens[ $checkToken ][ 'code' ] === T_CLOSE_PARENTHESIS
266
+                && isset( $tokens[ $checkToken ][ 'parenthesis_opener' ] ) === true )
267
+                || ( $tokens[ $i ][ 'code' ] === T_CLOSE_PARENTHESIS
268
+                && isset( $tokens[ $i ][ 'parenthesis_opener' ] ) === true )
269 269
             ) {
270
-                if ($checkToken !== null) {
270
+                if ( $checkToken !== null ) {
271 271
                     $parenCloser = $checkToken;
272 272
                 } else {
273 273
                     $parenCloser = $i;
274 274
                 }
275 275
 
276
-                if ($this->debug === true) {
277
-                    $line = $tokens[$i]['line'];
278
-                    echo "Closing parenthesis found on line $line".PHP_EOL;
276
+                if ( $this->debug === true ) {
277
+                    $line = $tokens[ $i ][ 'line' ];
278
+                    echo "Closing parenthesis found on line $line" . PHP_EOL;
279 279
                 }
280 280
 
281
-                $parenOpener = $tokens[$parenCloser]['parenthesis_opener'];
282
-                if ($tokens[$parenCloser]['line'] !== $tokens[$parenOpener]['line']) {
281
+                $parenOpener = $tokens[ $parenCloser ][ 'parenthesis_opener' ];
282
+                if ( $tokens[ $parenCloser ][ 'line' ] !== $tokens[ $parenOpener ][ 'line' ] ) {
283 283
                     $parens = 0;
284
-                    if (isset($tokens[$parenCloser]['nested_parenthesis']) === true
285
-                        && empty($tokens[$parenCloser]['nested_parenthesis']) === false
284
+                    if ( isset( $tokens[ $parenCloser ][ 'nested_parenthesis' ] ) === true
285
+                        && empty( $tokens[ $parenCloser ][ 'nested_parenthesis' ] ) === false
286 286
                     ) {
287
-                        $parens = $tokens[$parenCloser]['nested_parenthesis'];
288
-                        end($parens);
289
-                        $parens = key($parens);
290
-                        if ($this->debug === true) {
291
-                            $line = $tokens[$parens]['line'];
292
-                            echo "\t* token has nested parenthesis $parens on line $line *".PHP_EOL;
287
+                        $parens = $tokens[ $parenCloser ][ 'nested_parenthesis' ];
288
+                        end( $parens );
289
+                        $parens = key( $parens );
290
+                        if ( $this->debug === true ) {
291
+                            $line = $tokens[ $parens ][ 'line' ];
292
+                            echo "\t* token has nested parenthesis $parens on line $line *" . PHP_EOL;
293 293
                         }
294 294
                     }
295 295
 
296 296
                     $condition = 0;
297
-                    if (isset($tokens[$parenCloser]['conditions']) === true
298
-                        && empty($tokens[$parenCloser]['conditions']) === false
299
-                        && (isset($tokens[$parenCloser]['parenthesis_owner']) === false
300
-                        || $parens > 0)
297
+                    if ( isset( $tokens[ $parenCloser ][ 'conditions' ] ) === true
298
+                        && empty( $tokens[ $parenCloser ][ 'conditions' ] ) === false
299
+                        && ( isset( $tokens[ $parenCloser ][ 'parenthesis_owner' ] ) === false
300
+                        || $parens > 0 )
301 301
                     ) {
302
-                        $condition = $tokens[$parenCloser]['conditions'];
303
-                        end($condition);
304
-                        $condition = key($condition);
305
-                        if ($this->debug === true) {
306
-                            $line = $tokens[$condition]['line'];
307
-                            $type = $tokens[$condition]['type'];
308
-                            echo "\t* token is inside condition $condition ($type) on line $line *".PHP_EOL;
302
+                        $condition = $tokens[ $parenCloser ][ 'conditions' ];
303
+                        end( $condition );
304
+                        $condition = key( $condition );
305
+                        if ( $this->debug === true ) {
306
+                            $line = $tokens[ $condition ][ 'line' ];
307
+                            $type = $tokens[ $condition ][ 'type' ];
308
+                            echo "\t* token is inside condition $condition ($type) on line $line *" . PHP_EOL;
309 309
                         }
310 310
                     }
311 311
 
312
-                    if ($parens > $condition) {
313
-                        if ($this->debug === true) {
314
-                            echo "\t* using parenthesis *".PHP_EOL;
312
+                    if ( $parens > $condition ) {
313
+                        if ( $this->debug === true ) {
314
+                            echo "\t* using parenthesis *" . PHP_EOL;
315 315
                         }
316 316
 
317 317
                         $parenOpener = $parens;
318 318
                         $condition   = 0;
319
-                    } else if ($condition > 0) {
320
-                        if ($this->debug === true) {
321
-                            echo "\t* using condition *".PHP_EOL;
319
+                    } else if ( $condition > 0 ) {
320
+                        if ( $this->debug === true ) {
321
+                            echo "\t* using condition *" . PHP_EOL;
322 322
                         }
323 323
 
324 324
                         $parenOpener = $condition;
@@ -327,356 +327,356 @@  discard block
 block discarded – undo
327 327
 
328 328
                     $exact = false;
329 329
 
330
-                    $lastOpenTagConditions = array_keys($tokens[$lastOpenTag]['conditions']);
331
-                    $lastOpenTagCondition  = array_pop($lastOpenTagConditions);
330
+                    $lastOpenTagConditions = array_keys( $tokens[ $lastOpenTag ][ 'conditions' ] );
331
+                    $lastOpenTagCondition  = array_pop( $lastOpenTagConditions );
332 332
 
333
-                    if ($condition > 0 && $lastOpenTagCondition === $condition) {
334
-                        if ($this->debug === true) {
335
-                            echo "\t* open tag is inside condition; using open tag *".PHP_EOL;
333
+                    if ( $condition > 0 && $lastOpenTagCondition === $condition ) {
334
+                        if ( $this->debug === true ) {
335
+                            echo "\t* open tag is inside condition; using open tag *" . PHP_EOL;
336 336
                         }
337 337
 
338
-                        $checkIndent = ($tokens[$lastOpenTag]['column'] - 1);
339
-                        if (isset($adjustments[$condition]) === true) {
340
-                            $checkIndent += $adjustments[$condition];
338
+                        $checkIndent = ( $tokens[ $lastOpenTag ][ 'column' ] - 1 );
339
+                        if ( isset( $adjustments[ $condition ] ) === true ) {
340
+                            $checkIndent += $adjustments[ $condition ];
341 341
                         }
342 342
 
343 343
                         $currentIndent = $checkIndent;
344 344
 
345
-                        if ($this->debug === true) {
346
-                            $type = $tokens[$lastOpenTag]['type'];
347
-                            echo "\t=> checking indent of $checkIndent; main indent set to $currentIndent by token $lastOpenTag ($type)".PHP_EOL;
345
+                        if ( $this->debug === true ) {
346
+                            $type = $tokens[ $lastOpenTag ][ 'type' ];
347
+                            echo "\t=> checking indent of $checkIndent; main indent set to $currentIndent by token $lastOpenTag ($type)" . PHP_EOL;
348 348
                         }
349
-                    } else if ($condition > 0
350
-                        && isset($tokens[$condition]['scope_opener']) === true
351
-                        && isset($setIndents[$tokens[$condition]['scope_opener']]) === true
349
+                    } else if ( $condition > 0
350
+                        && isset( $tokens[ $condition ][ 'scope_opener' ] ) === true
351
+                        && isset( $setIndents[ $tokens[ $condition ][ 'scope_opener' ] ] ) === true
352 352
                     ) {
353
-                        $checkIndent = $setIndents[$tokens[$condition]['scope_opener']];
354
-                        if (isset($adjustments[$condition]) === true) {
355
-                            $checkIndent += $adjustments[$condition];
353
+                        $checkIndent = $setIndents[ $tokens[ $condition ][ 'scope_opener' ] ];
354
+                        if ( isset( $adjustments[ $condition ] ) === true ) {
355
+                            $checkIndent += $adjustments[ $condition ];
356 356
                         }
357 357
 
358 358
                         $currentIndent = $checkIndent;
359 359
 
360
-                        if ($this->debug === true) {
361
-                            $type = $tokens[$condition]['type'];
362
-                            echo "\t=> checking indent of $checkIndent; main indent set to $currentIndent by token $condition ($type)".PHP_EOL;
360
+                        if ( $this->debug === true ) {
361
+                            $type = $tokens[ $condition ][ 'type' ];
362
+                            echo "\t=> checking indent of $checkIndent; main indent set to $currentIndent by token $condition ($type)" . PHP_EOL;
363 363
                         }
364 364
                     } else {
365
-                        $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $parenOpener, true);
365
+                        $first = $phpcsFile->findFirstOnLine( T_WHITESPACE, $parenOpener, true );
366 366
 
367
-                        $checkIndent = ($tokens[$first]['column'] - 1);
368
-                        if (isset($adjustments[$first]) === true) {
369
-                            $checkIndent += $adjustments[$first];
367
+                        $checkIndent = ( $tokens[ $first ][ 'column' ] - 1 );
368
+                        if ( isset( $adjustments[ $first ] ) === true ) {
369
+                            $checkIndent += $adjustments[ $first ];
370 370
                         }
371 371
 
372
-                        if ($this->debug === true) {
373
-                            $line = $tokens[$first]['line'];
374
-                            $type = $tokens[$first]['type'];
375
-                            echo "\t* first token on line $line is $first ($type) *".PHP_EOL;
372
+                        if ( $this->debug === true ) {
373
+                            $line = $tokens[ $first ][ 'line' ];
374
+                            $type = $tokens[ $first ][ 'type' ];
375
+                            echo "\t* first token on line $line is $first ($type) *" . PHP_EOL;
376 376
                         }
377 377
 
378
-                        if ($first === $tokens[$parenCloser]['parenthesis_opener']
379
-                            && $tokens[($first - 1)]['line'] === $tokens[$first]['line']
378
+                        if ( $first === $tokens[ $parenCloser ][ 'parenthesis_opener' ]
379
+                            && $tokens[ ( $first - 1 ) ][ 'line' ] === $tokens[ $first ][ 'line' ]
380 380
                         ) {
381 381
                             // This is unlikely to be the start of the statement, so look
382 382
                             // back further to find it.
383 383
                             $first--;
384
-                            if ($this->debug === true) {
385
-                                $line = $tokens[$first]['line'];
386
-                                $type = $tokens[$first]['type'];
387
-                                echo "\t* first token is the parenthesis opener *".PHP_EOL;
388
-                                echo "\t* amended first token is $first ($type) on line $line *".PHP_EOL;
384
+                            if ( $this->debug === true ) {
385
+                                $line = $tokens[ $first ][ 'line' ];
386
+                                $type = $tokens[ $first ][ 'type' ];
387
+                                echo "\t* first token is the parenthesis opener *" . PHP_EOL;
388
+                                echo "\t* amended first token is $first ($type) on line $line *" . PHP_EOL;
389 389
                             }
390 390
                         }
391 391
 
392
-                        $prev = $phpcsFile->findStartOfStatement($first, T_COMMA);
393
-                        if ($prev !== $first) {
392
+                        $prev = $phpcsFile->findStartOfStatement( $first, T_COMMA );
393
+                        if ( $prev !== $first ) {
394 394
                             // This is not the start of the statement.
395
-                            if ($this->debug === true) {
396
-                                $line = $tokens[$prev]['line'];
397
-                                $type = $tokens[$prev]['type'];
398
-                                echo "\t* previous is $type on line $line *".PHP_EOL;
395
+                            if ( $this->debug === true ) {
396
+                                $line = $tokens[ $prev ][ 'line' ];
397
+                                $type = $tokens[ $prev ][ 'type' ];
398
+                                echo "\t* previous is $type on line $line *" . PHP_EOL;
399 399
                             }
400 400
 
401
-                            $first = $phpcsFile->findFirstOnLine([T_WHITESPACE, T_INLINE_HTML], $prev, true);
402
-                            if ($first !== false) {
403
-                                $prev  = $phpcsFile->findStartOfStatement($first, T_COMMA);
404
-                                $first = $phpcsFile->findFirstOnLine([T_WHITESPACE, T_INLINE_HTML], $prev, true);
401
+                            $first = $phpcsFile->findFirstOnLine( [ T_WHITESPACE, T_INLINE_HTML ], $prev, true );
402
+                            if ( $first !== false ) {
403
+                                $prev  = $phpcsFile->findStartOfStatement( $first, T_COMMA );
404
+                                $first = $phpcsFile->findFirstOnLine( [ T_WHITESPACE, T_INLINE_HTML ], $prev, true );
405 405
                             } else {
406 406
                                 $first = $prev;
407 407
                             }
408 408
 
409
-                            if ($this->debug === true) {
410
-                                $line = $tokens[$first]['line'];
411
-                                $type = $tokens[$first]['type'];
412
-                                echo "\t* amended first token is $first ($type) on line $line *".PHP_EOL;
409
+                            if ( $this->debug === true ) {
410
+                                $line = $tokens[ $first ][ 'line' ];
411
+                                $type = $tokens[ $first ][ 'type' ];
412
+                                echo "\t* amended first token is $first ($type) on line $line *" . PHP_EOL;
413 413
                             }
414 414
                         }//end if
415 415
 
416
-                        if (isset($tokens[$first]['scope_closer']) === true
417
-                            && $tokens[$first]['scope_closer'] === $first
416
+                        if ( isset( $tokens[ $first ][ 'scope_closer' ] ) === true
417
+                            && $tokens[ $first ][ 'scope_closer' ] === $first
418 418
                         ) {
419
-                            if ($this->debug === true) {
420
-                                echo "\t* first token is a scope closer *".PHP_EOL;
419
+                            if ( $this->debug === true ) {
420
+                                echo "\t* first token is a scope closer *" . PHP_EOL;
421 421
                             }
422 422
 
423
-                            if (isset($tokens[$first]['scope_condition']) === true) {
423
+                            if ( isset( $tokens[ $first ][ 'scope_condition' ] ) === true ) {
424 424
                                 $scopeCloser = $first;
425
-                                $first       = $phpcsFile->findFirstOnLine(T_WHITESPACE, $tokens[$scopeCloser]['scope_condition'], true);
425
+                                $first       = $phpcsFile->findFirstOnLine( T_WHITESPACE, $tokens[ $scopeCloser ][ 'scope_condition' ], true );
426 426
 
427
-                                $currentIndent = ($tokens[$first]['column'] - 1);
428
-                                if (isset($adjustments[$first]) === true) {
429
-                                    $currentIndent += $adjustments[$first];
427
+                                $currentIndent = ( $tokens[ $first ][ 'column' ] - 1 );
428
+                                if ( isset( $adjustments[ $first ] ) === true ) {
429
+                                    $currentIndent += $adjustments[ $first ];
430 430
                                 }
431 431
 
432 432
                                 // Make sure it is divisible by our expected indent.
433
-                                if ($tokens[$tokens[$scopeCloser]['scope_condition']]['code'] !== T_CLOSURE) {
434
-                                    $currentIndent = (int) (ceil($currentIndent / $this->indent) * $this->indent);
433
+                                if ( $tokens[ $tokens[ $scopeCloser ][ 'scope_condition' ] ][ 'code' ] !== T_CLOSURE ) {
434
+                                    $currentIndent = (int)( ceil( $currentIndent / $this->indent ) * $this->indent );
435 435
                                 }
436 436
 
437
-                                $setIndents[$first] = $currentIndent;
437
+                                $setIndents[ $first ] = $currentIndent;
438 438
 
439
-                                if ($this->debug === true) {
440
-                                    $type = $tokens[$first]['type'];
441
-                                    echo "\t=> indent set to $currentIndent by token $first ($type)".PHP_EOL;
439
+                                if ( $this->debug === true ) {
440
+                                    $type = $tokens[ $first ][ 'type' ];
441
+                                    echo "\t=> indent set to $currentIndent by token $first ($type)" . PHP_EOL;
442 442
                                 }
443 443
                             }//end if
444 444
                         } else {
445 445
                             // Don't force current indent to be divisible because there could be custom
446 446
                             // rules in place between parenthesis, such as with arrays.
447
-                            $currentIndent = ($tokens[$first]['column'] - 1);
448
-                            if (isset($adjustments[$first]) === true) {
449
-                                $currentIndent += $adjustments[$first];
447
+                            $currentIndent = ( $tokens[ $first ][ 'column' ] - 1 );
448
+                            if ( isset( $adjustments[ $first ] ) === true ) {
449
+                                $currentIndent += $adjustments[ $first ];
450 450
                             }
451 451
 
452
-                            $setIndents[$first] = $currentIndent;
452
+                            $setIndents[ $first ] = $currentIndent;
453 453
 
454
-                            if ($this->debug === true) {
455
-                                $type = $tokens[$first]['type'];
456
-                                echo "\t=> checking indent of $checkIndent; main indent set to $currentIndent by token $first ($type)".PHP_EOL;
454
+                            if ( $this->debug === true ) {
455
+                                $type = $tokens[ $first ][ 'type' ];
456
+                                echo "\t=> checking indent of $checkIndent; main indent set to $currentIndent by token $first ($type)" . PHP_EOL;
457 457
                             }
458 458
                         }//end if
459 459
                     }//end if
460
-                } else if ($this->debug === true) {
461
-                    echo "\t * ignoring single-line definition *".PHP_EOL;
460
+                } else if ( $this->debug === true ) {
461
+                    echo "\t * ignoring single-line definition *" . PHP_EOL;
462 462
                 }//end if
463 463
             }//end if
464 464
 
465 465
             // Closing short array bracket should just be indented to at least
466 466
             // the same level as where it was opened (but can be more).
467
-            if ($tokens[$i]['code'] === T_CLOSE_SHORT_ARRAY
468
-                || ($checkToken !== null
469
-                && $tokens[$checkToken]['code'] === T_CLOSE_SHORT_ARRAY)
467
+            if ( $tokens[ $i ][ 'code' ] === T_CLOSE_SHORT_ARRAY
468
+                || ( $checkToken !== null
469
+                && $tokens[ $checkToken ][ 'code' ] === T_CLOSE_SHORT_ARRAY )
470 470
             ) {
471
-                if ($checkToken !== null) {
471
+                if ( $checkToken !== null ) {
472 472
                     $arrayCloser = $checkToken;
473 473
                 } else {
474 474
                     $arrayCloser = $i;
475 475
                 }
476 476
 
477
-                if ($this->debug === true) {
478
-                    $line = $tokens[$arrayCloser]['line'];
479
-                    echo "Closing short array bracket found on line $line".PHP_EOL;
477
+                if ( $this->debug === true ) {
478
+                    $line = $tokens[ $arrayCloser ][ 'line' ];
479
+                    echo "Closing short array bracket found on line $line" . PHP_EOL;
480 480
                 }
481 481
 
482
-                $arrayOpener = $tokens[$arrayCloser]['bracket_opener'];
483
-                if ($tokens[$arrayCloser]['line'] !== $tokens[$arrayOpener]['line']) {
484
-                    $first       = $phpcsFile->findFirstOnLine(T_WHITESPACE, $arrayOpener, true);
485
-                    $checkIndent = ($tokens[$first]['column'] - 1);
486
-                    if (isset($adjustments[$first]) === true) {
487
-                        $checkIndent += $adjustments[$first];
482
+                $arrayOpener = $tokens[ $arrayCloser ][ 'bracket_opener' ];
483
+                if ( $tokens[ $arrayCloser ][ 'line' ] !== $tokens[ $arrayOpener ][ 'line' ] ) {
484
+                    $first       = $phpcsFile->findFirstOnLine( T_WHITESPACE, $arrayOpener, true );
485
+                    $checkIndent = ( $tokens[ $first ][ 'column' ] - 1 );
486
+                    if ( isset( $adjustments[ $first ] ) === true ) {
487
+                        $checkIndent += $adjustments[ $first ];
488 488
                     }
489 489
 
490 490
                     $exact = false;
491 491
 
492
-                    if ($this->debug === true) {
493
-                        $line = $tokens[$first]['line'];
494
-                        $type = $tokens[$first]['type'];
495
-                        echo "\t* first token on line $line is $first ($type) *".PHP_EOL;
492
+                    if ( $this->debug === true ) {
493
+                        $line = $tokens[ $first ][ 'line' ];
494
+                        $type = $tokens[ $first ][ 'type' ];
495
+                        echo "\t* first token on line $line is $first ($type) *" . PHP_EOL;
496 496
                     }
497 497
 
498
-                    if ($first === $tokens[$arrayCloser]['bracket_opener']) {
498
+                    if ( $first === $tokens[ $arrayCloser ][ 'bracket_opener' ] ) {
499 499
                         // This is unlikely to be the start of the statement, so look
500 500
                         // back further to find it.
501 501
                         $first--;
502 502
                     }
503 503
 
504
-                    $prev = $phpcsFile->findStartOfStatement($first, [T_COMMA, T_DOUBLE_ARROW]);
505
-                    if ($prev !== $first) {
504
+                    $prev = $phpcsFile->findStartOfStatement( $first, [ T_COMMA, T_DOUBLE_ARROW ] );
505
+                    if ( $prev !== $first ) {
506 506
                         // This is not the start of the statement.
507
-                        if ($this->debug === true) {
508
-                            $line = $tokens[$prev]['line'];
509
-                            $type = $tokens[$prev]['type'];
510
-                            echo "\t* previous is $type on line $line *".PHP_EOL;
507
+                        if ( $this->debug === true ) {
508
+                            $line = $tokens[ $prev ][ 'line' ];
509
+                            $type = $tokens[ $prev ][ 'type' ];
510
+                            echo "\t* previous is $type on line $line *" . PHP_EOL;
511 511
                         }
512 512
 
513
-                        $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $prev, true);
514
-                        $prev  = $phpcsFile->findStartOfStatement($first, [T_COMMA, T_DOUBLE_ARROW]);
515
-                        $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $prev, true);
516
-                        if ($this->debug === true) {
517
-                            $line = $tokens[$first]['line'];
518
-                            $type = $tokens[$first]['type'];
519
-                            echo "\t* amended first token is $first ($type) on line $line *".PHP_EOL;
513
+                        $first = $phpcsFile->findFirstOnLine( T_WHITESPACE, $prev, true );
514
+                        $prev  = $phpcsFile->findStartOfStatement( $first, [ T_COMMA, T_DOUBLE_ARROW ] );
515
+                        $first = $phpcsFile->findFirstOnLine( T_WHITESPACE, $prev, true );
516
+                        if ( $this->debug === true ) {
517
+                            $line = $tokens[ $first ][ 'line' ];
518
+                            $type = $tokens[ $first ][ 'type' ];
519
+                            echo "\t* amended first token is $first ($type) on line $line *" . PHP_EOL;
520 520
                         }
521
-                    } else if ($tokens[$first]['code'] === T_WHITESPACE) {
522
-                        $first = $phpcsFile->findNext(T_WHITESPACE, ($first + 1), null, true);
521
+                    } else if ( $tokens[ $first ][ 'code' ] === T_WHITESPACE ) {
522
+                        $first = $phpcsFile->findNext( T_WHITESPACE, ( $first + 1 ), null, true );
523 523
                     }
524 524
 
525
-                    if (isset($tokens[$first]['scope_closer']) === true
526
-                        && $tokens[$first]['scope_closer'] === $first
525
+                    if ( isset( $tokens[ $first ][ 'scope_closer' ] ) === true
526
+                        && $tokens[ $first ][ 'scope_closer' ] === $first
527 527
                     ) {
528 528
                         // The first token is a scope closer and would have already
529 529
                         // been processed and set the indent level correctly, so
530 530
                         // don't adjust it again.
531
-                        if ($this->debug === true) {
532
-                            echo "\t* first token is a scope closer; ignoring closing short array bracket *".PHP_EOL;
531
+                        if ( $this->debug === true ) {
532
+                            echo "\t* first token is a scope closer; ignoring closing short array bracket *" . PHP_EOL;
533 533
                         }
534 534
 
535
-                        if (isset($setIndents[$first]) === true) {
536
-                            $currentIndent = $setIndents[$first];
537
-                            if ($this->debug === true) {
538
-                                echo "\t=> indent reset to $currentIndent".PHP_EOL;
535
+                        if ( isset( $setIndents[ $first ] ) === true ) {
536
+                            $currentIndent = $setIndents[ $first ];
537
+                            if ( $this->debug === true ) {
538
+                                echo "\t=> indent reset to $currentIndent" . PHP_EOL;
539 539
                             }
540 540
                         }
541 541
                     } else {
542 542
                         // Don't force current indent to be divisible because there could be custom
543 543
                         // rules in place for arrays.
544
-                        $currentIndent = ($tokens[$first]['column'] - 1);
545
-                        if (isset($adjustments[$first]) === true) {
546
-                            $currentIndent += $adjustments[$first];
544
+                        $currentIndent = ( $tokens[ $first ][ 'column' ] - 1 );
545
+                        if ( isset( $adjustments[ $first ] ) === true ) {
546
+                            $currentIndent += $adjustments[ $first ];
547 547
                         }
548 548
 
549
-                        $setIndents[$first] = $currentIndent;
549
+                        $setIndents[ $first ] = $currentIndent;
550 550
 
551
-                        if ($this->debug === true) {
552
-                            $type = $tokens[$first]['type'];
553
-                            echo "\t=> checking indent of $checkIndent; main indent set to $currentIndent by token $first ($type)".PHP_EOL;
551
+                        if ( $this->debug === true ) {
552
+                            $type = $tokens[ $first ][ 'type' ];
553
+                            echo "\t=> checking indent of $checkIndent; main indent set to $currentIndent by token $first ($type)" . PHP_EOL;
554 554
                         }
555 555
                     }//end if
556
-                } else if ($this->debug === true) {
557
-                    echo "\t * ignoring single-line definition *".PHP_EOL;
556
+                } else if ( $this->debug === true ) {
557
+                    echo "\t * ignoring single-line definition *" . PHP_EOL;
558 558
                 }//end if
559 559
             }//end if
560 560
 
561 561
             // Adjust lines within scopes while auto-fixing.
562
-            if ($checkToken !== null
562
+            if ( $checkToken !== null
563 563
                 && $exact === false
564
-                && (empty($tokens[$checkToken]['conditions']) === false
565
-                || (isset($tokens[$checkToken]['scope_opener']) === true
566
-                && $tokens[$checkToken]['scope_opener'] === $checkToken))
564
+                && ( empty( $tokens[ $checkToken ][ 'conditions' ] ) === false
565
+                || ( isset( $tokens[ $checkToken ][ 'scope_opener' ] ) === true
566
+                && $tokens[ $checkToken ][ 'scope_opener' ] === $checkToken ) )
567 567
             ) {
568
-                if (empty($tokens[$checkToken]['conditions']) === false) {
569
-                    $condition = $tokens[$checkToken]['conditions'];
570
-                    end($condition);
571
-                    $condition = key($condition);
568
+                if ( empty( $tokens[ $checkToken ][ 'conditions' ] ) === false ) {
569
+                    $condition = $tokens[ $checkToken ][ 'conditions' ];
570
+                    end( $condition );
571
+                    $condition = key( $condition );
572 572
                 } else {
573
-                    $condition = $tokens[$checkToken]['scope_condition'];
573
+                    $condition = $tokens[ $checkToken ][ 'scope_condition' ];
574 574
                 }
575 575
 
576
-                $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $condition, true);
576
+                $first = $phpcsFile->findFirstOnLine( T_WHITESPACE, $condition, true );
577 577
 
578
-                if (isset($adjustments[$first]) === true
579
-                    && (($adjustments[$first] < 0 && $tokenIndent > $currentIndent)
580
-                    || ($adjustments[$first] > 0 && $tokenIndent < $currentIndent))
578
+                if ( isset( $adjustments[ $first ] ) === true
579
+                    && ( ( $adjustments[ $first ] < 0 && $tokenIndent > $currentIndent )
580
+                    || ( $adjustments[ $first ] > 0 && $tokenIndent < $currentIndent ) )
581 581
                 ) {
582
-                    $length = ($tokenIndent + $adjustments[$first]);
582
+                    $length = ( $tokenIndent + $adjustments[ $first ] );
583 583
 
584 584
                     // When fixing, we're going to adjust the indent of this line
585 585
                     // here automatically, so use this new padding value when
586 586
                     // comparing the expected padding to the actual padding.
587
-                    if ($phpcsFile->fixer->enabled === true) {
587
+                    if ( $phpcsFile->fixer->enabled === true ) {
588 588
                         $tokenIndent = $length;
589
-                        $this->adjustIndent($phpcsFile, $checkToken, $length, $adjustments[$first]);
589
+                        $this->adjustIndent( $phpcsFile, $checkToken, $length, $adjustments[ $first ] );
590 590
                     }
591 591
 
592
-                    if ($this->debug === true) {
593
-                        $line = $tokens[$checkToken]['line'];
594
-                        $type = $tokens[$checkToken]['type'];
595
-                        echo "Indent adjusted to $length for $type on line $line".PHP_EOL;
592
+                    if ( $this->debug === true ) {
593
+                        $line = $tokens[ $checkToken ][ 'line' ];
594
+                        $type = $tokens[ $checkToken ][ 'type' ];
595
+                        echo "Indent adjusted to $length for $type on line $line" . PHP_EOL;
596 596
                     }
597 597
 
598
-                    $adjustments[$checkToken] = $adjustments[$first];
598
+                    $adjustments[ $checkToken ] = $adjustments[ $first ];
599 599
 
600
-                    if ($this->debug === true) {
601
-                        $line = $tokens[$checkToken]['line'];
602
-                        $type = $tokens[$checkToken]['type'];
603
-                        echo "\t=> add adjustment of ".$adjustments[$checkToken]." for token $checkToken ($type) on line $line".PHP_EOL;
600
+                    if ( $this->debug === true ) {
601
+                        $line = $tokens[ $checkToken ][ 'line' ];
602
+                        $type = $tokens[ $checkToken ][ 'type' ];
603
+                        echo "\t=> add adjustment of " . $adjustments[ $checkToken ] . " for token $checkToken ($type) on line $line" . PHP_EOL;
604 604
                     }
605 605
                 }//end if
606 606
             }//end if
607 607
 
608 608
             // Scope closers reset the required indent to the same level as the opening condition.
609
-            if (($checkToken !== null
610
-                && isset($openScopes[$checkToken]) === true
611
-                || (isset($tokens[$checkToken]['scope_condition']) === true
612
-                && isset($tokens[$checkToken]['scope_closer']) === true
613
-                && $tokens[$checkToken]['scope_closer'] === $checkToken
614
-                && $tokens[$checkToken]['line'] !== $tokens[$tokens[$checkToken]['scope_opener']]['line']))
615
-                || ($checkToken === null
616
-                && isset($openScopes[$i]) === true
617
-                || (isset($tokens[$i]['scope_condition']) === true
618
-                && isset($tokens[$i]['scope_closer']) === true
619
-                && $tokens[$i]['scope_closer'] === $i
620
-                && $tokens[$i]['line'] !== $tokens[$tokens[$i]['scope_opener']]['line']))
609
+            if ( ( $checkToken !== null
610
+                && isset( $openScopes[ $checkToken ] ) === true
611
+                || ( isset( $tokens[ $checkToken ][ 'scope_condition' ] ) === true
612
+                && isset( $tokens[ $checkToken ][ 'scope_closer' ] ) === true
613
+                && $tokens[ $checkToken ][ 'scope_closer' ] === $checkToken
614
+                && $tokens[ $checkToken ][ 'line' ] !== $tokens[ $tokens[ $checkToken ][ 'scope_opener' ] ][ 'line' ] ) )
615
+                || ( $checkToken === null
616
+                && isset( $openScopes[ $i ] ) === true
617
+                || ( isset( $tokens[ $i ][ 'scope_condition' ] ) === true
618
+                && isset( $tokens[ $i ][ 'scope_closer' ] ) === true
619
+                && $tokens[ $i ][ 'scope_closer' ] === $i
620
+                && $tokens[ $i ][ 'line' ] !== $tokens[ $tokens[ $i ][ 'scope_opener' ] ][ 'line' ] ) )
621 621
             ) {
622
-                if ($this->debug === true) {
623
-                    if ($checkToken === null) {
624
-                        $type = $tokens[$tokens[$i]['scope_condition']]['type'];
625
-                        $line = $tokens[$i]['line'];
622
+                if ( $this->debug === true ) {
623
+                    if ( $checkToken === null ) {
624
+                        $type = $tokens[ $tokens[ $i ][ 'scope_condition' ] ][ 'type' ];
625
+                        $line = $tokens[ $i ][ 'line' ];
626 626
                     } else {
627
-                        $type = $tokens[$tokens[$checkToken]['scope_condition']]['type'];
628
-                        $line = $tokens[$checkToken]['line'];
627
+                        $type = $tokens[ $tokens[ $checkToken ][ 'scope_condition' ] ][ 'type' ];
628
+                        $line = $tokens[ $checkToken ][ 'line' ];
629 629
                     }
630 630
 
631
-                    echo "Close scope ($type) on line $line".PHP_EOL;
631
+                    echo "Close scope ($type) on line $line" . PHP_EOL;
632 632
                 }
633 633
 
634 634
                 $scopeCloser = $checkToken;
635
-                if ($scopeCloser === null) {
635
+                if ( $scopeCloser === null ) {
636 636
                     $scopeCloser = $i;
637 637
                 }
638 638
 
639
-                $conditionToken = array_pop($openScopes);
640
-                if ($this->debug === true) {
641
-                    $line = $tokens[$conditionToken]['line'];
642
-                    $type = $tokens[$conditionToken]['type'];
643
-                    echo "\t=> removed open scope $conditionToken ($type) on line $line".PHP_EOL;
639
+                $conditionToken = array_pop( $openScopes );
640
+                if ( $this->debug === true ) {
641
+                    $line = $tokens[ $conditionToken ][ 'line' ];
642
+                    $type = $tokens[ $conditionToken ][ 'type' ];
643
+                    echo "\t=> removed open scope $conditionToken ($type) on line $line" . PHP_EOL;
644 644
                 }
645 645
 
646
-                if (isset($tokens[$scopeCloser]['scope_condition']) === true) {
647
-                    $first = $phpcsFile->findFirstOnLine([T_WHITESPACE, T_INLINE_HTML], $tokens[$scopeCloser]['scope_condition'], true);
648
-                    if ($this->debug === true) {
649
-                        $line = $tokens[$first]['line'];
650
-                        $type = $tokens[$first]['type'];
651
-                        echo "\t* first token is $first ($type) on line $line *".PHP_EOL;
646
+                if ( isset( $tokens[ $scopeCloser ][ 'scope_condition' ] ) === true ) {
647
+                    $first = $phpcsFile->findFirstOnLine( [ T_WHITESPACE, T_INLINE_HTML ], $tokens[ $scopeCloser ][ 'scope_condition' ], true );
648
+                    if ( $this->debug === true ) {
649
+                        $line = $tokens[ $first ][ 'line' ];
650
+                        $type = $tokens[ $first ][ 'type' ];
651
+                        echo "\t* first token is $first ($type) on line $line *" . PHP_EOL;
652 652
                     }
653 653
 
654
-                    while ($tokens[$first]['code'] === T_CONSTANT_ENCAPSED_STRING
655
-                        && $tokens[($first - 1)]['code'] === T_CONSTANT_ENCAPSED_STRING
654
+                    while ( $tokens[ $first ][ 'code' ] === T_CONSTANT_ENCAPSED_STRING
655
+                        && $tokens[ ( $first - 1 ) ][ 'code' ] === T_CONSTANT_ENCAPSED_STRING
656 656
                     ) {
657
-                        $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, ($first - 1), true);
658
-                        if ($this->debug === true) {
659
-                            $line = $tokens[$first]['line'];
660
-                            $type = $tokens[$first]['type'];
661
-                            echo "\t* found multi-line string; amended first token is $first ($type) on line $line *".PHP_EOL;
657
+                        $first = $phpcsFile->findFirstOnLine( T_WHITESPACE, ( $first - 1 ), true );
658
+                        if ( $this->debug === true ) {
659
+                            $line = $tokens[ $first ][ 'line' ];
660
+                            $type = $tokens[ $first ][ 'type' ];
661
+                            echo "\t* found multi-line string; amended first token is $first ($type) on line $line *" . PHP_EOL;
662 662
                         }
663 663
                     }
664 664
 
665
-                    $currentIndent = ($tokens[$first]['column'] - 1);
666
-                    if (isset($adjustments[$first]) === true) {
667
-                        $currentIndent += $adjustments[$first];
665
+                    $currentIndent = ( $tokens[ $first ][ 'column' ] - 1 );
666
+                    if ( isset( $adjustments[ $first ] ) === true ) {
667
+                        $currentIndent += $adjustments[ $first ];
668 668
                     }
669 669
 
670
-                    $setIndents[$scopeCloser] = $currentIndent;
670
+                    $setIndents[ $scopeCloser ] = $currentIndent;
671 671
 
672
-                    if ($this->debug === true) {
673
-                        $type = $tokens[$scopeCloser]['type'];
674
-                        echo "\t=> indent set to $currentIndent by token $scopeCloser ($type)".PHP_EOL;
672
+                    if ( $this->debug === true ) {
673
+                        $type = $tokens[ $scopeCloser ][ 'type' ];
674
+                        echo "\t=> indent set to $currentIndent by token $scopeCloser ($type)" . PHP_EOL;
675 675
                     }
676 676
 
677 677
                     // We only check the indent of scope closers if they are
678 678
                     // curly braces because other constructs tend to have different rules.
679
-                    if ($tokens[$scopeCloser]['code'] === T_CLOSE_CURLY_BRACKET) {
679
+                    if ( $tokens[ $scopeCloser ][ 'code' ] === T_CLOSE_CURLY_BRACKET ) {
680 680
                         $exact = true;
681 681
                     } else {
682 682
                         $checkToken = null;
@@ -685,93 +685,93 @@  discard block
 block discarded – undo
685 685
             }//end if
686 686
 
687 687
             // Handle scope for JS object notation.
688
-            if ($phpcsFile->tokenizerType === 'JS'
689
-                && (($checkToken !== null
690
-                && $tokens[$checkToken]['code'] === T_CLOSE_OBJECT
691
-                && $tokens[$checkToken]['line'] !== $tokens[$tokens[$checkToken]['bracket_opener']]['line'])
692
-                || ($checkToken === null
693
-                && $tokens[$i]['code'] === T_CLOSE_OBJECT
694
-                && $tokens[$i]['line'] !== $tokens[$tokens[$i]['bracket_opener']]['line']))
688
+            if ( $phpcsFile->tokenizerType === 'JS'
689
+                && ( ( $checkToken !== null
690
+                && $tokens[ $checkToken ][ 'code' ] === T_CLOSE_OBJECT
691
+                && $tokens[ $checkToken ][ 'line' ] !== $tokens[ $tokens[ $checkToken ][ 'bracket_opener' ] ][ 'line' ] )
692
+                || ( $checkToken === null
693
+                && $tokens[ $i ][ 'code' ] === T_CLOSE_OBJECT
694
+                && $tokens[ $i ][ 'line' ] !== $tokens[ $tokens[ $i ][ 'bracket_opener' ] ][ 'line' ] ) )
695 695
             ) {
696
-                if ($this->debug === true) {
697
-                    $line = $tokens[$i]['line'];
698
-                    echo "Close JS object on line $line".PHP_EOL;
696
+                if ( $this->debug === true ) {
697
+                    $line = $tokens[ $i ][ 'line' ];
698
+                    echo "Close JS object on line $line" . PHP_EOL;
699 699
                 }
700 700
 
701 701
                 $scopeCloser = $checkToken;
702
-                if ($scopeCloser === null) {
702
+                if ( $scopeCloser === null ) {
703 703
                     $scopeCloser = $i;
704 704
                 } else {
705
-                    $conditionToken = array_pop($openScopes);
706
-                    if ($this->debug === true) {
707
-                        $line = $tokens[$conditionToken]['line'];
708
-                        $type = $tokens[$conditionToken]['type'];
709
-                        echo "\t=> removed open scope $conditionToken ($type) on line $line".PHP_EOL;
705
+                    $conditionToken = array_pop( $openScopes );
706
+                    if ( $this->debug === true ) {
707
+                        $line = $tokens[ $conditionToken ][ 'line' ];
708
+                        $type = $tokens[ $conditionToken ][ 'type' ];
709
+                        echo "\t=> removed open scope $conditionToken ($type) on line $line" . PHP_EOL;
710 710
                     }
711 711
                 }
712 712
 
713 713
                 $parens = 0;
714
-                if (isset($tokens[$scopeCloser]['nested_parenthesis']) === true
715
-                    && empty($tokens[$scopeCloser]['nested_parenthesis']) === false
714
+                if ( isset( $tokens[ $scopeCloser ][ 'nested_parenthesis' ] ) === true
715
+                    && empty( $tokens[ $scopeCloser ][ 'nested_parenthesis' ] ) === false
716 716
                 ) {
717
-                    $parens = $tokens[$scopeCloser]['nested_parenthesis'];
718
-                    end($parens);
719
-                    $parens = key($parens);
720
-                    if ($this->debug === true) {
721
-                        $line = $tokens[$parens]['line'];
722
-                        echo "\t* token has nested parenthesis $parens on line $line *".PHP_EOL;
717
+                    $parens = $tokens[ $scopeCloser ][ 'nested_parenthesis' ];
718
+                    end( $parens );
719
+                    $parens = key( $parens );
720
+                    if ( $this->debug === true ) {
721
+                        $line = $tokens[ $parens ][ 'line' ];
722
+                        echo "\t* token has nested parenthesis $parens on line $line *" . PHP_EOL;
723 723
                     }
724 724
                 }
725 725
 
726 726
                 $condition = 0;
727
-                if (isset($tokens[$scopeCloser]['conditions']) === true
728
-                    && empty($tokens[$scopeCloser]['conditions']) === false
727
+                if ( isset( $tokens[ $scopeCloser ][ 'conditions' ] ) === true
728
+                    && empty( $tokens[ $scopeCloser ][ 'conditions' ] ) === false
729 729
                 ) {
730
-                    $condition = $tokens[$scopeCloser]['conditions'];
731
-                    end($condition);
732
-                    $condition = key($condition);
733
-                    if ($this->debug === true) {
734
-                        $line = $tokens[$condition]['line'];
735
-                        $type = $tokens[$condition]['type'];
736
-                        echo "\t* token is inside condition $condition ($type) on line $line *".PHP_EOL;
730
+                    $condition = $tokens[ $scopeCloser ][ 'conditions' ];
731
+                    end( $condition );
732
+                    $condition = key( $condition );
733
+                    if ( $this->debug === true ) {
734
+                        $line = $tokens[ $condition ][ 'line' ];
735
+                        $type = $tokens[ $condition ][ 'type' ];
736
+                        echo "\t* token is inside condition $condition ($type) on line $line *" . PHP_EOL;
737 737
                     }
738 738
                 }
739 739
 
740
-                if ($parens > $condition) {
741
-                    if ($this->debug === true) {
742
-                        echo "\t* using parenthesis *".PHP_EOL;
740
+                if ( $parens > $condition ) {
741
+                    if ( $this->debug === true ) {
742
+                        echo "\t* using parenthesis *" . PHP_EOL;
743 743
                     }
744 744
 
745
-                    $first     = $phpcsFile->findFirstOnLine(T_WHITESPACE, $parens, true);
745
+                    $first     = $phpcsFile->findFirstOnLine( T_WHITESPACE, $parens, true );
746 746
                     $condition = 0;
747
-                } else if ($condition > 0) {
748
-                    if ($this->debug === true) {
749
-                        echo "\t* using condition *".PHP_EOL;
747
+                } else if ( $condition > 0 ) {
748
+                    if ( $this->debug === true ) {
749
+                        echo "\t* using condition *" . PHP_EOL;
750 750
                     }
751 751
 
752
-                    $first  = $phpcsFile->findFirstOnLine(T_WHITESPACE, $condition, true);
752
+                    $first  = $phpcsFile->findFirstOnLine( T_WHITESPACE, $condition, true );
753 753
                     $parens = 0;
754 754
                 } else {
755
-                    if ($this->debug === true) {
756
-                        $line = $tokens[$tokens[$scopeCloser]['bracket_opener']]['line'];
757
-                        echo "\t* token is not in parenthesis or condition; using opener on line $line *".PHP_EOL;
755
+                    if ( $this->debug === true ) {
756
+                        $line = $tokens[ $tokens[ $scopeCloser ][ 'bracket_opener' ] ][ 'line' ];
757
+                        echo "\t* token is not in parenthesis or condition; using opener on line $line *" . PHP_EOL;
758 758
                     }
759 759
 
760
-                    $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $tokens[$scopeCloser]['bracket_opener'], true);
760
+                    $first = $phpcsFile->findFirstOnLine( T_WHITESPACE, $tokens[ $scopeCloser ][ 'bracket_opener' ], true );
761 761
                 }//end if
762 762
 
763
-                $currentIndent = ($tokens[$first]['column'] - 1);
764
-                if (isset($adjustments[$first]) === true) {
765
-                    $currentIndent += $adjustments[$first];
763
+                $currentIndent = ( $tokens[ $first ][ 'column' ] - 1 );
764
+                if ( isset( $adjustments[ $first ] ) === true ) {
765
+                    $currentIndent += $adjustments[ $first ];
766 766
                 }
767 767
 
768
-                if ($parens > 0 || $condition > 0) {
769
-                    $checkIndent = ($tokens[$first]['column'] - 1);
770
-                    if (isset($adjustments[$first]) === true) {
771
-                        $checkIndent += $adjustments[$first];
768
+                if ( $parens > 0 || $condition > 0 ) {
769
+                    $checkIndent = ( $tokens[ $first ][ 'column' ] - 1 );
770
+                    if ( isset( $adjustments[ $first ] ) === true ) {
771
+                        $checkIndent += $adjustments[ $first ];
772 772
                     }
773 773
 
774
-                    if ($condition > 0) {
774
+                    if ( $condition > 0 ) {
775 775
                         $checkIndent   += $this->indent;
776 776
                         $currentIndent += $this->indent;
777 777
                         $exact          = true;
@@ -781,76 +781,76 @@  discard block
 block discarded – undo
781 781
                 }
782 782
 
783 783
                 // Make sure it is divisible by our expected indent.
784
-                $currentIndent      = (int) (ceil($currentIndent / $this->indent) * $this->indent);
785
-                $checkIndent        = (int) (ceil($checkIndent / $this->indent) * $this->indent);
786
-                $setIndents[$first] = $currentIndent;
784
+                $currentIndent      = (int)( ceil( $currentIndent / $this->indent ) * $this->indent );
785
+                $checkIndent        = (int)( ceil( $checkIndent / $this->indent ) * $this->indent );
786
+                $setIndents[ $first ] = $currentIndent;
787 787
 
788
-                if ($this->debug === true) {
789
-                    $type = $tokens[$first]['type'];
790
-                    echo "\t=> checking indent of $checkIndent; main indent set to $currentIndent by token $first ($type)".PHP_EOL;
788
+                if ( $this->debug === true ) {
789
+                    $type = $tokens[ $first ][ 'type' ];
790
+                    echo "\t=> checking indent of $checkIndent; main indent set to $currentIndent by token $first ($type)" . PHP_EOL;
791 791
                 }
792 792
             }//end if
793 793
 
794
-            if ($checkToken !== null
795
-                && isset(Tokens::$scopeOpeners[$tokens[$checkToken]['code']]) === true
796
-                && in_array($tokens[$checkToken]['code'], $this->nonIndentingScopes, true) === false
797
-                && isset($tokens[$checkToken]['scope_opener']) === true
794
+            if ( $checkToken !== null
795
+                && isset( Tokens::$scopeOpeners[ $tokens[ $checkToken ][ 'code' ] ] ) === true
796
+                && in_array( $tokens[ $checkToken ][ 'code' ], $this->nonIndentingScopes, true ) === false
797
+                && isset( $tokens[ $checkToken ][ 'scope_opener' ] ) === true
798 798
             ) {
799 799
                 $exact = true;
800 800
 
801 801
                 $lastOpener = null;
802
-                if (empty($openScopes) === false) {
803
-                    end($openScopes);
804
-                    $lastOpener = current($openScopes);
802
+                if ( empty( $openScopes ) === false ) {
803
+                    end( $openScopes );
804
+                    $lastOpener = current( $openScopes );
805 805
                 }
806 806
 
807 807
                 // A scope opener that shares a closer with another token (like multiple
808 808
                 // CASEs using the same BREAK) needs to reduce the indent level so its
809 809
                 // indent is checked correctly. It will then increase the indent again
810 810
                 // (as all openers do) after being checked.
811
-                if ($lastOpener !== null
812
-                    && isset($tokens[$lastOpener]['scope_closer']) === true
813
-                    && $tokens[$lastOpener]['level'] === $tokens[$checkToken]['level']
814
-                    && $tokens[$lastOpener]['scope_closer'] === $tokens[$checkToken]['scope_closer']
811
+                if ( $lastOpener !== null
812
+                    && isset( $tokens[ $lastOpener ][ 'scope_closer' ] ) === true
813
+                    && $tokens[ $lastOpener ][ 'level' ] === $tokens[ $checkToken ][ 'level' ]
814
+                    && $tokens[ $lastOpener ][ 'scope_closer' ] === $tokens[ $checkToken ][ 'scope_closer' ]
815 815
                 ) {
816 816
                     $currentIndent          -= $this->indent;
817
-                    $setIndents[$lastOpener] = $currentIndent;
818
-                    if ($this->debug === true) {
819
-                        $line = $tokens[$i]['line'];
820
-                        $type = $tokens[$lastOpener]['type'];
821
-                        echo "Shared closer found on line $line".PHP_EOL;
822
-                        echo "\t=> indent set to $currentIndent by token $lastOpener ($type)".PHP_EOL;
817
+                    $setIndents[ $lastOpener ] = $currentIndent;
818
+                    if ( $this->debug === true ) {
819
+                        $line = $tokens[ $i ][ 'line' ];
820
+                        $type = $tokens[ $lastOpener ][ 'type' ];
821
+                        echo "Shared closer found on line $line" . PHP_EOL;
822
+                        echo "\t=> indent set to $currentIndent by token $lastOpener ($type)" . PHP_EOL;
823 823
                     }
824 824
                 }
825 825
 
826
-                if ($tokens[$checkToken]['code'] === T_CLOSURE
826
+                if ( $tokens[ $checkToken ][ 'code' ] === T_CLOSURE
827 827
                     && $tokenIndent > $currentIndent
828 828
                 ) {
829 829
                     // The opener is indented more than needed, which is fine.
830 830
                     // But just check that it is divisible by our expected indent.
831
-                    $checkIndent = (int) (ceil($tokenIndent / $this->indent) * $this->indent);
831
+                    $checkIndent = (int)( ceil( $tokenIndent / $this->indent ) * $this->indent );
832 832
                     $exact       = false;
833 833
 
834
-                    if ($this->debug === true) {
835
-                        $line = $tokens[$i]['line'];
836
-                        echo "Closure found on line $line".PHP_EOL;
837
-                        echo "\t=> checking indent of $checkIndent; main indent remains at $currentIndent".PHP_EOL;
834
+                    if ( $this->debug === true ) {
835
+                        $line = $tokens[ $i ][ 'line' ];
836
+                        echo "Closure found on line $line" . PHP_EOL;
837
+                        echo "\t=> checking indent of $checkIndent; main indent remains at $currentIndent" . PHP_EOL;
838 838
                     }
839 839
                 }
840 840
             }//end if
841 841
 
842 842
             // Method prefix indentation has to be exact or else it will break
843 843
             // the rest of the function declaration, and potentially future ones.
844
-            if ($checkToken !== null
845
-                && isset(Tokens::$methodPrefixes[$tokens[$checkToken]['code']]) === true
846
-                && $tokens[($checkToken + 1)]['code'] !== T_DOUBLE_COLON
844
+            if ( $checkToken !== null
845
+                && isset( Tokens::$methodPrefixes[ $tokens[ $checkToken ][ 'code' ] ] ) === true
846
+                && $tokens[ ( $checkToken + 1 ) ][ 'code' ] !== T_DOUBLE_COLON
847 847
             ) {
848
-                $next = $phpcsFile->findNext(Tokens::$emptyTokens, ($checkToken + 1), null, true);
849
-                if ($next === false || $tokens[$next]['code'] !== T_CLOSURE) {
850
-                    if ($this->debug === true) {
851
-                        $line = $tokens[$checkToken]['line'];
852
-                        $type = $tokens[$checkToken]['type'];
853
-                        echo "\t* method prefix ($type) found on line $line; indent set to exact *".PHP_EOL;
848
+                $next = $phpcsFile->findNext( Tokens::$emptyTokens, ( $checkToken + 1 ), null, true );
849
+                if ( $next === false || $tokens[ $next ][ 'code' ] !== T_CLOSURE ) {
850
+                    if ( $this->debug === true ) {
851
+                        $line = $tokens[ $checkToken ][ 'line' ];
852
+                        $type = $tokens[ $checkToken ][ 'type' ];
853
+                        echo "\t* method prefix ($type) found on line $line; indent set to exact *" . PHP_EOL;
854 854
                     }
855 855
 
856 856
                     $exact = true;
@@ -859,7 +859,7 @@  discard block
 block discarded – undo
859 859
 
860 860
             // JS property indentation has to be exact or else if will break
861 861
             // things like function and object indentation.
862
-            if ($checkToken !== null && $tokens[$checkToken]['code'] === T_PROPERTY) {
862
+            if ( $checkToken !== null && $tokens[ $checkToken ][ 'code' ] === T_PROPERTY ) {
863 863
                 $exact = true;
864 864
             }
865 865
 
@@ -867,50 +867,50 @@  discard block
 block discarded – undo
867 867
             // so they don't cause problems with indent checks for the code
868 868
             // within them, but they don't need to line up with the current indent
869 869
             // in most cases.
870
-            if ($checkToken !== null
871
-                && ($tokens[$checkToken]['code'] === T_OPEN_TAG
872
-                || $tokens[$checkToken]['code'] === T_OPEN_TAG_WITH_ECHO)
870
+            if ( $checkToken !== null
871
+                && ( $tokens[ $checkToken ][ 'code' ] === T_OPEN_TAG
872
+                || $tokens[ $checkToken ][ 'code' ] === T_OPEN_TAG_WITH_ECHO )
873 873
             ) {
874
-                $checkIndent = ($tokens[$checkToken]['column'] - 1);
874
+                $checkIndent = ( $tokens[ $checkToken ][ 'column' ] - 1 );
875 875
 
876 876
                 // If we are re-opening a block that was closed in the same
877 877
                 // scope as us, then reset the indent back to what the scope opener
878 878
                 // set instead of using whatever indent this open tag has set.
879
-                if (empty($tokens[$checkToken]['conditions']) === false) {
880
-                    $close = $phpcsFile->findPrevious(T_CLOSE_TAG, ($checkToken - 1));
881
-                    if ($close !== false
882
-                        && $tokens[$checkToken]['conditions'] === $tokens[$close]['conditions']
879
+                if ( empty( $tokens[ $checkToken ][ 'conditions' ] ) === false ) {
880
+                    $close = $phpcsFile->findPrevious( T_CLOSE_TAG, ( $checkToken - 1 ) );
881
+                    if ( $close !== false
882
+                        && $tokens[ $checkToken ][ 'conditions' ] === $tokens[ $close ][ 'conditions' ]
883 883
                     ) {
884
-                        $conditions    = array_keys($tokens[$checkToken]['conditions']);
885
-                        $lastCondition = array_pop($conditions);
886
-                        $lastOpener    = $tokens[$lastCondition]['scope_opener'];
887
-                        $lastCloser    = $tokens[$lastCondition]['scope_closer'];
888
-                        if ($tokens[$lastCloser]['line'] !== $tokens[$checkToken]['line']
889
-                            && isset($setIndents[$lastOpener]) === true
884
+                        $conditions    = array_keys( $tokens[ $checkToken ][ 'conditions' ] );
885
+                        $lastCondition = array_pop( $conditions );
886
+                        $lastOpener    = $tokens[ $lastCondition ][ 'scope_opener' ];
887
+                        $lastCloser    = $tokens[ $lastCondition ][ 'scope_closer' ];
888
+                        if ( $tokens[ $lastCloser ][ 'line' ] !== $tokens[ $checkToken ][ 'line' ]
889
+                            && isset( $setIndents[ $lastOpener ] ) === true
890 890
                         ) {
891
-                            $checkIndent = $setIndents[$lastOpener];
891
+                            $checkIndent = $setIndents[ $lastOpener ];
892 892
                         }
893 893
                     }
894 894
                 }
895 895
 
896
-                $checkIndent = (int) (ceil($checkIndent / $this->indent) * $this->indent);
896
+                $checkIndent = (int)( ceil( $checkIndent / $this->indent ) * $this->indent );
897 897
             }//end if
898 898
 
899 899
             // Close tags needs to be indented to exact column positions.
900
-            if ($checkToken !== null && $tokens[$checkToken]['code'] === T_CLOSE_TAG) {
900
+            if ( $checkToken !== null && $tokens[ $checkToken ][ 'code' ] === T_CLOSE_TAG ) {
901 901
                 $exact       = true;
902 902
                 $checkIndent = $currentIndent;
903
-                $checkIndent = (int) (ceil($checkIndent / $this->indent) * $this->indent);
903
+                $checkIndent = (int)( ceil( $checkIndent / $this->indent ) * $this->indent );
904 904
             }
905 905
 
906 906
             // Special case for ELSE statements that are not on the same
907 907
             // line as the previous IF statements closing brace. They still need
908 908
             // to have the same indent or it will break code after the block.
909
-            if ($checkToken !== null && $tokens[$checkToken]['code'] === T_ELSE) {
909
+            if ( $checkToken !== null && $tokens[ $checkToken ][ 'code' ] === T_ELSE ) {
910 910
                 $exact = true;
911 911
             }
912 912
 
913
-            if ($checkIndent === null) {
913
+            if ( $checkIndent === null ) {
914 914
                 $checkIndent = $currentIndent;
915 915
             }
916 916
 
@@ -924,23 +924,23 @@  discard block
 block discarded – undo
924 924
                 the checking of future lines
925 925
             */
926 926
 
927
-            if ($checkToken !== null
928
-                && isset($this->ignoreIndentation[$tokens[$checkToken]['code']]) === false
929
-                && (($tokenIndent !== $checkIndent && $exact === true)
930
-                || ($tokenIndent < $checkIndent && $exact === false))
927
+            if ( $checkToken !== null
928
+                && isset( $this->ignoreIndentation[ $tokens[ $checkToken ][ 'code' ] ] ) === false
929
+                && ( ( $tokenIndent !== $checkIndent && $exact === true )
930
+                || ( $tokenIndent < $checkIndent && $exact === false ) )
931 931
             ) {
932 932
                 $type  = 'IncorrectExact';
933 933
                 $error = 'Line indented incorrectly; expected ';
934
-                if ($exact === false) {
934
+                if ( $exact === false ) {
935 935
                     $error .= 'at least ';
936 936
                     $type   = 'Incorrect';
937 937
                 }
938 938
 
939
-                if ($this->tabIndent === true) {
939
+                if ( $this->tabIndent === true ) {
940 940
                     $error .= '%s tabs, found %s';
941 941
                     $data   = [
942
-                        floor($checkIndent / $this->tabWidth),
943
-                        floor($tokenIndent / $this->tabWidth),
942
+                        floor( $checkIndent / $this->tabWidth ),
943
+                        floor( $tokenIndent / $this->tabWidth ),
944 944
                     ];
945 945
                 } else {
946 946
                     $error .= '%s spaces, found %s';
@@ -950,89 +950,89 @@  discard block
 block discarded – undo
950 950
                     ];
951 951
                 }
952 952
 
953
-                if ($this->debug === true) {
954
-                    $line    = $tokens[$checkToken]['line'];
955
-                    $message = vsprintf($error, $data);
956
-                    echo "[Line $line] $message".PHP_EOL;
953
+                if ( $this->debug === true ) {
954
+                    $line    = $tokens[ $checkToken ][ 'line' ];
955
+                    $message = vsprintf( $error, $data );
956
+                    echo "[Line $line] $message" . PHP_EOL;
957 957
                 }
958 958
 
959 959
                 // Assume the change would be applied and continue
960 960
                 // checking indents under this assumption. This gives more
961 961
                 // technically accurate error messages.
962
-                $adjustments[$checkToken] = ($checkIndent - $tokenIndent);
962
+                $adjustments[ $checkToken ] = ( $checkIndent - $tokenIndent );
963 963
 
964
-                $fix = $phpcsFile->addFixableError($error, $checkToken, $type, $data);
965
-                if ($fix === true || $this->debug === true) {
966
-                    $accepted = $this->adjustIndent($phpcsFile, $checkToken, $checkIndent, ($checkIndent - $tokenIndent));
964
+                $fix = $phpcsFile->addFixableError( $error, $checkToken, $type, $data );
965
+                if ( $fix === true || $this->debug === true ) {
966
+                    $accepted = $this->adjustIndent( $phpcsFile, $checkToken, $checkIndent, ( $checkIndent - $tokenIndent ) );
967 967
 
968
-                    if ($accepted === true && $this->debug === true) {
969
-                        $line = $tokens[$checkToken]['line'];
970
-                        $type = $tokens[$checkToken]['type'];
971
-                        echo "\t=> add adjustment of ".$adjustments[$checkToken]." for token $checkToken ($type) on line $line".PHP_EOL;
968
+                    if ( $accepted === true && $this->debug === true ) {
969
+                        $line = $tokens[ $checkToken ][ 'line' ];
970
+                        $type = $tokens[ $checkToken ][ 'type' ];
971
+                        echo "\t=> add adjustment of " . $adjustments[ $checkToken ] . " for token $checkToken ($type) on line $line" . PHP_EOL;
972 972
                     }
973 973
                 }
974 974
             }//end if
975 975
 
976
-            if ($checkToken !== null) {
976
+            if ( $checkToken !== null ) {
977 977
                 $i = $checkToken;
978 978
             }
979 979
 
980 980
             // Completely skip here/now docs as the indent is a part of the
981 981
             // content itself.
982
-            if ($tokens[$i]['code'] === T_START_HEREDOC
983
-                || $tokens[$i]['code'] === T_START_NOWDOC
982
+            if ( $tokens[ $i ][ 'code' ] === T_START_HEREDOC
983
+                || $tokens[ $i ][ 'code' ] === T_START_NOWDOC
984 984
             ) {
985
-                $i = $phpcsFile->findNext([T_END_HEREDOC, T_END_NOWDOC], ($i + 1));
986
-                $i = $phpcsFile->findNext(Tokens::$emptyTokens, ($i + 1), null, true);
985
+                $i = $phpcsFile->findNext( [ T_END_HEREDOC, T_END_NOWDOC ], ( $i + 1 ) );
986
+                $i = $phpcsFile->findNext( Tokens::$emptyTokens, ( $i + 1 ), null, true );
987 987
                 continue;
988 988
             }
989 989
 
990 990
             // Completely skip multi-line strings as the indent is a part of the
991 991
             // content itself.
992
-            if ($tokens[$i]['code'] === T_CONSTANT_ENCAPSED_STRING
993
-                || $tokens[$i]['code'] === T_DOUBLE_QUOTED_STRING
992
+            if ( $tokens[ $i ][ 'code' ] === T_CONSTANT_ENCAPSED_STRING
993
+                || $tokens[ $i ][ 'code' ] === T_DOUBLE_QUOTED_STRING
994 994
             ) {
995
-                $i = $phpcsFile->findNext($tokens[$i]['code'], ($i + 1), null, true);
995
+                $i = $phpcsFile->findNext( $tokens[ $i ][ 'code' ], ( $i + 1 ), null, true );
996 996
                 $i--;
997 997
                 continue;
998 998
             }
999 999
 
1000 1000
             // Completely skip doc comments as they tend to have complex
1001 1001
             // indentation rules.
1002
-            if ($tokens[$i]['code'] === T_DOC_COMMENT_OPEN_TAG) {
1003
-                $i = $tokens[$i]['comment_closer'];
1002
+            if ( $tokens[ $i ][ 'code' ] === T_DOC_COMMENT_OPEN_TAG ) {
1003
+                $i = $tokens[ $i ][ 'comment_closer' ];
1004 1004
                 continue;
1005 1005
             }
1006 1006
 
1007 1007
             // Open tags reset the indent level.
1008
-            if ($tokens[$i]['code'] === T_OPEN_TAG
1009
-                || $tokens[$i]['code'] === T_OPEN_TAG_WITH_ECHO
1008
+            if ( $tokens[ $i ][ 'code' ] === T_OPEN_TAG
1009
+                || $tokens[ $i ][ 'code' ] === T_OPEN_TAG_WITH_ECHO
1010 1010
             ) {
1011
-                if ($this->debug === true) {
1012
-                    $line = $tokens[$i]['line'];
1013
-                    echo "Open PHP tag found on line $line".PHP_EOL;
1011
+                if ( $this->debug === true ) {
1012
+                    $line = $tokens[ $i ][ 'line' ];
1013
+                    echo "Open PHP tag found on line $line" . PHP_EOL;
1014 1014
                 }
1015 1015
 
1016
-                if ($checkToken === null) {
1017
-                    $first         = $phpcsFile->findFirstOnLine(T_WHITESPACE, $i, true);
1018
-                    $currentIndent = (strlen($tokens[$first]['content']) - strlen(ltrim($tokens[$first]['content'])));
1016
+                if ( $checkToken === null ) {
1017
+                    $first         = $phpcsFile->findFirstOnLine( T_WHITESPACE, $i, true );
1018
+                    $currentIndent = ( strlen( $tokens[ $first ][ 'content' ] ) - strlen( ltrim( $tokens[ $first ][ 'content' ] ) ) );
1019 1019
                 } else {
1020
-                    $currentIndent = ($tokens[$i]['column'] - 1);
1020
+                    $currentIndent = ( $tokens[ $i ][ 'column' ] - 1 );
1021 1021
                 }
1022 1022
 
1023 1023
                 $lastOpenTag = $i;
1024 1024
 
1025
-                if (isset($adjustments[$i]) === true) {
1026
-                    $currentIndent += $adjustments[$i];
1025
+                if ( isset( $adjustments[ $i ] ) === true ) {
1026
+                    $currentIndent += $adjustments[ $i ];
1027 1027
                 }
1028 1028
 
1029 1029
                 // Make sure it is divisible by our expected indent.
1030
-                $currentIndent  = (int) (ceil($currentIndent / $this->indent) * $this->indent);
1031
-                $setIndents[$i] = $currentIndent;
1030
+                $currentIndent  = (int)( ceil( $currentIndent / $this->indent ) * $this->indent );
1031
+                $setIndents[ $i ] = $currentIndent;
1032 1032
 
1033
-                if ($this->debug === true) {
1034
-                    $type = $tokens[$i]['type'];
1035
-                    echo "\t=> indent set to $currentIndent by token $i ($type)".PHP_EOL;
1033
+                if ( $this->debug === true ) {
1034
+                    $type = $tokens[ $i ][ 'type' ];
1035
+                    echo "\t=> indent set to $currentIndent by token $i ($type)" . PHP_EOL;
1036 1036
                 }
1037 1037
 
1038 1038
                 continue;
@@ -1040,149 +1040,149 @@  discard block
 block discarded – undo
1040 1040
 
1041 1041
             // Close tags reset the indent level, unless they are closing a tag
1042 1042
             // opened on the same line.
1043
-            if ($tokens[$i]['code'] === T_CLOSE_TAG) {
1044
-                if ($this->debug === true) {
1045
-                    $line = $tokens[$i]['line'];
1046
-                    echo "Close PHP tag found on line $line".PHP_EOL;
1043
+            if ( $tokens[ $i ][ 'code' ] === T_CLOSE_TAG ) {
1044
+                if ( $this->debug === true ) {
1045
+                    $line = $tokens[ $i ][ 'line' ];
1046
+                    echo "Close PHP tag found on line $line" . PHP_EOL;
1047 1047
                 }
1048 1048
 
1049
-                if ($tokens[$lastOpenTag]['line'] !== $tokens[$i]['line']) {
1050
-                    $currentIndent = ($tokens[$i]['column'] - 1);
1049
+                if ( $tokens[ $lastOpenTag ][ 'line' ] !== $tokens[ $i ][ 'line' ] ) {
1050
+                    $currentIndent = ( $tokens[ $i ][ 'column' ] - 1 );
1051 1051
                     $lastCloseTag  = $i;
1052 1052
                 } else {
1053
-                    if ($lastCloseTag === null) {
1053
+                    if ( $lastCloseTag === null ) {
1054 1054
                         $currentIndent = 0;
1055 1055
                     } else {
1056
-                        $currentIndent = ($tokens[$lastCloseTag]['column'] - 1);
1056
+                        $currentIndent = ( $tokens[ $lastCloseTag ][ 'column' ] - 1 );
1057 1057
                     }
1058 1058
                 }
1059 1059
 
1060
-                if (isset($adjustments[$i]) === true) {
1061
-                    $currentIndent += $adjustments[$i];
1060
+                if ( isset( $adjustments[ $i ] ) === true ) {
1061
+                    $currentIndent += $adjustments[ $i ];
1062 1062
                 }
1063 1063
 
1064 1064
                 // Make sure it is divisible by our expected indent.
1065
-                $currentIndent  = (int) (ceil($currentIndent / $this->indent) * $this->indent);
1066
-                $setIndents[$i] = $currentIndent;
1065
+                $currentIndent  = (int)( ceil( $currentIndent / $this->indent ) * $this->indent );
1066
+                $setIndents[ $i ] = $currentIndent;
1067 1067
 
1068
-                if ($this->debug === true) {
1069
-                    $type = $tokens[$i]['type'];
1070
-                    echo "\t=> indent set to $currentIndent by token $i ($type)".PHP_EOL;
1068
+                if ( $this->debug === true ) {
1069
+                    $type = $tokens[ $i ][ 'type' ];
1070
+                    echo "\t=> indent set to $currentIndent by token $i ($type)" . PHP_EOL;
1071 1071
                 }
1072 1072
 
1073 1073
                 continue;
1074 1074
             }//end if
1075 1075
 
1076 1076
             // Anon classes and functions set the indent based on their own indent level.
1077
-            if ($tokens[$i]['code'] === T_CLOSURE || $tokens[$i]['code'] === T_ANON_CLASS) {
1078
-                $closer = $tokens[$i]['scope_closer'];
1079
-                if ($tokens[$i]['line'] === $tokens[$closer]['line']) {
1080
-                    if ($this->debug === true) {
1081
-                        $type = str_replace('_', ' ', strtolower(substr($tokens[$i]['type'], 2)));
1082
-                        $line = $tokens[$i]['line'];
1083
-                        echo "* ignoring single-line $type on line $line".PHP_EOL;
1077
+            if ( $tokens[ $i ][ 'code' ] === T_CLOSURE || $tokens[ $i ][ 'code' ] === T_ANON_CLASS ) {
1078
+                $closer = $tokens[ $i ][ 'scope_closer' ];
1079
+                if ( $tokens[ $i ][ 'line' ] === $tokens[ $closer ][ 'line' ] ) {
1080
+                    if ( $this->debug === true ) {
1081
+                        $type = str_replace( '_', ' ', strtolower( substr( $tokens[ $i ][ 'type' ], 2 ) ) );
1082
+                        $line = $tokens[ $i ][ 'line' ];
1083
+                        echo "* ignoring single-line $type on line $line" . PHP_EOL;
1084 1084
                     }
1085 1085
 
1086 1086
                     $i = $closer;
1087 1087
                     continue;
1088 1088
                 }
1089 1089
 
1090
-                if ($this->debug === true) {
1091
-                    $type = str_replace('_', ' ', strtolower(substr($tokens[$i]['type'], 2)));
1092
-                    $line = $tokens[$i]['line'];
1093
-                    echo "Open $type on line $line".PHP_EOL;
1090
+                if ( $this->debug === true ) {
1091
+                    $type = str_replace( '_', ' ', strtolower( substr( $tokens[ $i ][ 'type' ], 2 ) ) );
1092
+                    $line = $tokens[ $i ][ 'line' ];
1093
+                    echo "Open $type on line $line" . PHP_EOL;
1094 1094
                 }
1095 1095
 
1096
-                $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $i, true);
1097
-                if ($this->debug === true) {
1098
-                    $line = $tokens[$first]['line'];
1099
-                    $type = $tokens[$first]['type'];
1100
-                    echo "\t* first token is $first ($type) on line $line *".PHP_EOL;
1096
+                $first = $phpcsFile->findFirstOnLine( T_WHITESPACE, $i, true );
1097
+                if ( $this->debug === true ) {
1098
+                    $line = $tokens[ $first ][ 'line' ];
1099
+                    $type = $tokens[ $first ][ 'type' ];
1100
+                    echo "\t* first token is $first ($type) on line $line *" . PHP_EOL;
1101 1101
                 }
1102 1102
 
1103
-                while ($tokens[$first]['code'] === T_CONSTANT_ENCAPSED_STRING
1104
-                    && $tokens[($first - 1)]['code'] === T_CONSTANT_ENCAPSED_STRING
1103
+                while ( $tokens[ $first ][ 'code' ] === T_CONSTANT_ENCAPSED_STRING
1104
+                    && $tokens[ ( $first - 1 ) ][ 'code' ] === T_CONSTANT_ENCAPSED_STRING
1105 1105
                 ) {
1106
-                    $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, ($first - 1), true);
1107
-                    if ($this->debug === true) {
1108
-                        $line = $tokens[$first]['line'];
1109
-                        $type = $tokens[$first]['type'];
1110
-                        echo "\t* found multi-line string; amended first token is $first ($type) on line $line *".PHP_EOL;
1106
+                    $first = $phpcsFile->findFirstOnLine( T_WHITESPACE, ( $first - 1 ), true );
1107
+                    if ( $this->debug === true ) {
1108
+                        $line = $tokens[ $first ][ 'line' ];
1109
+                        $type = $tokens[ $first ][ 'type' ];
1110
+                        echo "\t* found multi-line string; amended first token is $first ($type) on line $line *" . PHP_EOL;
1111 1111
                     }
1112 1112
                 }
1113 1113
 
1114
-                $currentIndent = (($tokens[$first]['column'] - 1) + $this->indent);
1115
-                $openScopes[$tokens[$i]['scope_closer']] = $tokens[$i]['scope_condition'];
1116
-                if ($this->debug === true) {
1117
-                    $closerToken    = $tokens[$i]['scope_closer'];
1118
-                    $closerLine     = $tokens[$closerToken]['line'];
1119
-                    $closerType     = $tokens[$closerToken]['type'];
1120
-                    $conditionToken = $tokens[$i]['scope_condition'];
1121
-                    $conditionLine  = $tokens[$conditionToken]['line'];
1122
-                    $conditionType  = $tokens[$conditionToken]['type'];
1123
-                    echo "\t=> added open scope $closerToken ($closerType) on line $closerLine, pointing to condition $conditionToken ($conditionType) on line $conditionLine".PHP_EOL;
1114
+                $currentIndent = ( ( $tokens[ $first ][ 'column' ] - 1 ) + $this->indent );
1115
+                $openScopes[ $tokens[ $i ][ 'scope_closer' ] ] = $tokens[ $i ][ 'scope_condition' ];
1116
+                if ( $this->debug === true ) {
1117
+                    $closerToken    = $tokens[ $i ][ 'scope_closer' ];
1118
+                    $closerLine     = $tokens[ $closerToken ][ 'line' ];
1119
+                    $closerType     = $tokens[ $closerToken ][ 'type' ];
1120
+                    $conditionToken = $tokens[ $i ][ 'scope_condition' ];
1121
+                    $conditionLine  = $tokens[ $conditionToken ][ 'line' ];
1122
+                    $conditionType  = $tokens[ $conditionToken ][ 'type' ];
1123
+                    echo "\t=> added open scope $closerToken ($closerType) on line $closerLine, pointing to condition $conditionToken ($conditionType) on line $conditionLine" . PHP_EOL;
1124 1124
                 }
1125 1125
 
1126
-                if (isset($adjustments[$first]) === true) {
1127
-                    $currentIndent += $adjustments[$first];
1126
+                if ( isset( $adjustments[ $first ] ) === true ) {
1127
+                    $currentIndent += $adjustments[ $first ];
1128 1128
                 }
1129 1129
 
1130 1130
                 // Make sure it is divisible by our expected indent.
1131
-                $currentIndent = (int) (floor($currentIndent / $this->indent) * $this->indent);
1132
-                $i = $tokens[$i]['scope_opener'];
1133
-                $setIndents[$i] = $currentIndent;
1131
+                $currentIndent = (int)( floor( $currentIndent / $this->indent ) * $this->indent );
1132
+                $i = $tokens[ $i ][ 'scope_opener' ];
1133
+                $setIndents[ $i ] = $currentIndent;
1134 1134
 
1135
-                if ($this->debug === true) {
1136
-                    $type = $tokens[$i]['type'];
1137
-                    echo "\t=> indent set to $currentIndent by token $i ($type)".PHP_EOL;
1135
+                if ( $this->debug === true ) {
1136
+                    $type = $tokens[ $i ][ 'type' ];
1137
+                    echo "\t=> indent set to $currentIndent by token $i ($type)" . PHP_EOL;
1138 1138
                 }
1139 1139
 
1140 1140
                 continue;
1141 1141
             }//end if
1142 1142
 
1143 1143
             // Scope openers increase the indent level.
1144
-            if (isset($tokens[$i]['scope_condition']) === true
1145
-                && isset($tokens[$i]['scope_opener']) === true
1146
-                && $tokens[$i]['scope_opener'] === $i
1144
+            if ( isset( $tokens[ $i ][ 'scope_condition' ] ) === true
1145
+                && isset( $tokens[ $i ][ 'scope_opener' ] ) === true
1146
+                && $tokens[ $i ][ 'scope_opener' ] === $i
1147 1147
             ) {
1148
-                $closer = $tokens[$i]['scope_closer'];
1149
-                if ($tokens[$i]['line'] === $tokens[$closer]['line']) {
1150
-                    if ($this->debug === true) {
1151
-                        $line = $tokens[$i]['line'];
1152
-                        $type = $tokens[$i]['type'];
1153
-                        echo "* ignoring single-line $type on line $line".PHP_EOL;
1148
+                $closer = $tokens[ $i ][ 'scope_closer' ];
1149
+                if ( $tokens[ $i ][ 'line' ] === $tokens[ $closer ][ 'line' ] ) {
1150
+                    if ( $this->debug === true ) {
1151
+                        $line = $tokens[ $i ][ 'line' ];
1152
+                        $type = $tokens[ $i ][ 'type' ];
1153
+                        echo "* ignoring single-line $type on line $line" . PHP_EOL;
1154 1154
                     }
1155 1155
 
1156 1156
                     $i = $closer;
1157 1157
                     continue;
1158 1158
                 }
1159 1159
 
1160
-                $condition = $tokens[$tokens[$i]['scope_condition']]['code'];
1161
-                if (isset(Tokens::$scopeOpeners[$condition]) === true
1162
-                    && in_array($condition, $this->nonIndentingScopes, true) === false
1160
+                $condition = $tokens[ $tokens[ $i ][ 'scope_condition' ] ][ 'code' ];
1161
+                if ( isset( Tokens::$scopeOpeners[ $condition ] ) === true
1162
+                    && in_array( $condition, $this->nonIndentingScopes, true ) === false
1163 1163
                 ) {
1164
-                    if ($this->debug === true) {
1165
-                        $line = $tokens[$i]['line'];
1166
-                        $type = $tokens[$tokens[$i]['scope_condition']]['type'];
1167
-                        echo "Open scope ($type) on line $line".PHP_EOL;
1164
+                    if ( $this->debug === true ) {
1165
+                        $line = $tokens[ $i ][ 'line' ];
1166
+                        $type = $tokens[ $tokens[ $i ][ 'scope_condition' ] ][ 'type' ];
1167
+                        echo "Open scope ($type) on line $line" . PHP_EOL;
1168 1168
                     }
1169 1169
 
1170 1170
                     $currentIndent += $this->indent;
1171
-                    $setIndents[$i] = $currentIndent;
1172
-                    $openScopes[$tokens[$i]['scope_closer']] = $tokens[$i]['scope_condition'];
1173
-                    if ($this->debug === true) {
1174
-                        $closerToken    = $tokens[$i]['scope_closer'];
1175
-                        $closerLine     = $tokens[$closerToken]['line'];
1176
-                        $closerType     = $tokens[$closerToken]['type'];
1177
-                        $conditionToken = $tokens[$i]['scope_condition'];
1178
-                        $conditionLine  = $tokens[$conditionToken]['line'];
1179
-                        $conditionType  = $tokens[$conditionToken]['type'];
1180
-                        echo "\t=> added open scope $closerToken ($closerType) on line $closerLine, pointing to condition $conditionToken ($conditionType) on line $conditionLine".PHP_EOL;
1171
+                    $setIndents[ $i ] = $currentIndent;
1172
+                    $openScopes[ $tokens[ $i ][ 'scope_closer' ] ] = $tokens[ $i ][ 'scope_condition' ];
1173
+                    if ( $this->debug === true ) {
1174
+                        $closerToken    = $tokens[ $i ][ 'scope_closer' ];
1175
+                        $closerLine     = $tokens[ $closerToken ][ 'line' ];
1176
+                        $closerType     = $tokens[ $closerToken ][ 'type' ];
1177
+                        $conditionToken = $tokens[ $i ][ 'scope_condition' ];
1178
+                        $conditionLine  = $tokens[ $conditionToken ][ 'line' ];
1179
+                        $conditionType  = $tokens[ $conditionToken ][ 'type' ];
1180
+                        echo "\t=> added open scope $closerToken ($closerType) on line $closerLine, pointing to condition $conditionToken ($conditionType) on line $conditionLine" . PHP_EOL;
1181 1181
                     }
1182 1182
 
1183
-                    if ($this->debug === true) {
1184
-                        $type = $tokens[$i]['type'];
1185
-                        echo "\t=> indent set to $currentIndent by token $i ($type)".PHP_EOL;
1183
+                    if ( $this->debug === true ) {
1184
+                        $type = $tokens[ $i ][ 'type' ];
1185
+                        echo "\t=> indent set to $currentIndent by token $i ($type)" . PHP_EOL;
1186 1186
                     }
1187 1187
 
1188 1188
                     continue;
@@ -1190,120 +1190,120 @@  discard block
 block discarded – undo
1190 1190
             }//end if
1191 1191
 
1192 1192
             // JS objects set the indent level.
1193
-            if ($phpcsFile->tokenizerType === 'JS'
1194
-                && $tokens[$i]['code'] === T_OBJECT
1193
+            if ( $phpcsFile->tokenizerType === 'JS'
1194
+                && $tokens[ $i ][ 'code' ] === T_OBJECT
1195 1195
             ) {
1196
-                $closer = $tokens[$i]['bracket_closer'];
1197
-                if ($tokens[$i]['line'] === $tokens[$closer]['line']) {
1198
-                    if ($this->debug === true) {
1199
-                        $line = $tokens[$i]['line'];
1200
-                        echo "* ignoring single-line JS object on line $line".PHP_EOL;
1196
+                $closer = $tokens[ $i ][ 'bracket_closer' ];
1197
+                if ( $tokens[ $i ][ 'line' ] === $tokens[ $closer ][ 'line' ] ) {
1198
+                    if ( $this->debug === true ) {
1199
+                        $line = $tokens[ $i ][ 'line' ];
1200
+                        echo "* ignoring single-line JS object on line $line" . PHP_EOL;
1201 1201
                     }
1202 1202
 
1203 1203
                     $i = $closer;
1204 1204
                     continue;
1205 1205
                 }
1206 1206
 
1207
-                if ($this->debug === true) {
1208
-                    $line = $tokens[$i]['line'];
1209
-                    echo "Open JS object on line $line".PHP_EOL;
1207
+                if ( $this->debug === true ) {
1208
+                    $line = $tokens[ $i ][ 'line' ];
1209
+                    echo "Open JS object on line $line" . PHP_EOL;
1210 1210
                 }
1211 1211
 
1212
-                $first         = $phpcsFile->findFirstOnLine(T_WHITESPACE, $i, true);
1213
-                $currentIndent = (($tokens[$first]['column'] - 1) + $this->indent);
1214
-                if (isset($adjustments[$first]) === true) {
1215
-                    $currentIndent += $adjustments[$first];
1212
+                $first         = $phpcsFile->findFirstOnLine( T_WHITESPACE, $i, true );
1213
+                $currentIndent = ( ( $tokens[ $first ][ 'column' ] - 1 ) + $this->indent );
1214
+                if ( isset( $adjustments[ $first ] ) === true ) {
1215
+                    $currentIndent += $adjustments[ $first ];
1216 1216
                 }
1217 1217
 
1218 1218
                 // Make sure it is divisible by our expected indent.
1219
-                $currentIndent      = (int) (ceil($currentIndent / $this->indent) * $this->indent);
1220
-                $setIndents[$first] = $currentIndent;
1219
+                $currentIndent      = (int)( ceil( $currentIndent / $this->indent ) * $this->indent );
1220
+                $setIndents[ $first ] = $currentIndent;
1221 1221
 
1222
-                if ($this->debug === true) {
1223
-                    $type = $tokens[$first]['type'];
1224
-                    echo "\t=> indent set to $currentIndent by token $first ($type)".PHP_EOL;
1222
+                if ( $this->debug === true ) {
1223
+                    $type = $tokens[ $first ][ 'type' ];
1224
+                    echo "\t=> indent set to $currentIndent by token $first ($type)" . PHP_EOL;
1225 1225
                 }
1226 1226
 
1227 1227
                 continue;
1228 1228
             }//end if
1229 1229
 
1230 1230
             // Closing an anon class or function.
1231
-            if (isset($tokens[$i]['scope_condition']) === true
1232
-                && $tokens[$i]['scope_closer'] === $i
1233
-                && ($tokens[$tokens[$i]['scope_condition']]['code'] === T_CLOSURE
1234
-                || $tokens[$tokens[$i]['scope_condition']]['code'] === T_ANON_CLASS)
1231
+            if ( isset( $tokens[ $i ][ 'scope_condition' ] ) === true
1232
+                && $tokens[ $i ][ 'scope_closer' ] === $i
1233
+                && ( $tokens[ $tokens[ $i ][ 'scope_condition' ] ][ 'code' ] === T_CLOSURE
1234
+                || $tokens[ $tokens[ $i ][ 'scope_condition' ] ][ 'code' ] === T_ANON_CLASS )
1235 1235
             ) {
1236
-                if ($this->debug === true) {
1237
-                    $type = str_replace('_', ' ', strtolower(substr($tokens[$tokens[$i]['scope_condition']]['type'], 2)));
1238
-                    $line = $tokens[$i]['line'];
1239
-                    echo "Close $type on line $line".PHP_EOL;
1236
+                if ( $this->debug === true ) {
1237
+                    $type = str_replace( '_', ' ', strtolower( substr( $tokens[ $tokens[ $i ][ 'scope_condition' ] ][ 'type' ], 2 ) ) );
1238
+                    $line = $tokens[ $i ][ 'line' ];
1239
+                    echo "Close $type on line $line" . PHP_EOL;
1240 1240
                 }
1241 1241
 
1242 1242
                 $prev = false;
1243 1243
 
1244 1244
                 $object = 0;
1245
-                if ($phpcsFile->tokenizerType === 'JS') {
1246
-                    $conditions = $tokens[$i]['conditions'];
1247
-                    krsort($conditions, SORT_NUMERIC);
1248
-                    foreach ($conditions as $token => $condition) {
1249
-                        if ($condition === T_OBJECT) {
1245
+                if ( $phpcsFile->tokenizerType === 'JS' ) {
1246
+                    $conditions = $tokens[ $i ][ 'conditions' ];
1247
+                    krsort( $conditions, SORT_NUMERIC );
1248
+                    foreach ( $conditions as $token => $condition ) {
1249
+                        if ( $condition === T_OBJECT ) {
1250 1250
                             $object = $token;
1251 1251
                             break;
1252 1252
                         }
1253 1253
                     }
1254 1254
 
1255
-                    if ($this->debug === true && $object !== 0) {
1256
-                        $line = $tokens[$object]['line'];
1257
-                        echo "\t* token is inside JS object $object on line $line *".PHP_EOL;
1255
+                    if ( $this->debug === true && $object !== 0 ) {
1256
+                        $line = $tokens[ $object ][ 'line' ];
1257
+                        echo "\t* token is inside JS object $object on line $line *" . PHP_EOL;
1258 1258
                     }
1259 1259
                 }
1260 1260
 
1261 1261
                 $parens = 0;
1262
-                if (isset($tokens[$i]['nested_parenthesis']) === true
1263
-                    && empty($tokens[$i]['nested_parenthesis']) === false
1262
+                if ( isset( $tokens[ $i ][ 'nested_parenthesis' ] ) === true
1263
+                    && empty( $tokens[ $i ][ 'nested_parenthesis' ] ) === false
1264 1264
                 ) {
1265
-                    $parens = $tokens[$i]['nested_parenthesis'];
1266
-                    end($parens);
1267
-                    $parens = key($parens);
1268
-                    if ($this->debug === true) {
1269
-                        $line = $tokens[$parens]['line'];
1270
-                        echo "\t* token has nested parenthesis $parens on line $line *".PHP_EOL;
1265
+                    $parens = $tokens[ $i ][ 'nested_parenthesis' ];
1266
+                    end( $parens );
1267
+                    $parens = key( $parens );
1268
+                    if ( $this->debug === true ) {
1269
+                        $line = $tokens[ $parens ][ 'line' ];
1270
+                        echo "\t* token has nested parenthesis $parens on line $line *" . PHP_EOL;
1271 1271
                     }
1272 1272
                 }
1273 1273
 
1274 1274
                 $condition = 0;
1275
-                if (isset($tokens[$i]['conditions']) === true
1276
-                    && empty($tokens[$i]['conditions']) === false
1275
+                if ( isset( $tokens[ $i ][ 'conditions' ] ) === true
1276
+                    && empty( $tokens[ $i ][ 'conditions' ] ) === false
1277 1277
                 ) {
1278
-                    $condition = $tokens[$i]['conditions'];
1279
-                    end($condition);
1280
-                    $condition = key($condition);
1281
-                    if ($this->debug === true) {
1282
-                        $line = $tokens[$condition]['line'];
1283
-                        $type = $tokens[$condition]['type'];
1284
-                        echo "\t* token is inside condition $condition ($type) on line $line *".PHP_EOL;
1278
+                    $condition = $tokens[ $i ][ 'conditions' ];
1279
+                    end( $condition );
1280
+                    $condition = key( $condition );
1281
+                    if ( $this->debug === true ) {
1282
+                        $line = $tokens[ $condition ][ 'line' ];
1283
+                        $type = $tokens[ $condition ][ 'type' ];
1284
+                        echo "\t* token is inside condition $condition ($type) on line $line *" . PHP_EOL;
1285 1285
                     }
1286 1286
                 }
1287 1287
 
1288
-                if ($parens > $object && $parens > $condition) {
1289
-                    if ($this->debug === true) {
1290
-                        echo "\t* using parenthesis *".PHP_EOL;
1288
+                if ( $parens > $object && $parens > $condition ) {
1289
+                    if ( $this->debug === true ) {
1290
+                        echo "\t* using parenthesis *" . PHP_EOL;
1291 1291
                     }
1292 1292
 
1293
-                    $prev      = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($parens - 1), null, true);
1293
+                    $prev      = $phpcsFile->findPrevious( Tokens::$emptyTokens, ( $parens - 1 ), null, true );
1294 1294
                     $object    = 0;
1295 1295
                     $condition = 0;
1296
-                } else if ($object > 0 && $object >= $condition) {
1297
-                    if ($this->debug === true) {
1298
-                        echo "\t* using object *".PHP_EOL;
1296
+                } else if ( $object > 0 && $object >= $condition ) {
1297
+                    if ( $this->debug === true ) {
1298
+                        echo "\t* using object *" . PHP_EOL;
1299 1299
                     }
1300 1300
 
1301 1301
                     $prev      = $object;
1302 1302
                     $parens    = 0;
1303 1303
                     $condition = 0;
1304
-                } else if ($condition > 0) {
1305
-                    if ($this->debug === true) {
1306
-                        echo "\t* using condition *".PHP_EOL;
1304
+                } else if ( $condition > 0 ) {
1305
+                    if ( $this->debug === true ) {
1306
+                        echo "\t* using condition *" . PHP_EOL;
1307 1307
                     }
1308 1308
 
1309 1309
                     $prev   = $condition;
@@ -1311,72 +1311,72 @@  discard block
 block discarded – undo
1311 1311
                     $parens = 0;
1312 1312
                 }//end if
1313 1313
 
1314
-                if ($prev === false) {
1315
-                    $prev = $phpcsFile->findPrevious([T_EQUAL, T_RETURN], ($tokens[$i]['scope_condition'] - 1), null, false, null, true);
1316
-                    if ($prev === false) {
1314
+                if ( $prev === false ) {
1315
+                    $prev = $phpcsFile->findPrevious( [ T_EQUAL, T_RETURN ], ( $tokens[ $i ][ 'scope_condition' ] - 1 ), null, false, null, true );
1316
+                    if ( $prev === false ) {
1317 1317
                         $prev = $i;
1318
-                        if ($this->debug === true) {
1319
-                            echo "\t* could not find a previous T_EQUAL or T_RETURN token; will use current token *".PHP_EOL;
1318
+                        if ( $this->debug === true ) {
1319
+                            echo "\t* could not find a previous T_EQUAL or T_RETURN token; will use current token *" . PHP_EOL;
1320 1320
                         }
1321 1321
                     }
1322 1322
                 }
1323 1323
 
1324
-                if ($this->debug === true) {
1325
-                    $line = $tokens[$prev]['line'];
1326
-                    $type = $tokens[$prev]['type'];
1327
-                    echo "\t* previous token is $type on line $line *".PHP_EOL;
1324
+                if ( $this->debug === true ) {
1325
+                    $line = $tokens[ $prev ][ 'line' ];
1326
+                    $type = $tokens[ $prev ][ 'type' ];
1327
+                    echo "\t* previous token is $type on line $line *" . PHP_EOL;
1328 1328
                 }
1329 1329
 
1330
-                $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $prev, true);
1331
-                if ($this->debug === true) {
1332
-                    $line = $tokens[$first]['line'];
1333
-                    $type = $tokens[$first]['type'];
1334
-                    echo "\t* first token on line $line is $first ($type) *".PHP_EOL;
1330
+                $first = $phpcsFile->findFirstOnLine( T_WHITESPACE, $prev, true );
1331
+                if ( $this->debug === true ) {
1332
+                    $line = $tokens[ $first ][ 'line' ];
1333
+                    $type = $tokens[ $first ][ 'type' ];
1334
+                    echo "\t* first token on line $line is $first ($type) *" . PHP_EOL;
1335 1335
                 }
1336 1336
 
1337
-                $prev = $phpcsFile->findStartOfStatement($first);
1338
-                if ($prev !== $first) {
1337
+                $prev = $phpcsFile->findStartOfStatement( $first );
1338
+                if ( $prev !== $first ) {
1339 1339
                     // This is not the start of the statement.
1340
-                    if ($this->debug === true) {
1341
-                        $line = $tokens[$prev]['line'];
1342
-                        $type = $tokens[$prev]['type'];
1343
-                        echo "\t* amended previous is $type on line $line *".PHP_EOL;
1340
+                    if ( $this->debug === true ) {
1341
+                        $line = $tokens[ $prev ][ 'line' ];
1342
+                        $type = $tokens[ $prev ][ 'type' ];
1343
+                        echo "\t* amended previous is $type on line $line *" . PHP_EOL;
1344 1344
                     }
1345 1345
 
1346
-                    $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $prev, true);
1347
-                    if ($this->debug === true) {
1348
-                        $line = $tokens[$first]['line'];
1349
-                        $type = $tokens[$first]['type'];
1350
-                        echo "\t* amended first token is $first ($type) on line $line *".PHP_EOL;
1346
+                    $first = $phpcsFile->findFirstOnLine( T_WHITESPACE, $prev, true );
1347
+                    if ( $this->debug === true ) {
1348
+                        $line = $tokens[ $first ][ 'line' ];
1349
+                        $type = $tokens[ $first ][ 'type' ];
1350
+                        echo "\t* amended first token is $first ($type) on line $line *" . PHP_EOL;
1351 1351
                     }
1352 1352
                 }
1353 1353
 
1354
-                $currentIndent = ($tokens[$first]['column'] - 1);
1355
-                if ($object > 0 || $condition > 0) {
1354
+                $currentIndent = ( $tokens[ $first ][ 'column' ] - 1 );
1355
+                if ( $object > 0 || $condition > 0 ) {
1356 1356
                     $currentIndent += $this->indent;
1357 1357
                 }
1358 1358
 
1359
-                if (isset($tokens[$first]['scope_closer']) === true
1360
-                    && $tokens[$first]['scope_closer'] === $first
1359
+                if ( isset( $tokens[ $first ][ 'scope_closer' ] ) === true
1360
+                    && $tokens[ $first ][ 'scope_closer' ] === $first
1361 1361
                 ) {
1362
-                    if ($this->debug === true) {
1363
-                        echo "\t* first token is a scope closer *".PHP_EOL;
1362
+                    if ( $this->debug === true ) {
1363
+                        echo "\t* first token is a scope closer *" . PHP_EOL;
1364 1364
                     }
1365 1365
 
1366
-                    if ($condition === 0 || $tokens[$condition]['scope_opener'] < $first) {
1367
-                        $currentIndent = $setIndents[$first];
1368
-                    } else if ($this->debug === true) {
1369
-                        echo "\t* ignoring scope closer *".PHP_EOL;
1366
+                    if ( $condition === 0 || $tokens[ $condition ][ 'scope_opener' ] < $first ) {
1367
+                        $currentIndent = $setIndents[ $first ];
1368
+                    } else if ( $this->debug === true ) {
1369
+                        echo "\t* ignoring scope closer *" . PHP_EOL;
1370 1370
                     }
1371 1371
                 }
1372 1372
 
1373 1373
                 // Make sure it is divisible by our expected indent.
1374
-                $currentIndent      = (int) (ceil($currentIndent / $this->indent) * $this->indent);
1375
-                $setIndents[$first] = $currentIndent;
1374
+                $currentIndent      = (int)( ceil( $currentIndent / $this->indent ) * $this->indent );
1375
+                $setIndents[ $first ] = $currentIndent;
1376 1376
 
1377
-                if ($this->debug === true) {
1378
-                    $type = $tokens[$first]['type'];
1379
-                    echo "\t=> indent set to $currentIndent by token $first ($type)".PHP_EOL;
1377
+                if ( $this->debug === true ) {
1378
+                    $type = $tokens[ $first ][ 'type' ];
1379
+                    echo "\t=> indent set to $currentIndent by token $first ($type)" . PHP_EOL;
1380 1380
                 }
1381 1381
             }//end if
1382 1382
         }//end for
@@ -1399,72 +1399,72 @@  discard block
 block discarded – undo
1399 1399
      *
1400 1400
      * @return bool
1401 1401
      */
1402
-    protected function adjustIndent(File $phpcsFile, $stackPtr, $length, $change)
1402
+    protected function adjustIndent( File $phpcsFile, $stackPtr, $length, $change )
1403 1403
     {
1404 1404
         $tokens = $phpcsFile->getTokens();
1405 1405
 
1406 1406
         // We don't adjust indents outside of PHP.
1407
-        if ($tokens[$stackPtr]['code'] === T_INLINE_HTML) {
1407
+        if ( $tokens[ $stackPtr ][ 'code' ] === T_INLINE_HTML ) {
1408 1408
             return false;
1409 1409
         }
1410 1410
 
1411 1411
         $padding = '';
1412
-        if ($length > 0) {
1413
-            if ($this->tabIndent === true) {
1414
-                $numTabs = floor($length / $this->tabWidth);
1415
-                if ($numTabs > 0) {
1416
-                    $numSpaces = ($length - ($numTabs * $this->tabWidth));
1417
-                    $padding   = str_repeat("\t", $numTabs).str_repeat(' ', $numSpaces);
1412
+        if ( $length > 0 ) {
1413
+            if ( $this->tabIndent === true ) {
1414
+                $numTabs = floor( $length / $this->tabWidth );
1415
+                if ( $numTabs > 0 ) {
1416
+                    $numSpaces = ( $length - ( $numTabs * $this->tabWidth ) );
1417
+                    $padding   = str_repeat( "\t", $numTabs ) . str_repeat( ' ', $numSpaces );
1418 1418
                 }
1419 1419
             } else {
1420
-                $padding = str_repeat(' ', $length);
1420
+                $padding = str_repeat( ' ', $length );
1421 1421
             }
1422 1422
         }
1423 1423
 
1424
-        if ($tokens[$stackPtr]['column'] === 1) {
1425
-            $trimmed  = ltrim($tokens[$stackPtr]['content']);
1426
-            $accepted = $phpcsFile->fixer->replaceToken($stackPtr, $padding.$trimmed);
1424
+        if ( $tokens[ $stackPtr ][ 'column' ] === 1 ) {
1425
+            $trimmed  = ltrim( $tokens[ $stackPtr ][ 'content' ] );
1426
+            $accepted = $phpcsFile->fixer->replaceToken( $stackPtr, $padding . $trimmed );
1427 1427
         } else {
1428 1428
             // Easier to just replace the entire indent.
1429
-            $accepted = $phpcsFile->fixer->replaceToken(($stackPtr - 1), $padding);
1429
+            $accepted = $phpcsFile->fixer->replaceToken( ( $stackPtr - 1 ), $padding );
1430 1430
         }
1431 1431
 
1432
-        if ($accepted === false) {
1432
+        if ( $accepted === false ) {
1433 1433
             return false;
1434 1434
         }
1435 1435
 
1436
-        if ($tokens[$stackPtr]['code'] === T_DOC_COMMENT_OPEN_TAG) {
1436
+        if ( $tokens[ $stackPtr ][ 'code' ] === T_DOC_COMMENT_OPEN_TAG ) {
1437 1437
             // We adjusted the start of a comment, so adjust the rest of it
1438 1438
             // as well so the alignment remains correct.
1439
-            for ($x = ($stackPtr + 1); $x < $tokens[$stackPtr]['comment_closer']; $x++) {
1440
-                if ($tokens[$x]['column'] !== 1) {
1439
+            for ( $x = ( $stackPtr + 1 ); $x < $tokens[ $stackPtr ][ 'comment_closer' ]; $x++ ) {
1440
+                if ( $tokens[ $x ][ 'column' ] !== 1 ) {
1441 1441
                     continue;
1442 1442
                 }
1443 1443
 
1444 1444
                 $length = 0;
1445
-                if ($tokens[$x]['code'] === T_DOC_COMMENT_WHITESPACE) {
1446
-                    $length = $tokens[$x]['length'];
1445
+                if ( $tokens[ $x ][ 'code' ] === T_DOC_COMMENT_WHITESPACE ) {
1446
+                    $length = $tokens[ $x ][ 'length' ];
1447 1447
                 }
1448 1448
 
1449
-                $padding = ($length + $change);
1450
-                if ($padding > 0) {
1451
-                    if ($this->tabIndent === true) {
1452
-                        $numTabs   = floor($padding / $this->tabWidth);
1453
-                        $numSpaces = ($padding - ($numTabs * $this->tabWidth));
1454
-                        $padding   = str_repeat("\t", $numTabs).str_repeat(' ', $numSpaces);
1449
+                $padding = ( $length + $change );
1450
+                if ( $padding > 0 ) {
1451
+                    if ( $this->tabIndent === true ) {
1452
+                        $numTabs   = floor( $padding / $this->tabWidth );
1453
+                        $numSpaces = ( $padding - ( $numTabs * $this->tabWidth ) );
1454
+                        $padding   = str_repeat( "\t", $numTabs ) . str_repeat( ' ', $numSpaces );
1455 1455
                     } else {
1456
-                        $padding = str_repeat(' ', $padding);
1456
+                        $padding = str_repeat( ' ', $padding );
1457 1457
                     }
1458 1458
                 } else {
1459 1459
                     $padding = '';
1460 1460
                 }
1461 1461
 
1462
-                $phpcsFile->fixer->replaceToken($x, $padding);
1463
-                if ($this->debug === true) {
1464
-                    $length = strlen($padding);
1465
-                    $line   = $tokens[$x]['line'];
1466
-                    $type   = $tokens[$x]['type'];
1467
-                    echo "\t=> Indent adjusted to $length for $type on line $line".PHP_EOL;
1462
+                $phpcsFile->fixer->replaceToken( $x, $padding );
1463
+                if ( $this->debug === true ) {
1464
+                    $length = strlen( $padding );
1465
+                    $line   = $tokens[ $x ][ 'line' ];
1466
+                    $type   = $tokens[ $x ][ 'type' ];
1467
+                    echo "\t=> Indent adjusted to $length for $type on line $line" . PHP_EOL;
1468 1468
                 }
1469 1469
             }//end for
1470 1470
         }//end if
Please login to merge, or discard this patch.
Standards/Generic/Sniffs/WhiteSpace/ArbitraryParenthesesSpacingSniff.php 1 patch
Spacing   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
      *
40 40
      * @var array
41 41
      */
42
-    private $ignoreTokens = [];
42
+    private $ignoreTokens = [ ];
43 43
 
44 44
 
45 45
     /**
@@ -51,20 +51,20 @@  discard block
 block discarded – undo
51 51
     {
52 52
         $this->ignoreTokens = Tokens::$functionNameTokens;
53 53
 
54
-        $this->ignoreTokens[T_VARIABLE]            = T_VARIABLE;
55
-        $this->ignoreTokens[T_CLOSE_PARENTHESIS]   = T_CLOSE_PARENTHESIS;
56
-        $this->ignoreTokens[T_CLOSE_CURLY_BRACKET] = T_CLOSE_CURLY_BRACKET;
57
-        $this->ignoreTokens[T_CLOSE_SQUARE_BRACKET] = T_CLOSE_SQUARE_BRACKET;
58
-        $this->ignoreTokens[T_CLOSE_SHORT_ARRAY]    = T_CLOSE_SHORT_ARRAY;
59
-
60
-        $this->ignoreTokens[T_ANON_CLASS] = T_ANON_CLASS;
61
-        $this->ignoreTokens[T_USE]        = T_USE;
62
-        $this->ignoreTokens[T_LIST]       = T_LIST;
63
-        $this->ignoreTokens[T_DECLARE]    = T_DECLARE;
64
-        $this->ignoreTokens[T_THROW]      = T_THROW;
65
-        $this->ignoreTokens[T_YIELD]      = T_YIELD;
66
-        $this->ignoreTokens[T_YIELD_FROM] = T_YIELD_FROM;
67
-        $this->ignoreTokens[T_CLONE]      = T_CLONE;
54
+        $this->ignoreTokens[ T_VARIABLE ]            = T_VARIABLE;
55
+        $this->ignoreTokens[ T_CLOSE_PARENTHESIS ]   = T_CLOSE_PARENTHESIS;
56
+        $this->ignoreTokens[ T_CLOSE_CURLY_BRACKET ] = T_CLOSE_CURLY_BRACKET;
57
+        $this->ignoreTokens[ T_CLOSE_SQUARE_BRACKET ] = T_CLOSE_SQUARE_BRACKET;
58
+        $this->ignoreTokens[ T_CLOSE_SHORT_ARRAY ]    = T_CLOSE_SHORT_ARRAY;
59
+
60
+        $this->ignoreTokens[ T_ANON_CLASS ] = T_ANON_CLASS;
61
+        $this->ignoreTokens[ T_USE ]        = T_USE;
62
+        $this->ignoreTokens[ T_LIST ]       = T_LIST;
63
+        $this->ignoreTokens[ T_DECLARE ]    = T_DECLARE;
64
+        $this->ignoreTokens[ T_THROW ]      = T_THROW;
65
+        $this->ignoreTokens[ T_YIELD ]      = T_YIELD;
66
+        $this->ignoreTokens[ T_YIELD_FROM ] = T_YIELD_FROM;
67
+        $this->ignoreTokens[ T_CLONE ]      = T_CLONE;
68 68
 
69 69
         return [
70 70
             T_OPEN_PARENTHESIS,
@@ -83,150 +83,150 @@  discard block
 block discarded – undo
83 83
      *
84 84
      * @return void
85 85
      */
86
-    public function process(File $phpcsFile, $stackPtr)
86
+    public function process( File $phpcsFile, $stackPtr )
87 87
     {
88 88
         $tokens = $phpcsFile->getTokens();
89 89
 
90
-        if (isset($tokens[$stackPtr]['parenthesis_owner']) === true) {
90
+        if ( isset( $tokens[ $stackPtr ][ 'parenthesis_owner' ] ) === true ) {
91 91
             // This parenthesis is owned by a function/control structure etc.
92 92
             return;
93 93
         }
94 94
 
95 95
         // More checking for the type of parenthesis we *don't* want to handle.
96 96
         $opener = $stackPtr;
97
-        if ($tokens[$stackPtr]['code'] === T_CLOSE_PARENTHESIS) {
98
-            if (isset($tokens[$stackPtr]['parenthesis_opener']) === false) {
97
+        if ( $tokens[ $stackPtr ][ 'code' ] === T_CLOSE_PARENTHESIS ) {
98
+            if ( isset( $tokens[ $stackPtr ][ 'parenthesis_opener' ] ) === false ) {
99 99
                 // Parse error.
100 100
                 return;
101 101
             }
102 102
 
103
-            $opener = $tokens[$stackPtr]['parenthesis_opener'];
103
+            $opener = $tokens[ $stackPtr ][ 'parenthesis_opener' ];
104 104
         }
105 105
 
106
-        $preOpener = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($opener - 1), null, true);
107
-        if ($preOpener !== false && isset($this->ignoreTokens[$tokens[$preOpener]['code']]) === true) {
106
+        $preOpener = $phpcsFile->findPrevious( Tokens::$emptyTokens, ( $opener - 1 ), null, true );
107
+        if ( $preOpener !== false && isset( $this->ignoreTokens[ $tokens[ $preOpener ][ 'code' ] ] ) === true ) {
108 108
             // Function or language construct call.
109 109
             return;
110 110
         }
111 111
 
112 112
         // Check for empty parentheses.
113
-        if ($tokens[$stackPtr]['code'] === T_OPEN_PARENTHESIS
114
-            && isset($tokens[$stackPtr]['parenthesis_closer']) === true
113
+        if ( $tokens[ $stackPtr ][ 'code' ] === T_OPEN_PARENTHESIS
114
+            && isset( $tokens[ $stackPtr ][ 'parenthesis_closer' ] ) === true
115 115
         ) {
116
-            $nextNonEmpty = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true);
117
-            if ($nextNonEmpty === $tokens[$stackPtr]['parenthesis_closer']) {
118
-                $phpcsFile->addWarning('Empty set of arbitrary parentheses found.', $stackPtr, 'FoundEmpty');
116
+            $nextNonEmpty = $phpcsFile->findNext( T_WHITESPACE, ( $stackPtr + 1 ), null, true );
117
+            if ( $nextNonEmpty === $tokens[ $stackPtr ][ 'parenthesis_closer' ] ) {
118
+                $phpcsFile->addWarning( 'Empty set of arbitrary parentheses found.', $stackPtr, 'FoundEmpty' );
119 119
 
120
-                return ($tokens[$stackPtr]['parenthesis_closer'] + 1);
120
+                return ( $tokens[ $stackPtr ][ 'parenthesis_closer' ] + 1 );
121 121
             }
122 122
         }
123 123
 
124 124
         // Check the spacing on the inside of the parentheses.
125
-        $this->spacing = (int) $this->spacing;
125
+        $this->spacing = (int)$this->spacing;
126 126
 
127
-        if ($tokens[$stackPtr]['code'] === T_OPEN_PARENTHESIS
128
-            && isset($tokens[($stackPtr + 1)], $tokens[($stackPtr + 2)]) === true
127
+        if ( $tokens[ $stackPtr ][ 'code' ] === T_OPEN_PARENTHESIS
128
+            && isset( $tokens[ ( $stackPtr + 1 ) ], $tokens[ ( $stackPtr + 2 ) ] ) === true
129 129
         ) {
130
-            $nextToken = $tokens[($stackPtr + 1)];
130
+            $nextToken = $tokens[ ( $stackPtr + 1 ) ];
131 131
 
132
-            if ($nextToken['code'] !== T_WHITESPACE) {
132
+            if ( $nextToken[ 'code' ] !== T_WHITESPACE ) {
133 133
                 $inside = 0;
134 134
             } else {
135
-                if ($tokens[($stackPtr + 2)]['line'] !== $tokens[$stackPtr]['line']) {
135
+                if ( $tokens[ ( $stackPtr + 2 ) ][ 'line' ] !== $tokens[ $stackPtr ][ 'line' ] ) {
136 136
                     $inside = 'newline';
137 137
                 } else {
138
-                    $inside = $nextToken['length'];
138
+                    $inside = $nextToken[ 'length' ];
139 139
                 }
140 140
             }
141 141
 
142
-            if ($this->spacing !== $inside
143
-                && ($inside !== 'newline' || $this->ignoreNewlines === false)
142
+            if ( $this->spacing !== $inside
143
+                && ( $inside !== 'newline' || $this->ignoreNewlines === false )
144 144
             ) {
145 145
                 $error = 'Expected %s space after open parenthesis; %s found';
146 146
                 $data  = [
147 147
                     $this->spacing,
148 148
                     $inside,
149 149
                 ];
150
-                $fix   = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceAfterOpen', $data);
150
+                $fix = $phpcsFile->addFixableError( $error, $stackPtr, 'SpaceAfterOpen', $data );
151 151
 
152
-                if ($fix === true) {
152
+                if ( $fix === true ) {
153 153
                     $expected = '';
154
-                    if ($this->spacing > 0) {
155
-                        $expected = str_repeat(' ', $this->spacing);
154
+                    if ( $this->spacing > 0 ) {
155
+                        $expected = str_repeat( ' ', $this->spacing );
156 156
                     }
157 157
 
158
-                    if ($inside === 0) {
159
-                        if ($expected !== '') {
160
-                            $phpcsFile->fixer->addContent($stackPtr, $expected);
158
+                    if ( $inside === 0 ) {
159
+                        if ( $expected !== '' ) {
160
+                            $phpcsFile->fixer->addContent( $stackPtr, $expected );
161 161
                         }
162
-                    } else if ($inside === 'newline') {
162
+                    } else if ( $inside === 'newline' ) {
163 163
                         $phpcsFile->fixer->beginChangeset();
164
-                        for ($i = ($stackPtr + 2); $i < $phpcsFile->numTokens; $i++) {
165
-                            if ($tokens[$i]['code'] !== T_WHITESPACE) {
164
+                        for ( $i = ( $stackPtr + 2 ); $i < $phpcsFile->numTokens; $i++ ) {
165
+                            if ( $tokens[ $i ][ 'code' ] !== T_WHITESPACE ) {
166 166
                                 break;
167 167
                             }
168 168
 
169
-                            $phpcsFile->fixer->replaceToken($i, '');
169
+                            $phpcsFile->fixer->replaceToken( $i, '' );
170 170
                         }
171 171
 
172
-                        $phpcsFile->fixer->replaceToken(($stackPtr + 1), $expected);
172
+                        $phpcsFile->fixer->replaceToken( ( $stackPtr + 1 ), $expected );
173 173
                         $phpcsFile->fixer->endChangeset();
174 174
                     } else {
175
-                        $phpcsFile->fixer->replaceToken(($stackPtr + 1), $expected);
175
+                        $phpcsFile->fixer->replaceToken( ( $stackPtr + 1 ), $expected );
176 176
                     }
177 177
                 }//end if
178 178
             }//end if
179 179
         }//end if
180 180
 
181
-        if ($tokens[$stackPtr]['code'] === T_CLOSE_PARENTHESIS
182
-            && isset($tokens[($stackPtr - 1)], $tokens[($stackPtr - 2)]) === true
181
+        if ( $tokens[ $stackPtr ][ 'code' ] === T_CLOSE_PARENTHESIS
182
+            && isset( $tokens[ ( $stackPtr - 1 ) ], $tokens[ ( $stackPtr - 2 ) ] ) === true
183 183
         ) {
184
-            $prevToken = $tokens[($stackPtr - 1)];
184
+            $prevToken = $tokens[ ( $stackPtr - 1 ) ];
185 185
 
186
-            if ($prevToken['code'] !== T_WHITESPACE) {
186
+            if ( $prevToken[ 'code' ] !== T_WHITESPACE ) {
187 187
                 $inside = 0;
188 188
             } else {
189
-                if ($tokens[($stackPtr - 2)]['line'] !== $tokens[$stackPtr]['line']) {
189
+                if ( $tokens[ ( $stackPtr - 2 ) ][ 'line' ] !== $tokens[ $stackPtr ][ 'line' ] ) {
190 190
                     $inside = 'newline';
191 191
                 } else {
192
-                    $inside = $prevToken['length'];
192
+                    $inside = $prevToken[ 'length' ];
193 193
                 }
194 194
             }
195 195
 
196
-            if ($this->spacing !== $inside
197
-                && ($inside !== 'newline' || $this->ignoreNewlines === false)
196
+            if ( $this->spacing !== $inside
197
+                && ( $inside !== 'newline' || $this->ignoreNewlines === false )
198 198
             ) {
199 199
                 $error = 'Expected %s space before close parenthesis; %s found';
200 200
                 $data  = [
201 201
                     $this->spacing,
202 202
                     $inside,
203 203
                 ];
204
-                $fix   = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceBeforeClose', $data);
204
+                $fix = $phpcsFile->addFixableError( $error, $stackPtr, 'SpaceBeforeClose', $data );
205 205
 
206
-                if ($fix === true) {
206
+                if ( $fix === true ) {
207 207
                     $expected = '';
208
-                    if ($this->spacing > 0) {
209
-                        $expected = str_repeat(' ', $this->spacing);
208
+                    if ( $this->spacing > 0 ) {
209
+                        $expected = str_repeat( ' ', $this->spacing );
210 210
                     }
211 211
 
212
-                    if ($inside === 0) {
213
-                        if ($expected !== '') {
214
-                            $phpcsFile->fixer->addContentBefore($stackPtr, $expected);
212
+                    if ( $inside === 0 ) {
213
+                        if ( $expected !== '' ) {
214
+                            $phpcsFile->fixer->addContentBefore( $stackPtr, $expected );
215 215
                         }
216
-                    } else if ($inside === 'newline') {
216
+                    } else if ( $inside === 'newline' ) {
217 217
                         $phpcsFile->fixer->beginChangeset();
218
-                        for ($i = ($stackPtr - 2); $i > 0; $i--) {
219
-                            if ($tokens[$i]['code'] !== T_WHITESPACE) {
218
+                        for ( $i = ( $stackPtr - 2 ); $i > 0; $i-- ) {
219
+                            if ( $tokens[ $i ][ 'code' ] !== T_WHITESPACE ) {
220 220
                                 break;
221 221
                             }
222 222
 
223
-                            $phpcsFile->fixer->replaceToken($i, '');
223
+                            $phpcsFile->fixer->replaceToken( $i, '' );
224 224
                         }
225 225
 
226
-                        $phpcsFile->fixer->replaceToken(($stackPtr - 1), $expected);
226
+                        $phpcsFile->fixer->replaceToken( ( $stackPtr - 1 ), $expected );
227 227
                         $phpcsFile->fixer->endChangeset();
228 228
                     } else {
229
-                        $phpcsFile->fixer->replaceToken(($stackPtr - 1), $expected);
229
+                        $phpcsFile->fixer->replaceToken( ( $stackPtr - 1 ), $expected );
230 230
                     }
231 231
                 }//end if
232 232
             }//end if
Please login to merge, or discard this patch.
src/Standards/Generic/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php 1 patch
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -53,63 +53,63 @@  discard block
 block discarded – undo
53 53
      *
54 54
      * @return void
55 55
      */
56
-    public function process(File $phpcsFile, $stackPtr)
56
+    public function process( File $phpcsFile, $stackPtr )
57 57
     {
58 58
         $tokens = $phpcsFile->getTokens();
59 59
 
60
-        $nextToken = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true);
61
-        if ($nextToken === false) {
60
+        $nextToken = $phpcsFile->findNext( T_WHITESPACE, ( $stackPtr + 1 ), null, true );
61
+        if ( $nextToken === false ) {
62 62
             // Skip when at end of file.
63 63
             return;
64 64
         }
65 65
 
66
-        if ($tokens[($stackPtr + 1)]['code'] === T_SEMICOLON) {
66
+        if ( $tokens[ ( $stackPtr + 1 ) ][ 'code' ] === T_SEMICOLON ) {
67 67
             // No content for this language construct.
68 68
             return;
69 69
         }
70 70
 
71
-        $content = $tokens[$stackPtr]['content'];
72
-        if ($tokens[$stackPtr]['code'] === T_NAMESPACE) {
73
-            $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
74
-            if ($nextNonEmpty !== false && $tokens[$nextNonEmpty]['code'] === T_NS_SEPARATOR) {
71
+        $content = $tokens[ $stackPtr ][ 'content' ];
72
+        if ( $tokens[ $stackPtr ][ 'code' ] === T_NAMESPACE ) {
73
+            $nextNonEmpty = $phpcsFile->findNext( Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true );
74
+            if ( $nextNonEmpty !== false && $tokens[ $nextNonEmpty ][ 'code' ] === T_NS_SEPARATOR ) {
75 75
                 // Namespace keyword used as operator, not as the language construct.
76 76
                 return;
77 77
             }
78 78
         }
79 79
 
80
-        if ($tokens[$stackPtr]['code'] === T_YIELD_FROM
81
-            && strtolower($content) !== 'yield from'
80
+        if ( $tokens[ $stackPtr ][ 'code' ] === T_YIELD_FROM
81
+            && strtolower( $content ) !== 'yield from'
82 82
         ) {
83
-            if ($tokens[($stackPtr - 1)]['code'] === T_YIELD_FROM) {
83
+            if ( $tokens[ ( $stackPtr - 1 ) ][ 'code' ] === T_YIELD_FROM ) {
84 84
                 // A multi-line statements that has already been processed.
85 85
                 return;
86 86
             }
87 87
 
88 88
             $found = $content;
89
-            if ($tokens[($stackPtr + 1)]['code'] === T_YIELD_FROM) {
89
+            if ( $tokens[ ( $stackPtr + 1 ) ][ 'code' ] === T_YIELD_FROM ) {
90 90
                 // This yield from statement is split over multiple lines.
91
-                $i = ($stackPtr + 1);
91
+                $i = ( $stackPtr + 1 );
92 92
                 do {
93
-                    $found .= $tokens[$i]['content'];
93
+                    $found .= $tokens[ $i ][ 'content' ];
94 94
                     $i++;
95
-                } while ($tokens[$i]['code'] === T_YIELD_FROM);
95
+                } while ( $tokens[ $i ][ 'code' ] === T_YIELD_FROM );
96 96
             }
97 97
 
98 98
             $error = 'Language constructs must be followed by a single space; expected 1 space between YIELD FROM found "%s"';
99
-            $data  = [Common::prepareForOutput($found)];
100
-            $fix   = $phpcsFile->addFixableError($error, $stackPtr, 'IncorrectYieldFrom', $data);
101
-            if ($fix === true) {
102
-                preg_match('/yield/i', $found, $yield);
103
-                preg_match('/from/i', $found, $from);
99
+            $data  = [ Common::prepareForOutput( $found ) ];
100
+            $fix   = $phpcsFile->addFixableError( $error, $stackPtr, 'IncorrectYieldFrom', $data );
101
+            if ( $fix === true ) {
102
+                preg_match( '/yield/i', $found, $yield );
103
+                preg_match( '/from/i', $found, $from );
104 104
                 $phpcsFile->fixer->beginChangeset();
105
-                $phpcsFile->fixer->replaceToken($stackPtr, $yield[0].' '.$from[0]);
105
+                $phpcsFile->fixer->replaceToken( $stackPtr, $yield[ 0 ] . ' ' . $from[ 0 ] );
106 106
 
107
-                if ($tokens[($stackPtr + 1)]['code'] === T_YIELD_FROM) {
108
-                    $i = ($stackPtr + 1);
107
+                if ( $tokens[ ( $stackPtr + 1 ) ][ 'code' ] === T_YIELD_FROM ) {
108
+                    $i = ( $stackPtr + 1 );
109 109
                     do {
110
-                        $phpcsFile->fixer->replaceToken($i, '');
110
+                        $phpcsFile->fixer->replaceToken( $i, '' );
111 111
                         $i++;
112
-                    } while ($tokens[$i]['code'] === T_YIELD_FROM);
112
+                    } while ( $tokens[ $i ][ 'code' ] === T_YIELD_FROM );
113 113
                 }
114 114
 
115 115
                 $phpcsFile->fixer->endChangeset();
@@ -118,25 +118,25 @@  discard block
 block discarded – undo
118 118
             return;
119 119
         }//end if
120 120
 
121
-        if ($tokens[($stackPtr + 1)]['code'] === T_WHITESPACE) {
122
-            $content = $tokens[($stackPtr + 1)]['content'];
123
-            if ($content !== ' ') {
121
+        if ( $tokens[ ( $stackPtr + 1 ) ][ 'code' ] === T_WHITESPACE ) {
122
+            $content = $tokens[ ( $stackPtr + 1 ) ][ 'content' ];
123
+            if ( $content !== ' ' ) {
124 124
                 $error = 'Language constructs must be followed by a single space; expected 1 space but found "%s"';
125
-                $data  = [Common::prepareForOutput($content)];
126
-                $fix   = $phpcsFile->addFixableError($error, $stackPtr, 'IncorrectSingle', $data);
127
-                if ($fix === true) {
128
-                    $phpcsFile->fixer->replaceToken(($stackPtr + 1), ' ');
125
+                $data  = [ Common::prepareForOutput( $content ) ];
126
+                $fix   = $phpcsFile->addFixableError( $error, $stackPtr, 'IncorrectSingle', $data );
127
+                if ( $fix === true ) {
128
+                    $phpcsFile->fixer->replaceToken( ( $stackPtr + 1 ), ' ' );
129 129
                 }
130 130
             }
131
-        } else if ($tokens[($stackPtr + 1)]['code'] !== T_OPEN_PARENTHESIS) {
131
+        } else if ( $tokens[ ( $stackPtr + 1 ) ][ 'code' ] !== T_OPEN_PARENTHESIS ) {
132 132
             $error = 'Language constructs must be followed by a single space; expected "%s" but found "%s"';
133 133
             $data  = [
134
-                $tokens[$stackPtr]['content'].' '.$tokens[($stackPtr + 1)]['content'],
135
-                $tokens[$stackPtr]['content'].$tokens[($stackPtr + 1)]['content'],
134
+                $tokens[ $stackPtr ][ 'content' ] . ' ' . $tokens[ ( $stackPtr + 1 ) ][ 'content' ],
135
+                $tokens[ $stackPtr ][ 'content' ] . $tokens[ ( $stackPtr + 1 ) ][ 'content' ],
136 136
             ];
137
-            $fix   = $phpcsFile->addFixableError($error, $stackPtr, 'Incorrect', $data);
138
-            if ($fix === true) {
139
-                $phpcsFile->fixer->addContent($stackPtr, ' ');
137
+            $fix = $phpcsFile->addFixableError( $error, $stackPtr, 'Incorrect', $data );
138
+            if ( $fix === true ) {
139
+                $phpcsFile->fixer->addContent( $stackPtr, ' ' );
140 140
             }
141 141
         }//end if
142 142
 
Please login to merge, or discard this patch.
src/Standards/Generic/Sniffs/Arrays/DisallowShortArraySyntaxSniff.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
      */
24 24
     public function register()
25 25
     {
26
-        return [T_OPEN_SHORT_ARRAY];
26
+        return [ T_OPEN_SHORT_ARRAY ];
27 27
 
28 28
     }//end register()
29 29
 
@@ -37,21 +37,21 @@  discard block
 block discarded – undo
37 37
      *
38 38
      * @return void
39 39
      */
40
-    public function process(File $phpcsFile, $stackPtr)
40
+    public function process( File $phpcsFile, $stackPtr )
41 41
     {
42
-        $phpcsFile->recordMetric($stackPtr, 'Short array syntax used', 'yes');
42
+        $phpcsFile->recordMetric( $stackPtr, 'Short array syntax used', 'yes' );
43 43
 
44 44
         $error = 'Short array syntax is not allowed';
45
-        $fix   = $phpcsFile->addFixableError($error, $stackPtr, 'Found');
45
+        $fix   = $phpcsFile->addFixableError( $error, $stackPtr, 'Found' );
46 46
 
47
-        if ($fix === true) {
47
+        if ( $fix === true ) {
48 48
             $tokens = $phpcsFile->getTokens();
49
-            $opener = $tokens[$stackPtr]['bracket_opener'];
50
-            $closer = $tokens[$stackPtr]['bracket_closer'];
49
+            $opener = $tokens[ $stackPtr ][ 'bracket_opener' ];
50
+            $closer = $tokens[ $stackPtr ][ 'bracket_closer' ];
51 51
 
52 52
             $phpcsFile->fixer->beginChangeset();
53
-            $phpcsFile->fixer->replaceToken($opener, 'array(');
54
-            $phpcsFile->fixer->replaceToken($closer, ')');
53
+            $phpcsFile->fixer->replaceToken( $opener, 'array(' );
54
+            $phpcsFile->fixer->replaceToken( $closer, ')' );
55 55
             $phpcsFile->fixer->endChangeset();
56 56
         }
57 57
 
Please login to merge, or discard this patch.
src/Standards/Generic/Sniffs/Arrays/DisallowLongArraySyntaxSniff.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
      */
24 24
     public function register()
25 25
     {
26
-        return [T_ARRAY];
26
+        return [ T_ARRAY ];
27 27
 
28 28
     }//end register()
29 29
 
@@ -37,36 +37,36 @@  discard block
 block discarded – undo
37 37
      *
38 38
      * @return void
39 39
      */
40
-    public function process(File $phpcsFile, $stackPtr)
40
+    public function process( File $phpcsFile, $stackPtr )
41 41
     {
42 42
         $tokens = $phpcsFile->getTokens();
43 43
 
44
-        $phpcsFile->recordMetric($stackPtr, 'Short array syntax used', 'no');
44
+        $phpcsFile->recordMetric( $stackPtr, 'Short array syntax used', 'no' );
45 45
 
46 46
         $error = 'Short array syntax must be used to define arrays';
47 47
 
48
-        if (isset($tokens[$stackPtr]['parenthesis_opener']) === false
49
-            || isset($tokens[$stackPtr]['parenthesis_closer']) === false
48
+        if ( isset( $tokens[ $stackPtr ][ 'parenthesis_opener' ] ) === false
49
+            || isset( $tokens[ $stackPtr ][ 'parenthesis_closer' ] ) === false
50 50
         ) {
51 51
             // Live coding/parse error, just show the error, don't try and fix it.
52
-            $phpcsFile->addError($error, $stackPtr, 'Found');
52
+            $phpcsFile->addError( $error, $stackPtr, 'Found' );
53 53
             return;
54 54
         }
55 55
 
56
-        $fix = $phpcsFile->addFixableError($error, $stackPtr, 'Found');
56
+        $fix = $phpcsFile->addFixableError( $error, $stackPtr, 'Found' );
57 57
 
58
-        if ($fix === true) {
59
-            $opener = $tokens[$stackPtr]['parenthesis_opener'];
60
-            $closer = $tokens[$stackPtr]['parenthesis_closer'];
58
+        if ( $fix === true ) {
59
+            $opener = $tokens[ $stackPtr ][ 'parenthesis_opener' ];
60
+            $closer = $tokens[ $stackPtr ][ 'parenthesis_closer' ];
61 61
 
62 62
             $phpcsFile->fixer->beginChangeset();
63 63
 
64
-            if ($opener === null) {
65
-                $phpcsFile->fixer->replaceToken($stackPtr, '[]');
64
+            if ( $opener === null ) {
65
+                $phpcsFile->fixer->replaceToken( $stackPtr, '[]' );
66 66
             } else {
67
-                $phpcsFile->fixer->replaceToken($stackPtr, '');
68
-                $phpcsFile->fixer->replaceToken($opener, '[');
69
-                $phpcsFile->fixer->replaceToken($closer, ']');
67
+                $phpcsFile->fixer->replaceToken( $stackPtr, '' );
68
+                $phpcsFile->fixer->replaceToken( $opener, '[' );
69
+                $phpcsFile->fixer->replaceToken( $closer, ']' );
70 70
             }
71 71
 
72 72
             $phpcsFile->fixer->endChangeset();
Please login to merge, or discard this patch.
php_codesniffer/src/Standards/Generic/Sniffs/Arrays/ArrayIndentSniff.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
      *
37 37
      * @return void
38 38
      */
39
-    public function processSingleLineArray($phpcsFile, $stackPtr, $arrayStart, $arrayEnd, $indices)
39
+    public function processSingleLineArray( $phpcsFile, $stackPtr, $arrayStart, $arrayEnd, $indices )
40 40
     {
41 41
 
42 42
     }//end processSingleLineArray()
@@ -55,31 +55,31 @@  discard block
 block discarded – undo
55 55
      *
56 56
      * @return void
57 57
      */
58
-    public function processMultiLineArray($phpcsFile, $stackPtr, $arrayStart, $arrayEnd, $indices)
58
+    public function processMultiLineArray( $phpcsFile, $stackPtr, $arrayStart, $arrayEnd, $indices )
59 59
     {
60 60
         $tokens = $phpcsFile->getTokens();
61 61
 
62
-        $first          = $phpcsFile->findFirstOnLine(T_WHITESPACE, $stackPtr, true);
63
-        $expectedIndent = ($tokens[$first]['column'] - 1 + $this->indent);
62
+        $first          = $phpcsFile->findFirstOnLine( T_WHITESPACE, $stackPtr, true );
63
+        $expectedIndent = ( $tokens[ $first ][ 'column' ] - 1 + $this->indent );
64 64
 
65
-        foreach ($indices as $index) {
66
-            if (isset($index['index_start']) === true) {
67
-                $start = $index['index_start'];
65
+        foreach ( $indices as $index ) {
66
+            if ( isset( $index[ 'index_start' ] ) === true ) {
67
+                $start = $index[ 'index_start' ];
68 68
             } else {
69
-                $start = $index['value_start'];
69
+                $start = $index[ 'value_start' ];
70 70
             }
71 71
 
72
-            $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($start - 1), null, true);
73
-            if ($tokens[$prev]['line'] === $tokens[$start]['line']) {
72
+            $prev = $phpcsFile->findPrevious( Tokens::$emptyTokens, ( $start - 1 ), null, true );
73
+            if ( $tokens[ $prev ][ 'line' ] === $tokens[ $start ][ 'line' ] ) {
74 74
                 // This index isn't the only content on the line
75 75
                 // so we can't check indent rules.
76 76
                 continue;
77 77
             }
78 78
 
79
-            $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $start, true);
79
+            $first = $phpcsFile->findFirstOnLine( T_WHITESPACE, $start, true );
80 80
 
81
-            $foundIndent = ($tokens[$first]['column'] - 1);
82
-            if ($foundIndent === $expectedIndent) {
81
+            $foundIndent = ( $tokens[ $first ][ 'column' ] - 1 );
82
+            if ( $foundIndent === $expectedIndent ) {
83 83
                 continue;
84 84
             }
85 85
 
@@ -88,26 +88,26 @@  discard block
 block discarded – undo
88 88
                 $expectedIndent,
89 89
                 $foundIndent,
90 90
             ];
91
-            $fix   = $phpcsFile->addFixableError($error, $first, 'KeyIncorrect', $data);
92
-            if ($fix === false) {
91
+            $fix = $phpcsFile->addFixableError( $error, $first, 'KeyIncorrect', $data );
92
+            if ( $fix === false ) {
93 93
                 continue;
94 94
             }
95 95
 
96
-            $padding = str_repeat(' ', $expectedIndent);
97
-            if ($foundIndent === 0) {
98
-                $phpcsFile->fixer->addContentBefore($first, $padding);
96
+            $padding = str_repeat( ' ', $expectedIndent );
97
+            if ( $foundIndent === 0 ) {
98
+                $phpcsFile->fixer->addContentBefore( $first, $padding );
99 99
             } else {
100
-                $phpcsFile->fixer->replaceToken(($first - 1), $padding);
100
+                $phpcsFile->fixer->replaceToken( ( $first - 1 ), $padding );
101 101
             }
102 102
         }//end foreach
103 103
 
104
-        $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($arrayEnd - 1), null, true);
105
-        if ($tokens[$prev]['line'] === $tokens[$arrayEnd]['line']) {
104
+        $prev = $phpcsFile->findPrevious( T_WHITESPACE, ( $arrayEnd - 1 ), null, true );
105
+        if ( $tokens[ $prev ][ 'line' ] === $tokens[ $arrayEnd ][ 'line' ] ) {
106 106
             $error = 'Closing brace of array declaration must be on a new line';
107
-            $fix   = $phpcsFile->addFixableError($error, $arrayEnd, 'CloseBraceNotNewLine');
108
-            if ($fix === true) {
109
-                $padding = $phpcsFile->eolChar.str_repeat(' ', $expectedIndent);
110
-                $phpcsFile->fixer->addContentBefore($arrayEnd, $padding);
107
+            $fix   = $phpcsFile->addFixableError( $error, $arrayEnd, 'CloseBraceNotNewLine' );
108
+            if ( $fix === true ) {
109
+                $padding = $phpcsFile->eolChar . str_repeat( ' ', $expectedIndent );
110
+                $phpcsFile->fixer->addContentBefore( $arrayEnd, $padding );
111 111
             }
112 112
 
113 113
             return;
@@ -115,8 +115,8 @@  discard block
 block discarded – undo
115 115
 
116 116
         // The close brace must be indented one stop less.
117 117
         $expectedIndent -= $this->indent;
118
-        $foundIndent     = ($tokens[$arrayEnd]['column'] - 1);
119
-        if ($foundIndent === $expectedIndent) {
118
+        $foundIndent     = ( $tokens[ $arrayEnd ][ 'column' ] - 1 );
119
+        if ( $foundIndent === $expectedIndent ) {
120 120
             return;
121 121
         }
122 122
 
@@ -125,16 +125,16 @@  discard block
 block discarded – undo
125 125
             $expectedIndent,
126 126
             $foundIndent,
127 127
         ];
128
-        $fix   = $phpcsFile->addFixableError($error, $arrayEnd, 'CloseBraceIncorrect', $data);
129
-        if ($fix === false) {
128
+        $fix = $phpcsFile->addFixableError( $error, $arrayEnd, 'CloseBraceIncorrect', $data );
129
+        if ( $fix === false ) {
130 130
             return;
131 131
         }
132 132
 
133
-        $padding = str_repeat(' ', $expectedIndent);
134
-        if ($foundIndent === 0) {
135
-            $phpcsFile->fixer->addContentBefore($arrayEnd, $padding);
133
+        $padding = str_repeat( ' ', $expectedIndent );
134
+        if ( $foundIndent === 0 ) {
135
+            $phpcsFile->fixer->addContentBefore( $arrayEnd, $padding );
136 136
         } else {
137
-            $phpcsFile->fixer->replaceToken(($arrayEnd - 1), $padding);
137
+            $phpcsFile->fixer->replaceToken( ( $arrayEnd - 1 ), $padding );
138 138
         }
139 139
 
140 140
     }//end processMultiLineArray()
Please login to merge, or discard this patch.
Standards/Generic/Sniffs/Functions/OpeningFunctionBraceBsdAllmanSniff.php 1 patch
Spacing   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -55,121 +55,121 @@  discard block
 block discarded – undo
55 55
      *
56 56
      * @return void
57 57
      */
58
-    public function process(File $phpcsFile, $stackPtr)
58
+    public function process( File $phpcsFile, $stackPtr )
59 59
     {
60 60
         $tokens = $phpcsFile->getTokens();
61 61
 
62
-        if (isset($tokens[$stackPtr]['scope_opener']) === false) {
62
+        if ( isset( $tokens[ $stackPtr ][ 'scope_opener' ] ) === false ) {
63 63
             return;
64 64
         }
65 65
 
66
-        if (($tokens[$stackPtr]['code'] === T_FUNCTION
67
-            && (bool) $this->checkFunctions === false)
68
-            || ($tokens[$stackPtr]['code'] === T_CLOSURE
69
-            && (bool) $this->checkClosures === false)
66
+        if ( ( $tokens[ $stackPtr ][ 'code' ] === T_FUNCTION
67
+            && (bool)$this->checkFunctions === false )
68
+            || ( $tokens[ $stackPtr ][ 'code' ] === T_CLOSURE
69
+            && (bool)$this->checkClosures === false )
70 70
         ) {
71 71
             return;
72 72
         }
73 73
 
74
-        $openingBrace = $tokens[$stackPtr]['scope_opener'];
75
-        $closeBracket = $tokens[$stackPtr]['parenthesis_closer'];
76
-        if ($tokens[$stackPtr]['code'] === T_CLOSURE) {
77
-            $use = $phpcsFile->findNext(T_USE, ($closeBracket + 1), $tokens[$stackPtr]['scope_opener']);
78
-            if ($use !== false) {
79
-                $openBracket  = $phpcsFile->findNext(T_OPEN_PARENTHESIS, ($use + 1));
80
-                $closeBracket = $tokens[$openBracket]['parenthesis_closer'];
74
+        $openingBrace = $tokens[ $stackPtr ][ 'scope_opener' ];
75
+        $closeBracket = $tokens[ $stackPtr ][ 'parenthesis_closer' ];
76
+        if ( $tokens[ $stackPtr ][ 'code' ] === T_CLOSURE ) {
77
+            $use = $phpcsFile->findNext( T_USE, ( $closeBracket + 1 ), $tokens[ $stackPtr ][ 'scope_opener' ] );
78
+            if ( $use !== false ) {
79
+                $openBracket  = $phpcsFile->findNext( T_OPEN_PARENTHESIS, ( $use + 1 ) );
80
+                $closeBracket = $tokens[ $openBracket ][ 'parenthesis_closer' ];
81 81
             }
82 82
         }
83 83
 
84 84
         // Find the end of the function declaration.
85
-        $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($openingBrace - 1), $closeBracket, true);
85
+        $prev = $phpcsFile->findPrevious( Tokens::$emptyTokens, ( $openingBrace - 1 ), $closeBracket, true );
86 86
 
87
-        $functionLine = $tokens[$prev]['line'];
88
-        $braceLine    = $tokens[$openingBrace]['line'];
87
+        $functionLine = $tokens[ $prev ][ 'line' ];
88
+        $braceLine    = $tokens[ $openingBrace ][ 'line' ];
89 89
 
90
-        $lineDifference = ($braceLine - $functionLine);
90
+        $lineDifference = ( $braceLine - $functionLine );
91 91
 
92 92
         $metricType = 'Function';
93
-        if ($tokens[$stackPtr]['code'] === T_CLOSURE) {
93
+        if ( $tokens[ $stackPtr ][ 'code' ] === T_CLOSURE ) {
94 94
             $metricType = 'Closure';
95 95
         }
96 96
 
97
-        if ($lineDifference === 0) {
97
+        if ( $lineDifference === 0 ) {
98 98
             $error = 'Opening brace should be on a new line';
99
-            $fix   = $phpcsFile->addFixableError($error, $openingBrace, 'BraceOnSameLine');
100
-            if ($fix === true) {
99
+            $fix   = $phpcsFile->addFixableError( $error, $openingBrace, 'BraceOnSameLine' );
100
+            if ( $fix === true ) {
101 101
                 $hasTrailingAnnotation = false;
102
-                for ($nextLine = ($openingBrace + 1); $nextLine < $phpcsFile->numTokens; $nextLine++) {
103
-                    if ($tokens[$openingBrace]['line'] !== $tokens[$nextLine]['line']) {
102
+                for ( $nextLine = ( $openingBrace + 1 ); $nextLine < $phpcsFile->numTokens; $nextLine++ ) {
103
+                    if ( $tokens[ $openingBrace ][ 'line' ] !== $tokens[ $nextLine ][ 'line' ] ) {
104 104
                         break;
105 105
                     }
106 106
 
107
-                    if (isset(Tokens::$phpcsCommentTokens[$tokens[$nextLine]['code']]) === true) {
107
+                    if ( isset( Tokens::$phpcsCommentTokens[ $tokens[ $nextLine ][ 'code' ] ] ) === true ) {
108 108
                         $hasTrailingAnnotation = true;
109 109
                     }
110 110
                 }
111 111
 
112 112
                 $phpcsFile->fixer->beginChangeset();
113
-                $indent = $phpcsFile->findFirstOnLine([], $openingBrace);
113
+                $indent = $phpcsFile->findFirstOnLine( [ ], $openingBrace );
114 114
 
115
-                if ($hasTrailingAnnotation === false || $nextLine === false) {
116
-                    if ($tokens[$indent]['code'] === T_WHITESPACE) {
117
-                        $phpcsFile->fixer->addContentBefore($openingBrace, $tokens[$indent]['content']);
115
+                if ( $hasTrailingAnnotation === false || $nextLine === false ) {
116
+                    if ( $tokens[ $indent ][ 'code' ] === T_WHITESPACE ) {
117
+                        $phpcsFile->fixer->addContentBefore( $openingBrace, $tokens[ $indent ][ 'content' ] );
118 118
                     }
119 119
 
120
-                    if ($tokens[($openingBrace - 1)]['code'] === T_WHITESPACE) {
121
-                        $phpcsFile->fixer->replaceToken(($openingBrace - 1), '');
120
+                    if ( $tokens[ ( $openingBrace - 1 ) ][ 'code' ] === T_WHITESPACE ) {
121
+                        $phpcsFile->fixer->replaceToken( ( $openingBrace - 1 ), '' );
122 122
                     }
123 123
 
124
-                    $phpcsFile->fixer->addNewlineBefore($openingBrace);
124
+                    $phpcsFile->fixer->addNewlineBefore( $openingBrace );
125 125
                 } else {
126
-                    $phpcsFile->fixer->replaceToken($openingBrace, '');
127
-                    $phpcsFile->fixer->addNewlineBefore($nextLine);
128
-                    $phpcsFile->fixer->addContentBefore($nextLine, '{');
126
+                    $phpcsFile->fixer->replaceToken( $openingBrace, '' );
127
+                    $phpcsFile->fixer->addNewlineBefore( $nextLine );
128
+                    $phpcsFile->fixer->addContentBefore( $nextLine, '{' );
129 129
 
130
-                    if ($tokens[$indent]['code'] === T_WHITESPACE) {
131
-                        $phpcsFile->fixer->addContentBefore($nextLine, $tokens[$indent]['content']);
130
+                    if ( $tokens[ $indent ][ 'code' ] === T_WHITESPACE ) {
131
+                        $phpcsFile->fixer->addContentBefore( $nextLine, $tokens[ $indent ][ 'content' ] );
132 132
                     }
133 133
                 }
134 134
 
135 135
                 $phpcsFile->fixer->endChangeset();
136 136
             }//end if
137 137
 
138
-            $phpcsFile->recordMetric($stackPtr, "$metricType opening brace placement", 'same line');
139
-        } else if ($lineDifference > 1) {
138
+            $phpcsFile->recordMetric( $stackPtr, "$metricType opening brace placement", 'same line' );
139
+        } else if ( $lineDifference > 1 ) {
140 140
             $error = 'Opening brace should be on the line after the declaration; found %s blank line(s)';
141
-            $data  = [($lineDifference - 1)];
142
-            $fix   = $phpcsFile->addFixableError($error, $openingBrace, 'BraceSpacing', $data);
143
-            if ($fix === true) {
144
-                for ($i = ($tokens[$stackPtr]['parenthesis_closer'] + 1); $i < $openingBrace; $i++) {
145
-                    if ($tokens[$i]['line'] === $braceLine) {
146
-                        $phpcsFile->fixer->addNewLineBefore($i);
141
+            $data  = [ ( $lineDifference - 1 ) ];
142
+            $fix   = $phpcsFile->addFixableError( $error, $openingBrace, 'BraceSpacing', $data );
143
+            if ( $fix === true ) {
144
+                for ( $i = ( $tokens[ $stackPtr ][ 'parenthesis_closer' ] + 1 ); $i < $openingBrace; $i++ ) {
145
+                    if ( $tokens[ $i ][ 'line' ] === $braceLine ) {
146
+                        $phpcsFile->fixer->addNewLineBefore( $i );
147 147
                         break;
148 148
                     }
149 149
 
150
-                    $phpcsFile->fixer->replaceToken($i, '');
150
+                    $phpcsFile->fixer->replaceToken( $i, '' );
151 151
                 }
152 152
             }
153 153
         }//end if
154 154
 
155 155
         $ignore   = Tokens::$phpcsCommentTokens;
156
-        $ignore[] = T_WHITESPACE;
157
-        $next     = $phpcsFile->findNext($ignore, ($openingBrace + 1), null, true);
158
-        if ($tokens[$next]['line'] === $tokens[$openingBrace]['line']) {
159
-            if ($next === $tokens[$stackPtr]['scope_closer']) {
156
+        $ignore[ ] = T_WHITESPACE;
157
+        $next     = $phpcsFile->findNext( $ignore, ( $openingBrace + 1 ), null, true );
158
+        if ( $tokens[ $next ][ 'line' ] === $tokens[ $openingBrace ][ 'line' ] ) {
159
+            if ( $next === $tokens[ $stackPtr ][ 'scope_closer' ] ) {
160 160
                 // Ignore empty functions.
161 161
                 return;
162 162
             }
163 163
 
164 164
             $error = 'Opening brace must be the last content on the line';
165
-            $fix   = $phpcsFile->addFixableError($error, $openingBrace, 'ContentAfterBrace');
166
-            if ($fix === true) {
167
-                $phpcsFile->fixer->addNewline($openingBrace);
165
+            $fix   = $phpcsFile->addFixableError( $error, $openingBrace, 'ContentAfterBrace' );
166
+            if ( $fix === true ) {
167
+                $phpcsFile->fixer->addNewline( $openingBrace );
168 168
             }
169 169
         }
170 170
 
171 171
         // Only continue checking if the opening brace looks good.
172
-        if ($lineDifference !== 1) {
172
+        if ( $lineDifference !== 1 ) {
173 173
             return;
174 174
         }
175 175
 
@@ -177,16 +177,16 @@  discard block
 block discarded – undo
177 177
         // as if this is a method with tokens before it (public, static etc)
178 178
         // or an if with an else before it, then we need to start the scope
179 179
         // checking from there, rather than the current token.
180
-        $lineStart = $phpcsFile->findFirstOnLine(T_WHITESPACE, $stackPtr, true);
180
+        $lineStart = $phpcsFile->findFirstOnLine( T_WHITESPACE, $stackPtr, true );
181 181
 
182 182
         // The opening brace is on the correct line, now it needs to be
183 183
         // checked to be correctly indented.
184
-        $startColumn = $tokens[$lineStart]['column'];
185
-        $braceIndent = $tokens[$openingBrace]['column'];
184
+        $startColumn = $tokens[ $lineStart ][ 'column' ];
185
+        $braceIndent = $tokens[ $openingBrace ][ 'column' ];
186 186
 
187
-        if ($braceIndent !== $startColumn) {
188
-            $expected = ($startColumn - 1);
189
-            $found    = ($braceIndent - 1);
187
+        if ( $braceIndent !== $startColumn ) {
188
+            $expected = ( $startColumn - 1 );
189
+            $found    = ( $braceIndent - 1 );
190 190
 
191 191
             $error = 'Opening brace indented incorrectly; expected %s spaces, found %s';
192 192
             $data  = [
@@ -194,18 +194,18 @@  discard block
 block discarded – undo
194 194
                 $found,
195 195
             ];
196 196
 
197
-            $fix = $phpcsFile->addFixableError($error, $openingBrace, 'BraceIndent', $data);
198
-            if ($fix === true) {
199
-                $indent = str_repeat(' ', $expected);
200
-                if ($found === 0) {
201
-                    $phpcsFile->fixer->addContentBefore($openingBrace, $indent);
197
+            $fix = $phpcsFile->addFixableError( $error, $openingBrace, 'BraceIndent', $data );
198
+            if ( $fix === true ) {
199
+                $indent = str_repeat( ' ', $expected );
200
+                if ( $found === 0 ) {
201
+                    $phpcsFile->fixer->addContentBefore( $openingBrace, $indent );
202 202
                 } else {
203
-                    $phpcsFile->fixer->replaceToken(($openingBrace - 1), $indent);
203
+                    $phpcsFile->fixer->replaceToken( ( $openingBrace - 1 ), $indent );
204 204
                 }
205 205
             }
206 206
         }//end if
207 207
 
208
-        $phpcsFile->recordMetric($stackPtr, "$metricType opening brace placement", 'new line');
208
+        $phpcsFile->recordMetric( $stackPtr, "$metricType opening brace placement", 'new line' );
209 209
 
210 210
     }//end process()
211 211
 
Please login to merge, or discard this patch.
Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php 1 patch
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -56,125 +56,125 @@
 block discarded – undo
56 56
      *
57 57
      * @return void
58 58
      */
59
-    public function process(File $phpcsFile, $stackPtr)
59
+    public function process( File $phpcsFile, $stackPtr )
60 60
     {
61 61
         $tokens = $phpcsFile->getTokens();
62 62
 
63
-        if (isset($tokens[$stackPtr]['scope_opener']) === false) {
63
+        if ( isset( $tokens[ $stackPtr ][ 'scope_opener' ] ) === false ) {
64 64
             return;
65 65
         }
66 66
 
67
-        if (($tokens[$stackPtr]['code'] === T_FUNCTION
68
-            && (bool) $this->checkFunctions === false)
69
-            || ($tokens[$stackPtr]['code'] === T_CLOSURE
70
-            && (bool) $this->checkClosures === false)
67
+        if ( ( $tokens[ $stackPtr ][ 'code' ] === T_FUNCTION
68
+            && (bool)$this->checkFunctions === false )
69
+            || ( $tokens[ $stackPtr ][ 'code' ] === T_CLOSURE
70
+            && (bool)$this->checkClosures === false )
71 71
         ) {
72 72
             return;
73 73
         }
74 74
 
75
-        $openingBrace = $tokens[$stackPtr]['scope_opener'];
76
-        $closeBracket = $tokens[$stackPtr]['parenthesis_closer'];
77
-        if ($tokens[$stackPtr]['code'] === T_CLOSURE) {
78
-            $use = $phpcsFile->findNext(T_USE, ($closeBracket + 1), $tokens[$stackPtr]['scope_opener']);
79
-            if ($use !== false) {
80
-                $openBracket  = $phpcsFile->findNext(T_OPEN_PARENTHESIS, ($use + 1));
81
-                $closeBracket = $tokens[$openBracket]['parenthesis_closer'];
75
+        $openingBrace = $tokens[ $stackPtr ][ 'scope_opener' ];
76
+        $closeBracket = $tokens[ $stackPtr ][ 'parenthesis_closer' ];
77
+        if ( $tokens[ $stackPtr ][ 'code' ] === T_CLOSURE ) {
78
+            $use = $phpcsFile->findNext( T_USE, ( $closeBracket + 1 ), $tokens[ $stackPtr ][ 'scope_opener' ] );
79
+            if ( $use !== false ) {
80
+                $openBracket  = $phpcsFile->findNext( T_OPEN_PARENTHESIS, ( $use + 1 ) );
81
+                $closeBracket = $tokens[ $openBracket ][ 'parenthesis_closer' ];
82 82
             }
83 83
         }
84 84
 
85 85
         // Find the end of the function declaration.
86
-        $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($openingBrace - 1), $closeBracket, true);
86
+        $prev = $phpcsFile->findPrevious( Tokens::$emptyTokens, ( $openingBrace - 1 ), $closeBracket, true );
87 87
 
88
-        $functionLine = $tokens[$prev]['line'];
89
-        $braceLine    = $tokens[$openingBrace]['line'];
88
+        $functionLine = $tokens[ $prev ][ 'line' ];
89
+        $braceLine    = $tokens[ $openingBrace ][ 'line' ];
90 90
 
91
-        $lineDifference = ($braceLine - $functionLine);
91
+        $lineDifference = ( $braceLine - $functionLine );
92 92
 
93 93
         $metricType = 'Function';
94
-        if ($tokens[$stackPtr]['code'] === T_CLOSURE) {
94
+        if ( $tokens[ $stackPtr ][ 'code' ] === T_CLOSURE ) {
95 95
             $metricType = 'Closure';
96 96
         }
97 97
 
98
-        if ($lineDifference > 0) {
99
-            $phpcsFile->recordMetric($stackPtr, "$metricType opening brace placement", 'new line');
98
+        if ( $lineDifference > 0 ) {
99
+            $phpcsFile->recordMetric( $stackPtr, "$metricType opening brace placement", 'new line' );
100 100
             $error = 'Opening brace should be on the same line as the declaration';
101
-            $fix   = $phpcsFile->addFixableError($error, $openingBrace, 'BraceOnNewLine');
102
-            if ($fix === true) {
103
-                $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($openingBrace - 1), $closeBracket, true);
101
+            $fix   = $phpcsFile->addFixableError( $error, $openingBrace, 'BraceOnNewLine' );
102
+            if ( $fix === true ) {
103
+                $prev = $phpcsFile->findPrevious( Tokens::$emptyTokens, ( $openingBrace - 1 ), $closeBracket, true );
104 104
                 $phpcsFile->fixer->beginChangeset();
105
-                $phpcsFile->fixer->addContent($prev, ' {');
106
-                $phpcsFile->fixer->replaceToken($openingBrace, '');
107
-                if ($tokens[($openingBrace + 1)]['code'] === T_WHITESPACE
108
-                    && $tokens[($openingBrace + 2)]['line'] > $tokens[$openingBrace]['line']
105
+                $phpcsFile->fixer->addContent( $prev, ' {' );
106
+                $phpcsFile->fixer->replaceToken( $openingBrace, '' );
107
+                if ( $tokens[ ( $openingBrace + 1 ) ][ 'code' ] === T_WHITESPACE
108
+                    && $tokens[ ( $openingBrace + 2 ) ][ 'line' ] > $tokens[ $openingBrace ][ 'line' ]
109 109
                 ) {
110 110
                     // Brace is followed by a new line, so remove it to ensure we don't
111 111
                     // leave behind a blank line at the top of the block.
112
-                    $phpcsFile->fixer->replaceToken(($openingBrace + 1), '');
112
+                    $phpcsFile->fixer->replaceToken( ( $openingBrace + 1 ), '' );
113 113
 
114
-                    if ($tokens[($openingBrace - 1)]['code'] === T_WHITESPACE
115
-                        && $tokens[($openingBrace - 1)]['line'] === $tokens[$openingBrace]['line']
116
-                        && $tokens[($openingBrace - 2)]['line'] < $tokens[$openingBrace]['line']
114
+                    if ( $tokens[ ( $openingBrace - 1 ) ][ 'code' ] === T_WHITESPACE
115
+                        && $tokens[ ( $openingBrace - 1 ) ][ 'line' ] === $tokens[ $openingBrace ][ 'line' ]
116
+                        && $tokens[ ( $openingBrace - 2 ) ][ 'line' ] < $tokens[ $openingBrace ][ 'line' ]
117 117
                     ) {
118 118
                         // Brace is preceded by indent, so remove it to ensure we don't
119 119
                         // leave behind more indent than is required for the first line.
120
-                        $phpcsFile->fixer->replaceToken(($openingBrace - 1), '');
120
+                        $phpcsFile->fixer->replaceToken( ( $openingBrace - 1 ), '' );
121 121
                     }
122 122
                 }
123 123
 
124 124
                 $phpcsFile->fixer->endChangeset();
125 125
             }//end if
126 126
         } else {
127
-            $phpcsFile->recordMetric($stackPtr, "$metricType opening brace placement", 'same line');
127
+            $phpcsFile->recordMetric( $stackPtr, "$metricType opening brace placement", 'same line' );
128 128
         }//end if
129 129
 
130 130
         $ignore   = Tokens::$phpcsCommentTokens;
131
-        $ignore[] = T_WHITESPACE;
132
-        $next     = $phpcsFile->findNext($ignore, ($openingBrace + 1), null, true);
133
-        if ($tokens[$next]['line'] === $tokens[$openingBrace]['line']) {
134
-            if ($next === $tokens[$stackPtr]['scope_closer']
135
-                || $tokens[$next]['code'] === T_CLOSE_TAG
131
+        $ignore[ ] = T_WHITESPACE;
132
+        $next     = $phpcsFile->findNext( $ignore, ( $openingBrace + 1 ), null, true );
133
+        if ( $tokens[ $next ][ 'line' ] === $tokens[ $openingBrace ][ 'line' ] ) {
134
+            if ( $next === $tokens[ $stackPtr ][ 'scope_closer' ]
135
+                || $tokens[ $next ][ 'code' ] === T_CLOSE_TAG
136 136
             ) {
137 137
                 // Ignore empty functions.
138 138
                 return;
139 139
             }
140 140
 
141 141
             $error = 'Opening brace must be the last content on the line';
142
-            $fix   = $phpcsFile->addFixableError($error, $openingBrace, 'ContentAfterBrace');
143
-            if ($fix === true) {
144
-                $phpcsFile->fixer->addNewline($openingBrace);
142
+            $fix   = $phpcsFile->addFixableError( $error, $openingBrace, 'ContentAfterBrace' );
143
+            if ( $fix === true ) {
144
+                $phpcsFile->fixer->addNewline( $openingBrace );
145 145
             }
146 146
         }
147 147
 
148 148
         // Only continue checking if the opening brace looks good.
149
-        if ($lineDifference > 0) {
149
+        if ( $lineDifference > 0 ) {
150 150
             return;
151 151
         }
152 152
 
153 153
         // We are looking for tabs, even if they have been replaced, because
154 154
         // we enforce a space here.
155
-        if (isset($tokens[($openingBrace - 1)]['orig_content']) === true) {
156
-            $spacing = $tokens[($openingBrace - 1)]['orig_content'];
155
+        if ( isset( $tokens[ ( $openingBrace - 1 ) ][ 'orig_content' ] ) === true ) {
156
+            $spacing = $tokens[ ( $openingBrace - 1 ) ][ 'orig_content' ];
157 157
         } else {
158
-            $spacing = $tokens[($openingBrace - 1)]['content'];
158
+            $spacing = $tokens[ ( $openingBrace - 1 ) ][ 'content' ];
159 159
         }
160 160
 
161
-        if ($tokens[($openingBrace - 1)]['code'] !== T_WHITESPACE) {
161
+        if ( $tokens[ ( $openingBrace - 1 ) ][ 'code' ] !== T_WHITESPACE ) {
162 162
             $length = 0;
163
-        } else if ($spacing === "\t") {
163
+        } else if ( $spacing === "\t" ) {
164 164
             $length = '\t';
165 165
         } else {
166
-            $length = strlen($spacing);
166
+            $length = strlen( $spacing );
167 167
         }
168 168
 
169
-        if ($length !== 1) {
169
+        if ( $length !== 1 ) {
170 170
             $error = 'Expected 1 space before opening brace; found %s';
171
-            $data  = [$length];
172
-            $fix   = $phpcsFile->addFixableError($error, $closeBracket, 'SpaceBeforeBrace', $data);
173
-            if ($fix === true) {
174
-                if ($length === 0 || $length === '\t') {
175
-                    $phpcsFile->fixer->addContentBefore($openingBrace, ' ');
171
+            $data  = [ $length ];
172
+            $fix   = $phpcsFile->addFixableError( $error, $closeBracket, 'SpaceBeforeBrace', $data );
173
+            if ( $fix === true ) {
174
+                if ( $length === 0 || $length === '\t' ) {
175
+                    $phpcsFile->fixer->addContentBefore( $openingBrace, ' ' );
176 176
                 } else {
177
-                    $phpcsFile->fixer->replaceToken(($openingBrace - 1), ' ');
177
+                    $phpcsFile->fixer->replaceToken( ( $openingBrace - 1 ), ' ' );
178 178
                 }
179 179
             }
180 180
         }
Please login to merge, or discard this patch.
src/Standards/Generic/Sniffs/Functions/FunctionCallArgumentSpacingSniff.php 1 patch
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
      *
48 48
      * @return void
49 49
      */
50
-    public function process(File $phpcsFile, $stackPtr)
50
+    public function process( File $phpcsFile, $stackPtr )
51 51
     {
52 52
         $tokens = $phpcsFile->getTokens();
53 53
 
@@ -58,14 +58,14 @@  discard block
 block discarded – undo
58 58
         // function or method *call*.
59 59
         $functionName    = $stackPtr;
60 60
         $ignoreTokens    = Tokens::$emptyTokens;
61
-        $ignoreTokens[]  = T_BITWISE_AND;
62
-        $functionKeyword = $phpcsFile->findPrevious($ignoreTokens, ($stackPtr - 1), null, true);
63
-        if ($tokens[$functionKeyword]['code'] === T_FUNCTION || $tokens[$functionKeyword]['code'] === T_CLASS) {
61
+        $ignoreTokens[ ]  = T_BITWISE_AND;
62
+        $functionKeyword = $phpcsFile->findPrevious( $ignoreTokens, ( $stackPtr - 1 ), null, true );
63
+        if ( $tokens[ $functionKeyword ][ 'code' ] === T_FUNCTION || $tokens[ $functionKeyword ][ 'code' ] === T_CLASS ) {
64 64
             return;
65 65
         }
66 66
 
67
-        if ($tokens[$stackPtr]['code'] === T_CLOSE_CURLY_BRACKET
68
-            && isset($tokens[$stackPtr]['scope_condition']) === true
67
+        if ( $tokens[ $stackPtr ][ 'code' ] === T_CLOSE_CURLY_BRACKET
68
+            && isset( $tokens[ $stackPtr ][ 'scope_condition' ] ) === true
69 69
         ) {
70 70
             // Not a function call.
71 71
             return;
@@ -73,16 +73,16 @@  discard block
 block discarded – undo
73 73
 
74 74
         // If the next non-whitespace token after the function or method call
75 75
         // is not an opening parenthesis then it can't really be a *call*.
76
-        $openBracket = $phpcsFile->findNext(Tokens::$emptyTokens, ($functionName + 1), null, true);
77
-        if ($tokens[$openBracket]['code'] !== T_OPEN_PARENTHESIS) {
76
+        $openBracket = $phpcsFile->findNext( Tokens::$emptyTokens, ( $functionName + 1 ), null, true );
77
+        if ( $tokens[ $openBracket ][ 'code' ] !== T_OPEN_PARENTHESIS ) {
78 78
             return;
79 79
         }
80 80
 
81
-        if (isset($tokens[$openBracket]['parenthesis_closer']) === false) {
81
+        if ( isset( $tokens[ $openBracket ][ 'parenthesis_closer' ] ) === false ) {
82 82
             return;
83 83
         }
84 84
 
85
-        $closeBracket  = $tokens[$openBracket]['parenthesis_closer'];
85
+        $closeBracket  = $tokens[ $openBracket ][ 'parenthesis_closer' ];
86 86
         $nextSeparator = $openBracket;
87 87
 
88 88
         $find = [
@@ -93,41 +93,41 @@  discard block
 block discarded – undo
93 93
             T_OPEN_SHORT_ARRAY,
94 94
         ];
95 95
 
96
-        while (($nextSeparator = $phpcsFile->findNext($find, ($nextSeparator + 1), $closeBracket)) !== false) {
97
-            if ($tokens[$nextSeparator]['code'] === T_CLOSURE
98
-                || $tokens[$nextSeparator]['code'] === T_ANON_CLASS
96
+        while ( ( $nextSeparator = $phpcsFile->findNext( $find, ( $nextSeparator + 1 ), $closeBracket ) ) !== false ) {
97
+            if ( $tokens[ $nextSeparator ][ 'code' ] === T_CLOSURE
98
+                || $tokens[ $nextSeparator ][ 'code' ] === T_ANON_CLASS
99 99
             ) {
100 100
                 // Skip closures.
101
-                $nextSeparator = $tokens[$nextSeparator]['scope_closer'];
101
+                $nextSeparator = $tokens[ $nextSeparator ][ 'scope_closer' ];
102 102
                 continue;
103
-            } else if ($tokens[$nextSeparator]['code'] === T_OPEN_SHORT_ARRAY) {
103
+            } else if ( $tokens[ $nextSeparator ][ 'code' ] === T_OPEN_SHORT_ARRAY ) {
104 104
                 // Skips arrays using short notation.
105
-                $nextSeparator = $tokens[$nextSeparator]['bracket_closer'];
105
+                $nextSeparator = $tokens[ $nextSeparator ][ 'bracket_closer' ];
106 106
                 continue;
107 107
             }
108 108
 
109 109
             // Make sure the comma or variable belongs directly to this function call,
110 110
             // and is not inside a nested function call or array.
111
-            $brackets    = $tokens[$nextSeparator]['nested_parenthesis'];
112
-            $lastBracket = array_pop($brackets);
113
-            if ($lastBracket !== $closeBracket) {
111
+            $brackets    = $tokens[ $nextSeparator ][ 'nested_parenthesis' ];
112
+            $lastBracket = array_pop( $brackets );
113
+            if ( $lastBracket !== $closeBracket ) {
114 114
                 continue;
115 115
             }
116 116
 
117
-            if ($tokens[$nextSeparator]['code'] === T_COMMA) {
118
-                if ($tokens[($nextSeparator - 1)]['code'] === T_WHITESPACE) {
119
-                    $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($nextSeparator - 2), null, true);
120
-                    if (isset(Tokens::$heredocTokens[$tokens[$prev]['code']]) === false) {
117
+            if ( $tokens[ $nextSeparator ][ 'code' ] === T_COMMA ) {
118
+                if ( $tokens[ ( $nextSeparator - 1 ) ][ 'code' ] === T_WHITESPACE ) {
119
+                    $prev = $phpcsFile->findPrevious( Tokens::$emptyTokens, ( $nextSeparator - 2 ), null, true );
120
+                    if ( isset( Tokens::$heredocTokens[ $tokens[ $prev ][ 'code' ] ] ) === false ) {
121 121
                         $error = 'Space found before comma in function call';
122
-                        $fix   = $phpcsFile->addFixableError($error, $nextSeparator, 'SpaceBeforeComma');
123
-                        if ($fix === true) {
122
+                        $fix   = $phpcsFile->addFixableError( $error, $nextSeparator, 'SpaceBeforeComma' );
123
+                        if ( $fix === true ) {
124 124
                             $phpcsFile->fixer->beginChangeset();
125 125
 
126
-                            if ($tokens[$prev]['line'] !== $tokens[$nextSeparator]['line']) {
127
-                                $phpcsFile->fixer->addContent($prev, ',');
128
-                                $phpcsFile->fixer->replaceToken($nextSeparator, '');
126
+                            if ( $tokens[ $prev ][ 'line' ] !== $tokens[ $nextSeparator ][ 'line' ] ) {
127
+                                $phpcsFile->fixer->addContent( $prev, ',' );
128
+                                $phpcsFile->fixer->replaceToken( $nextSeparator, '' );
129 129
                             } else {
130
-                                $phpcsFile->fixer->replaceToken(($nextSeparator - 1), '');
130
+                                $phpcsFile->fixer->replaceToken( ( $nextSeparator - 1 ), '' );
131 131
                             }
132 132
 
133 133
                             $phpcsFile->fixer->endChangeset();
@@ -135,46 +135,46 @@  discard block
 block discarded – undo
135 135
                     }//end if
136 136
                 }//end if
137 137
 
138
-                if ($tokens[($nextSeparator + 1)]['code'] !== T_WHITESPACE) {
138
+                if ( $tokens[ ( $nextSeparator + 1 ) ][ 'code' ] !== T_WHITESPACE ) {
139 139
                     $error = 'No space found after comma in function call';
140
-                    $fix   = $phpcsFile->addFixableError($error, $nextSeparator, 'NoSpaceAfterComma');
141
-                    if ($fix === true) {
142
-                        $phpcsFile->fixer->addContent($nextSeparator, ' ');
140
+                    $fix   = $phpcsFile->addFixableError( $error, $nextSeparator, 'NoSpaceAfterComma' );
141
+                    if ( $fix === true ) {
142
+                        $phpcsFile->fixer->addContent( $nextSeparator, ' ' );
143 143
                     }
144 144
                 } else {
145 145
                     // If there is a newline in the space, then they must be formatting
146 146
                     // each argument on a newline, which is valid, so ignore it.
147
-                    $next = $phpcsFile->findNext(Tokens::$emptyTokens, ($nextSeparator + 1), null, true);
148
-                    if ($tokens[$next]['line'] === $tokens[$nextSeparator]['line']) {
149
-                        $space = $tokens[($nextSeparator + 1)]['length'];
150
-                        if ($space > 1) {
147
+                    $next = $phpcsFile->findNext( Tokens::$emptyTokens, ( $nextSeparator + 1 ), null, true );
148
+                    if ( $tokens[ $next ][ 'line' ] === $tokens[ $nextSeparator ][ 'line' ] ) {
149
+                        $space = $tokens[ ( $nextSeparator + 1 ) ][ 'length' ];
150
+                        if ( $space > 1 ) {
151 151
                             $error = 'Expected 1 space after comma in function call; %s found';
152
-                            $data  = [$space];
153
-                            $fix   = $phpcsFile->addFixableError($error, $nextSeparator, 'TooMuchSpaceAfterComma', $data);
154
-                            if ($fix === true) {
155
-                                $phpcsFile->fixer->replaceToken(($nextSeparator + 1), ' ');
152
+                            $data  = [ $space ];
153
+                            $fix   = $phpcsFile->addFixableError( $error, $nextSeparator, 'TooMuchSpaceAfterComma', $data );
154
+                            if ( $fix === true ) {
155
+                                $phpcsFile->fixer->replaceToken( ( $nextSeparator + 1 ), ' ' );
156 156
                             }
157 157
                         }
158 158
                     }
159 159
                 }//end if
160 160
             } else {
161 161
                 // Token is a variable.
162
-                $nextToken = $phpcsFile->findNext(Tokens::$emptyTokens, ($nextSeparator + 1), $closeBracket, true);
163
-                if ($nextToken !== false) {
164
-                    if ($tokens[$nextToken]['code'] === T_EQUAL) {
165
-                        if (($tokens[($nextToken - 1)]['code']) !== T_WHITESPACE) {
162
+                $nextToken = $phpcsFile->findNext( Tokens::$emptyTokens, ( $nextSeparator + 1 ), $closeBracket, true );
163
+                if ( $nextToken !== false ) {
164
+                    if ( $tokens[ $nextToken ][ 'code' ] === T_EQUAL ) {
165
+                        if ( ( $tokens[ ( $nextToken - 1 ) ][ 'code' ] ) !== T_WHITESPACE ) {
166 166
                             $error = 'Expected 1 space before = sign of default value';
167
-                            $fix   = $phpcsFile->addFixableError($error, $nextToken, 'NoSpaceBeforeEquals');
168
-                            if ($fix === true) {
169
-                                $phpcsFile->fixer->addContentBefore($nextToken, ' ');
167
+                            $fix   = $phpcsFile->addFixableError( $error, $nextToken, 'NoSpaceBeforeEquals' );
168
+                            if ( $fix === true ) {
169
+                                $phpcsFile->fixer->addContentBefore( $nextToken, ' ' );
170 170
                             }
171 171
                         }
172 172
 
173
-                        if ($tokens[($nextToken + 1)]['code'] !== T_WHITESPACE) {
173
+                        if ( $tokens[ ( $nextToken + 1 ) ][ 'code' ] !== T_WHITESPACE ) {
174 174
                             $error = 'Expected 1 space after = sign of default value';
175
-                            $fix   = $phpcsFile->addFixableError($error, $nextToken, 'NoSpaceAfterEquals');
176
-                            if ($fix === true) {
177
-                                $phpcsFile->fixer->addContent($nextToken, ' ');
175
+                            $fix   = $phpcsFile->addFixableError( $error, $nextToken, 'NoSpaceAfterEquals' );
176
+                            if ( $fix === true ) {
177
+                                $phpcsFile->fixer->addContent( $nextToken, ' ' );
178 178
                             }
179 179
                         }
180 180
                     }
Please login to merge, or discard this patch.