-
-
Notifications
You must be signed in to change notification settings - Fork 101
Expand file tree
/
Copy pathFunctionCallSignatureSniff.php
More file actions
632 lines (550 loc) · 26.8 KB
/
FunctionCallSignatureSniff.php
File metadata and controls
632 lines (550 loc) · 26.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
<?php
/**
* Ensures function calls are formatted correctly.
*
* @author Greg Sherwood <gsherwood@squiz.net>
* @copyright 2006-2023 Squiz Pty Ltd (ABN 77 084 670 600)
* @copyright 2023 PHPCSStandards and contributors
* @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/HEAD/licence.txt BSD Licence
*/
namespace PHP_CodeSniffer\Standards\PEAR\Sniffs\Functions;
use PHP_CodeSniffer\Files\File;
use PHP_CodeSniffer\Sniffs\Sniff;
use PHP_CodeSniffer\Util\Tokens;
class FunctionCallSignatureSniff implements Sniff
{
/**
* The number of spaces code should be indented.
*
* @var integer
*/
public $indent = 4;
/**
* If TRUE, multiple arguments can be defined per line in a multi-line call.
*
* @var boolean
*/
public $allowMultipleArguments = true;
/**
* How many spaces should follow the opening bracket.
*
* @var integer
*/
public $requiredSpacesAfterOpen = 0;
/**
* How many spaces should precede the closing bracket.
*
* @var integer
*/
public $requiredSpacesBeforeClose = 0;
/**
* Returns an array of tokens this test wants to listen for.
*
* @return array<int|string>
*/
public function register()
{
$tokens = Tokens::FUNCTION_NAME_TOKENS;
$tokens[] = T_VARIABLE;
$tokens[] = T_CLOSE_CURLY_BRACKET;
$tokens[] = T_CLOSE_SQUARE_BRACKET;
$tokens[] = T_CLOSE_PARENTHESIS;
return $tokens;
}
/**
* Processes this test, when one of its tokens is encountered.
*
* @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
* @param int $stackPtr The position of the current token
* in the stack passed in $tokens.
*
* @return void
*/
public function process(File $phpcsFile, int $stackPtr)
{
$this->requiredSpacesAfterOpen = (int) $this->requiredSpacesAfterOpen;
$this->requiredSpacesBeforeClose = (int) $this->requiredSpacesBeforeClose;
$tokens = $phpcsFile->getTokens();
if ($tokens[$stackPtr]['code'] === T_CLOSE_CURLY_BRACKET
&& isset($tokens[$stackPtr]['scope_condition']) === true
) {
// Not a function call.
return;
}
// Find the next non-empty token.
$openBracket = $phpcsFile->findNext(Tokens::EMPTY_TOKENS, ($stackPtr + 1), null, true);
if ($tokens[$openBracket]['code'] !== T_OPEN_PARENTHESIS) {
// Not a function call.
return;
}
if (isset($tokens[$openBracket]['parenthesis_closer']) === false) {
// Not a function call.
return;
}
// Find the previous non-empty token.
$search = Tokens::EMPTY_TOKENS;
$search[] = T_BITWISE_AND;
$previous = $phpcsFile->findPrevious($search, ($stackPtr - 1), null, true);
if ($tokens[$previous]['code'] === T_FUNCTION) {
// It's a function definition, not a function call.
return;
}
$closeBracket = $tokens[$openBracket]['parenthesis_closer'];
if ($tokens[$stackPtr]['code'] !== T_ANON_CLASS
&& ($stackPtr + 1) !== $openBracket
) {
// Checking this: $value = my_function[*](...).
$error = 'Space before opening parenthesis of function call prohibited';
$fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceBeforeOpenBracket');
if ($fix === true) {
$phpcsFile->fixer->beginChangeset();
for ($i = ($stackPtr + 1); $i < $openBracket; $i++) {
$phpcsFile->fixer->replaceToken($i, '');
}
// Modify the bracket as well to ensure a conflict if the bracket
// has been changed in some way by another sniff.
$phpcsFile->fixer->replaceToken($openBracket, '(');
$phpcsFile->fixer->endChangeset();
}
}
$next = $phpcsFile->findNext(T_WHITESPACE, ($closeBracket + 1), null, true);
if ($tokens[$next]['code'] === T_SEMICOLON) {
if (isset(Tokens::EMPTY_TOKENS[$tokens[($closeBracket + 1)]['code']]) === true) {
$error = 'Space after closing parenthesis of function call prohibited';
$fix = $phpcsFile->addFixableError($error, $closeBracket, 'SpaceAfterCloseBracket');
if ($fix === true) {
$phpcsFile->fixer->beginChangeset();
for ($i = ($closeBracket + 1); $i < $next; $i++) {
$phpcsFile->fixer->replaceToken($i, '');
}
// Modify the bracket as well to ensure a conflict if the bracket
// has been changed in some way by another sniff.
$phpcsFile->fixer->replaceToken($closeBracket, ')');
$phpcsFile->fixer->endChangeset();
}
}
}
// Check if this is a single line or multi-line function call.
if ($this->isMultiLineCall($phpcsFile, $stackPtr, $openBracket, $tokens) === true) {
$this->processMultiLineCall($phpcsFile, $stackPtr, $openBracket, $tokens);
} else {
$this->processSingleLineCall($phpcsFile, $stackPtr, $openBracket, $tokens);
}
}
/**
* Determine if this is a multi-line function call.
*
* @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
* @param int $stackPtr The position of the current token
* in the stack passed in $tokens.
* @param int $openBracket The position of the opening bracket
* in the stack passed in $tokens.
* @param array $tokens The stack of tokens that make up
* the file.
*
* @return bool
*/
public function isMultiLineCall(File $phpcsFile, int $stackPtr, int $openBracket, array $tokens)
{
$closeBracket = $tokens[$openBracket]['parenthesis_closer'];
if ($tokens[$openBracket]['line'] !== $tokens[$closeBracket]['line']) {
return true;
}
return false;
}
/**
* Processes single-line calls.
*
* @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
* @param int $stackPtr The position of the current token
* in the stack passed in $tokens.
* @param int $openBracket The position of the opening bracket
* in the stack passed in $tokens.
* @param array $tokens The stack of tokens that make up
* the file.
*
* @return void
*/
public function processSingleLineCall(File $phpcsFile, int $stackPtr, int $openBracket, array $tokens)
{
$closer = $tokens[$openBracket]['parenthesis_closer'];
if ($openBracket === ($closer - 1)) {
return;
}
// If the function call has no arguments or comments, enforce 0 spaces.
$next = $phpcsFile->findNext(T_WHITESPACE, ($openBracket + 1), $closer, true);
if ($next === false) {
$requiredSpacesAfterOpen = 0;
$requiredSpacesBeforeClose = 0;
} else {
$requiredSpacesAfterOpen = $this->requiredSpacesAfterOpen;
$requiredSpacesBeforeClose = $this->requiredSpacesBeforeClose;
}
if ($requiredSpacesAfterOpen === 0 && $tokens[($openBracket + 1)]['code'] === T_WHITESPACE) {
// Checking this: $value = my_function([*]...).
$error = 'Space after opening parenthesis of function call prohibited';
$fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceAfterOpenBracket');
if ($fix === true) {
$phpcsFile->fixer->replaceToken(($openBracket + 1), '');
}
} elseif ($requiredSpacesAfterOpen > 0) {
$spaceAfterOpen = 0;
if ($tokens[($openBracket + 1)]['code'] === T_WHITESPACE) {
$spaceAfterOpen = $tokens[($openBracket + 1)]['length'];
}
if ($spaceAfterOpen !== $requiredSpacesAfterOpen) {
$error = 'Expected %s spaces after opening parenthesis; %s found';
$data = [
$requiredSpacesAfterOpen,
$spaceAfterOpen,
];
$fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceAfterOpenBracket', $data);
if ($fix === true) {
$padding = str_repeat(' ', $requiredSpacesAfterOpen);
if ($spaceAfterOpen === 0) {
$phpcsFile->fixer->addContent($openBracket, $padding);
} else {
$phpcsFile->fixer->replaceToken(($openBracket + 1), $padding);
}
}
}
}
// Checking this: $value = my_function(...[*]).
$spaceBeforeClose = 0;
$prev = $phpcsFile->findPrevious(T_WHITESPACE, ($closer - 1), $openBracket, true);
if ($tokens[$prev]['code'] === T_END_HEREDOC || $tokens[$prev]['code'] === T_END_NOWDOC) {
// Need a newline after these tokens, so ignore this rule.
return;
}
if ($tokens[$prev]['line'] !== $tokens[$closer]['line']) {
$spaceBeforeClose = 'newline';
} elseif ($tokens[($closer - 1)]['code'] === T_WHITESPACE) {
$spaceBeforeClose = $tokens[($closer - 1)]['length'];
}
if ($spaceBeforeClose !== $requiredSpacesBeforeClose) {
$error = 'Expected %s spaces before closing parenthesis; %s found';
$data = [
$requiredSpacesBeforeClose,
$spaceBeforeClose,
];
$fix = $phpcsFile->addFixableError($error, $closer, 'SpaceBeforeCloseBracket', $data);
if ($fix === true) {
$padding = str_repeat(' ', $requiredSpacesBeforeClose);
if ($spaceBeforeClose === 0) {
$phpcsFile->fixer->addContentBefore($closer, $padding);
} elseif ($spaceBeforeClose === 'newline') {
$phpcsFile->fixer->beginChangeset();
$closingContent = ')';
$next = $phpcsFile->findNext(T_WHITESPACE, ($closer + 1), null, true);
if ($tokens[$next]['code'] === T_SEMICOLON) {
$closingContent .= ';';
for ($i = ($closer + 1); $i <= $next; $i++) {
$phpcsFile->fixer->replaceToken($i, '');
}
}
// We want to jump over any whitespace or inline comment and
// move the closing parenthesis after any other token.
$prev = ($closer - 1);
while (isset(Tokens::EMPTY_TOKENS[$tokens[$prev]['code']]) === true) {
if (($tokens[$prev]['code'] === T_COMMENT)
&& (strpos($tokens[$prev]['content'], '*/') !== false)
) {
break;
}
$prev--;
}
$phpcsFile->fixer->addContent($prev, $padding . $closingContent);
$prevNonWhitespace = $phpcsFile->findPrevious(T_WHITESPACE, ($closer - 1), null, true);
for ($i = ($prevNonWhitespace + 1); $i <= $closer; $i++) {
$phpcsFile->fixer->replaceToken($i, '');
}
$phpcsFile->fixer->endChangeset();
} else {
$phpcsFile->fixer->replaceToken(($closer - 1), $padding);
}
}
}
}
/**
* Processes multi-line calls.
*
* @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
* @param int $stackPtr The position of the current token
* in the stack passed in $tokens.
* @param int $openBracket The position of the opening bracket
* in the stack passed in $tokens.
* @param array $tokens The stack of tokens that make up
* the file.
*
* @return void
*/
public function processMultiLineCall(File $phpcsFile, int $stackPtr, int $openBracket, array $tokens)
{
// We need to work out how far indented the function
// call itself is, so we can work out how far to
// indent the arguments.
$first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $stackPtr, true);
if ($first !== false
&& $tokens[$first]['code'] === T_CONSTANT_ENCAPSED_STRING
&& $tokens[($first - 1)]['code'] === T_CONSTANT_ENCAPSED_STRING
) {
// We are in a multi-line string, so find the start and use
// the indent from there.
$prev = $phpcsFile->findPrevious(T_CONSTANT_ENCAPSED_STRING, ($first - 2), null, true);
$first = $phpcsFile->findFirstOnLine(Tokens::EMPTY_TOKENS, $prev, true);
if ($first === false) {
$first = ($prev + 1);
}
}
$foundFunctionIndent = 0;
if ($first !== false) {
if ($tokens[$first]['code'] === T_INLINE_HTML
|| ($tokens[$first]['code'] === T_CONSTANT_ENCAPSED_STRING
&& $tokens[($first - 1)]['code'] === T_CONSTANT_ENCAPSED_STRING)
) {
$trimmed = ltrim($tokens[$first]['content']);
if ($trimmed === '') {
$foundFunctionIndent = strlen($tokens[$first]['content']);
} else {
$foundFunctionIndent = (strlen($tokens[$first]['content']) - strlen($trimmed));
}
} else {
$foundFunctionIndent = ($tokens[$first]['column'] - 1);
}
}
// Make sure the function indent is divisible by the indent size.
// We round down here because this accounts for times when the
// surrounding code is indented a little too far in, and not correctly
// at a tab stop. Without this, the function will be indented a further
// $indent spaces to the right.
$functionIndent = (int) (floor($foundFunctionIndent / $this->indent) * $this->indent);
$adjustment = 0;
if ($foundFunctionIndent !== $functionIndent) {
$error = 'Opening statement of multi-line function call not indented correctly; expected %s spaces but found %s';
$data = [
$functionIndent,
$foundFunctionIndent,
];
$fix = $phpcsFile->addFixableError($error, $first, 'OpeningIndent', $data);
if ($fix === true) {
// Set adjustment for use later to determine whether argument indentation is correct when fixing.
$adjustment = ($functionIndent - $foundFunctionIndent);
$padding = str_repeat(' ', $functionIndent);
if ($foundFunctionIndent === 0) {
$phpcsFile->fixer->addContentBefore($first, $padding);
} elseif ($tokens[$first]['code'] === T_INLINE_HTML) {
$newContent = $padding . ltrim($tokens[$first]['content']);
$phpcsFile->fixer->replaceToken($first, $newContent);
} else {
$phpcsFile->fixer->replaceToken(($first - 1), $padding);
}
}
}
$next = $phpcsFile->findNext(Tokens::EMPTY_TOKENS, ($openBracket + 1), null, true);
if ($tokens[$next]['line'] === $tokens[$openBracket]['line']) {
$error = 'Opening parenthesis of a multi-line function call must be the last content on the line';
$fix = $phpcsFile->addFixableError($error, $stackPtr, 'ContentAfterOpenBracket');
if ($fix === true) {
$phpcsFile->fixer->addContent(
$openBracket,
$phpcsFile->eolChar . str_repeat(' ', ($foundFunctionIndent + $this->indent))
);
}
}
$closeBracket = $tokens[$openBracket]['parenthesis_closer'];
$prev = $phpcsFile->findPrevious(T_WHITESPACE, ($closeBracket - 1), null, true);
if ($tokens[$prev]['line'] === $tokens[$closeBracket]['line']) {
$error = 'Closing parenthesis of a multi-line function call must be on a line by itself';
$fix = $phpcsFile->addFixableError($error, $closeBracket, 'CloseBracketLine');
if ($fix === true) {
$phpcsFile->fixer->addContentBefore(
$closeBracket,
$phpcsFile->eolChar . str_repeat(' ', ($foundFunctionIndent + $this->indent))
);
}
}
// Each line between the parenthesis should be indented n spaces.
$lastLine = ($tokens[$openBracket]['line'] - 1);
$argStart = null;
$argEnd = null;
// Start processing at the first argument.
$i = $phpcsFile->findNext(T_WHITESPACE, ($openBracket + 1), null, true);
if ($tokens[$i]['line'] > ($tokens[$openBracket]['line'] + 1)) {
$error = 'The first argument in a multi-line function call must be on the line after the opening parenthesis';
$fix = $phpcsFile->addFixableError($error, $i, 'FirstArgumentPosition');
if ($fix === true) {
$phpcsFile->fixer->beginChangeset();
for ($x = ($openBracket + 1); $x < $i; $x++) {
if ($tokens[$x]['line'] === $tokens[$openBracket]['line']) {
continue;
}
if ($tokens[$x]['line'] === $tokens[$i]['line']) {
break;
}
$phpcsFile->fixer->replaceToken($x, '');
}
$phpcsFile->fixer->endChangeset();
}
}
$i = $phpcsFile->findNext(Tokens::EMPTY_TOKENS, ($openBracket + 1), null, true);
if ($tokens[($i - 1)]['code'] === T_WHITESPACE
&& $tokens[($i - 1)]['line'] === $tokens[$i]['line']
) {
// Make sure we check the indent.
$i--;
}
for ($i; $i < $closeBracket; $i++) {
if ($i > $argStart && $i < $argEnd) {
$inArg = true;
} else {
$inArg = false;
}
if ($tokens[$i]['line'] !== $lastLine) {
$lastLine = $tokens[$i]['line'];
// Ignore heredoc indentation.
if (isset(Tokens::HEREDOC_TOKENS[$tokens[$i]['code']]) === true) {
continue;
}
// Ignore multi-line string indentation.
if (isset(Tokens::STRING_TOKENS[$tokens[$i]['code']]) === true
&& $tokens[$i]['code'] === $tokens[($i - 1)]['code']
) {
continue;
}
// Ignore inline HTML.
if ($tokens[$i]['code'] === T_INLINE_HTML) {
continue;
}
if ($tokens[$i]['line'] !== $tokens[$openBracket]['line']) {
// We changed lines, so this should be a whitespace indent token, but first make
// sure it isn't a blank line because we don't need to check indent unless there
// is actually some code to indent.
if ($tokens[$i]['code'] === T_WHITESPACE) {
$nextCode = $phpcsFile->findNext(T_WHITESPACE, ($i + 1), ($closeBracket + 1), true);
if ($tokens[$nextCode]['line'] !== $lastLine) {
if ($inArg === false) {
$error = 'Empty lines are not allowed in multi-line function calls';
$fix = $phpcsFile->addFixableError($error, $i, 'EmptyLine');
if ($fix === true) {
$phpcsFile->fixer->replaceToken($i, '');
}
}
continue;
}
} else {
$nextCode = $i;
}
if ($tokens[$nextCode]['line'] === $tokens[$closeBracket]['line']) {
// Closing brace needs to be indented to the same level
// as the function call.
$inArg = false;
$expectedIndent = ($foundFunctionIndent + $adjustment);
} else {
$expectedIndent = ($foundFunctionIndent + $this->indent + $adjustment);
}
if ($tokens[$i]['code'] === T_END_HEREDOC
|| $tokens[$i]['code'] === T_END_NOWDOC
) {
continue;
}
if ($tokens[$i]['code'] !== T_WHITESPACE
&& $tokens[$i]['code'] !== T_DOC_COMMENT_WHITESPACE
) {
// Just check if it is a multi-line block comment. If so, we can
// calculate the indent from the whitespace before the content.
if ($tokens[$i]['code'] === T_COMMENT
&& $tokens[($i - 1)]['code'] === T_COMMENT
) {
$trimmedLength = strlen(ltrim($tokens[$i]['content']));
if ($trimmedLength === 0) {
// This is a blank comment line, so indenting it is
// pointless.
continue;
}
$foundIndent = (strlen($tokens[$i]['content']) - $trimmedLength);
} else {
$foundIndent = 0;
}
} else {
$foundIndent = $tokens[$i]['length'];
}
if ($foundIndent < $expectedIndent
|| ($inArg === false
&& $expectedIndent !== $foundIndent)
) {
$error = 'Multi-line function call not indented correctly; expected %s spaces but found %s';
$data = [
$expectedIndent,
$foundIndent,
];
$fix = $phpcsFile->addFixableError($error, $i, 'Indent', $data);
if ($fix === true) {
$phpcsFile->fixer->beginChangeset();
$padding = str_repeat(' ', $expectedIndent);
if ($foundIndent === 0) {
$phpcsFile->fixer->addContentBefore($i, $padding);
if (isset($tokens[$i]['scope_opener']) === true
&& $tokens[$i]['code'] !== T_START_HEREDOC
&& $tokens[$i]['code'] !== T_START_NOWDOC
) {
$phpcsFile->fixer->changeCodeBlockIndent($i, $tokens[$i]['scope_closer'], $expectedIndent);
}
} else {
if ($tokens[$i]['code'] === T_COMMENT) {
$comment = $padding . ltrim($tokens[$i]['content']);
$phpcsFile->fixer->replaceToken($i, $comment);
} else {
$phpcsFile->fixer->replaceToken($i, $padding);
}
if (isset($tokens[($i + 1)]['scope_opener']) === true
&& $tokens[($i + 1)]['code'] !== T_START_HEREDOC
&& $tokens[($i + 1)]['code'] !== T_START_NOWDOC
) {
$phpcsFile->fixer->changeCodeBlockIndent(($i + 1), $tokens[($i + 1)]['scope_closer'], ($expectedIndent - $foundIndent));
}
}
$phpcsFile->fixer->endChangeset();
}
}
} else {
$nextCode = $i;
}
if ($inArg === false) {
$argStart = $nextCode;
$argEnd = $phpcsFile->findEndOfStatement($nextCode, [T_COLON]);
}
}
// If we are within an argument we should be ignoring commas
// as these are not signalling the end of an argument.
if ($inArg === false && $tokens[$i]['code'] === T_COMMA) {
$next = $phpcsFile->findNext(Tokens::EMPTY_TOKENS, ($i + 1), $closeBracket, true);
if ($next === false) {
continue;
}
if ($this->allowMultipleArguments === false) {
// Comma has to be the last token on the line.
if ($tokens[$i]['line'] === $tokens[$next]['line']) {
$error = 'Only one argument is allowed per line in a multi-line function call';
$fix = $phpcsFile->addFixableError($error, $next, 'MultipleArguments');
if ($fix === true) {
$phpcsFile->fixer->beginChangeset();
for ($x = ($next - 1); $x > $i; $x--) {
if ($tokens[$x]['code'] !== T_WHITESPACE) {
break;
}
$phpcsFile->fixer->replaceToken($x, '');
}
$phpcsFile->fixer->addContentBefore(
$next,
$phpcsFile->eolChar . str_repeat(' ', ($foundFunctionIndent + $this->indent))
);
$phpcsFile->fixer->endChangeset();
}
}
}
$argStart = $next;
$argEnd = $phpcsFile->findEndOfStatement($next, [T_COLON]);
}
}
}
}