• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

PHPCSStandards / PHP_CodeSniffer / 15253296250

26 May 2025 11:55AM UTC coverage: 78.632% (+0.3%) from 78.375%
15253296250

Pull #1105

github

web-flow
Merge d9441d98f into caf806050
Pull Request #1105: Skip tests when 'git' command is not available

19665 of 25009 relevant lines covered (78.63%)

88.67 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

98.77
/src/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php
1
<?php
2
/**
3
 * Ensure single and multi-line function declarations are defined correctly.
4
 *
5
 * @author    Greg Sherwood <gsherwood@squiz.net>
6
 * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600)
7
 * @license   https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
8
 */
9

10
namespace PHP_CodeSniffer\Standards\PEAR\Sniffs\Functions;
11

12
use PHP_CodeSniffer\Files\File;
13
use PHP_CodeSniffer\Sniffs\Sniff;
14
use PHP_CodeSniffer\Standards\Generic\Sniffs\Functions\OpeningFunctionBraceBsdAllmanSniff;
15
use PHP_CodeSniffer\Standards\Generic\Sniffs\Functions\OpeningFunctionBraceKernighanRitchieSniff;
16
use PHP_CodeSniffer\Util\Tokens;
17

18
class FunctionDeclarationSniff implements Sniff
19
{
20

21
    /**
22
     * The number of spaces code should be indented.
23
     *
24
     * @var integer
25
     */
26
    public $indent = 4;
27

28

29
    /**
30
     * Returns an array of tokens this test wants to listen for.
31
     *
32
     * @return array<int|string>
33
     */
34
    public function register()
3✔
35
    {
36
        return [
2✔
37
            T_FUNCTION,
3✔
38
            T_CLOSURE,
3✔
39
        ];
2✔
40

41
    }//end register()
42

43

44
    /**
45
     * Processes this test, when one of its tokens is encountered.
46
     *
47
     * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
48
     * @param int                         $stackPtr  The position of the current token
49
     *                                               in the stack passed in $tokens.
50
     *
51
     * @return void
52
     */
53
    public function process(File $phpcsFile, $stackPtr)
3✔
54
    {
55
        $tokens = $phpcsFile->getTokens();
3✔
56

57
        if (isset($tokens[$stackPtr]['parenthesis_opener']) === false
3✔
58
            || isset($tokens[$stackPtr]['parenthesis_closer']) === false
3✔
59
            || $tokens[$stackPtr]['parenthesis_opener'] === null
3✔
60
            || $tokens[$stackPtr]['parenthesis_closer'] === null
3✔
61
        ) {
62
            return;
×
63
        }
64

65
        $openBracket  = $tokens[$stackPtr]['parenthesis_opener'];
3✔
66
        $closeBracket = $tokens[$stackPtr]['parenthesis_closer'];
3✔
67

68
        if (strtolower($tokens[$stackPtr]['content']) === 'function') {
3✔
69
            // Must be one space after the FUNCTION keyword.
70
            if ($tokens[($stackPtr + 1)]['content'] === $phpcsFile->eolChar) {
3✔
71
                $spaces = 'newline';
3✔
72
            } else if ($tokens[($stackPtr + 1)]['code'] === T_WHITESPACE) {
3✔
73
                $spaces = $tokens[($stackPtr + 1)]['length'];
3✔
74
            } else {
75
                $spaces = 0;
3✔
76
            }
77

78
            if ($spaces !== 1) {
3✔
79
                $error = 'Expected 1 space after FUNCTION keyword; %s found';
3✔
80
                $data  = [$spaces];
3✔
81
                $fix   = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceAfterFunction', $data);
3✔
82
                if ($fix === true) {
3✔
83
                    if ($spaces === 0) {
3✔
84
                        $phpcsFile->fixer->addContent($stackPtr, ' ');
3✔
85
                    } else {
86
                        $phpcsFile->fixer->replaceToken(($stackPtr + 1), ' ');
3✔
87
                    }
88
                }
89
            }
90
        }//end if
91

92
        // Must be no space before the opening parenthesis. For closures, this is
93
        // enforced by the previous check because there is no content between the keywords
94
        // and the opening parenthesis.
95
        // Unfinished closures are tokenized as T_FUNCTION however, and can be excluded
96
        // by checking if the function has a name.
97
        if ($tokens[$stackPtr]['code'] === T_FUNCTION) {
3✔
98
            $methodProps = $phpcsFile->getMethodProperties($stackPtr);
3✔
99
            $methodName  = $phpcsFile->getDeclarationName($stackPtr);
3✔
100
            if ($methodName !== '') {
3✔
101
                if ($tokens[($openBracket - 1)]['content'] === $phpcsFile->eolChar) {
3✔
102
                    $spaces = 'newline';
3✔
103
                } else if ($tokens[($openBracket - 1)]['code'] === T_WHITESPACE) {
3✔
104
                    $spaces = $tokens[($openBracket - 1)]['length'];
3✔
105
                } else {
106
                    $spaces = 0;
3✔
107
                }
108

109
                if ($spaces !== 0) {
3✔
110
                    $error = 'Expected 0 spaces before opening parenthesis; %s found';
3✔
111
                    $data  = [$spaces];
3✔
112
                    $fix   = $phpcsFile->addFixableError($error, $openBracket, 'SpaceBeforeOpenParen', $data);
3✔
113
                    if ($fix === true) {
3✔
114
                        $phpcsFile->fixer->replaceToken(($openBracket - 1), '');
3✔
115
                    }
116
                }
117

118
                // Must be no space before semicolon in abstract/interface methods.
119
                if ($methodProps['has_body'] === false) {
3✔
120
                    $end = $phpcsFile->findNext(T_SEMICOLON, $closeBracket);
3✔
121
                    if ($end !== false) {
3✔
122
                        if ($tokens[($end - 1)]['content'] === $phpcsFile->eolChar) {
3✔
123
                            $spaces = 'newline';
3✔
124
                        } else if ($tokens[($end - 1)]['code'] === T_WHITESPACE) {
3✔
125
                            $spaces = $tokens[($end - 1)]['length'];
3✔
126
                        } else {
127
                            $spaces = 0;
3✔
128
                        }
129

130
                        if ($spaces !== 0) {
3✔
131
                            $error = 'Expected 0 spaces before semicolon; %s found';
3✔
132
                            $data  = [$spaces];
3✔
133
                            $fix   = $phpcsFile->addFixableError($error, $end, 'SpaceBeforeSemicolon', $data);
3✔
134
                            if ($fix === true) {
3✔
135
                                $phpcsFile->fixer->replaceToken(($end - 1), '');
3✔
136
                            }
137
                        }
138
                    }
139
                }//end if
140
            }//end if
141
        }//end if
142

143
        // Must be one space before and after USE keyword for closures.
144
        if ($tokens[$stackPtr]['code'] === T_CLOSURE) {
3✔
145
            $use = $phpcsFile->findNext(T_USE, ($closeBracket + 1), $tokens[$stackPtr]['scope_opener']);
3✔
146
            if ($use !== false) {
3✔
147
                if ($tokens[($use + 1)]['code'] !== T_WHITESPACE) {
3✔
148
                    $length = 0;
3✔
149
                } else if ($tokens[($use + 1)]['content'] === "\t") {
3✔
150
                    $length = '\t';
×
151
                } else {
152
                    $length = $tokens[($use + 1)]['length'];
3✔
153
                }
154

155
                if ($length !== 1) {
3✔
156
                    $error = 'Expected 1 space after USE keyword; found %s';
3✔
157
                    $data  = [$length];
3✔
158
                    $fix   = $phpcsFile->addFixableError($error, $use, 'SpaceAfterUse', $data);
3✔
159
                    if ($fix === true) {
3✔
160
                        if ($length === 0) {
3✔
161
                            $phpcsFile->fixer->addContent($use, ' ');
3✔
162
                        } else {
163
                            $phpcsFile->fixer->replaceToken(($use + 1), ' ');
3✔
164
                        }
165
                    }
166
                }
167

168
                if ($tokens[($use - 1)]['code'] !== T_WHITESPACE) {
3✔
169
                    $length = 0;
3✔
170
                } else if ($tokens[($use - 1)]['content'] === "\t") {
3✔
171
                    $length = '\t';
×
172
                } else {
173
                    $length = $tokens[($use - 1)]['length'];
3✔
174
                }
175

176
                if ($length !== 1) {
3✔
177
                    $error = 'Expected 1 space before USE keyword; found %s';
3✔
178
                    $data  = [$length];
3✔
179
                    $fix   = $phpcsFile->addFixableError($error, $use, 'SpaceBeforeUse', $data);
3✔
180
                    if ($fix === true) {
3✔
181
                        if ($length === 0) {
3✔
182
                            $phpcsFile->fixer->addContentBefore($use, ' ');
3✔
183
                        } else {
184
                            $phpcsFile->fixer->replaceToken(($use - 1), ' ');
3✔
185
                        }
186
                    }
187
                }
188
            }//end if
189
        }//end if
190

191
        if ($this->isMultiLineDeclaration($phpcsFile, $stackPtr, $openBracket, $tokens) === true) {
3✔
192
            $this->processMultiLineDeclaration($phpcsFile, $stackPtr, $tokens);
3✔
193
        } else {
194
            $this->processSingleLineDeclaration($phpcsFile, $stackPtr, $tokens);
3✔
195
        }
196

197
    }//end process()
1✔
198

199

200
    /**
201
     * Determine if this is a multi-line function declaration.
202
     *
203
     * @param \PHP_CodeSniffer\Files\File $phpcsFile   The file being scanned.
204
     * @param int                         $stackPtr    The position of the current token
205
     *                                                 in the stack passed in $tokens.
206
     * @param int                         $openBracket The position of the opening bracket
207
     *                                                 in the stack passed in $tokens.
208
     * @param array                       $tokens      The stack of tokens that make up
209
     *                                                 the file.
210
     *
211
     * @return bool
212
     */
213
    public function isMultiLineDeclaration($phpcsFile, $stackPtr, $openBracket, $tokens)
3✔
214
    {
215
        $closeBracket = $tokens[$openBracket]['parenthesis_closer'];
3✔
216
        if ($tokens[$openBracket]['line'] !== $tokens[$closeBracket]['line']) {
3✔
217
            return true;
3✔
218
        }
219

220
        // Closures may use the USE keyword and so be multi-line in this way.
221
        if ($tokens[$stackPtr]['code'] === T_CLOSURE) {
3✔
222
            $use = $phpcsFile->findNext(T_USE, ($closeBracket + 1), $tokens[$stackPtr]['scope_opener']);
3✔
223
            if ($use !== false) {
3✔
224
                // If the opening and closing parenthesis of the use statement
225
                // are also on the same line, this is a single line declaration.
226
                if ($tokens[$tokens[$use]['parenthesis_opener']]['line'] !== $tokens[$tokens[$use]['parenthesis_closer']]['line']) {
3✔
227
                    return true;
3✔
228
                }
229
            }
230
        }
231

232
        return false;
3✔
233

234
    }//end isMultiLineDeclaration()
235

236

237
    /**
238
     * Processes single-line declarations.
239
     *
240
     * Just uses the Generic BSD-Allman brace sniff.
241
     *
242
     * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
243
     * @param int                         $stackPtr  The position of the current token
244
     *                                               in the stack passed in $tokens.
245
     * @param array                       $tokens    The stack of tokens that make up
246
     *                                               the file.
247
     *
248
     * @return void
249
     */
250
    public function processSingleLineDeclaration($phpcsFile, $stackPtr, $tokens)
3✔
251
    {
252
        if ($tokens[$stackPtr]['code'] === T_CLOSURE) {
3✔
253
            $sniff = new OpeningFunctionBraceKernighanRitchieSniff();
3✔
254
        } else {
255
            $sniff = new OpeningFunctionBraceBsdAllmanSniff();
3✔
256
        }
257

258
        $sniff->checkClosures = true;
3✔
259
        $sniff->process($phpcsFile, $stackPtr);
3✔
260

261
    }//end processSingleLineDeclaration()
1✔
262

263

264
    /**
265
     * Processes multi-line declarations.
266
     *
267
     * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
268
     * @param int                         $stackPtr  The position of the current token
269
     *                                               in the stack passed in $tokens.
270
     * @param array                       $tokens    The stack of tokens that make up
271
     *                                               the file.
272
     *
273
     * @return void
274
     */
275
    public function processMultiLineDeclaration($phpcsFile, $stackPtr, $tokens)
3✔
276
    {
277
        $this->processArgumentList($phpcsFile, $stackPtr, $this->indent);
3✔
278

279
        $closeBracket = $tokens[$stackPtr]['parenthesis_closer'];
3✔
280
        if ($tokens[$stackPtr]['code'] === T_CLOSURE) {
3✔
281
            $use = $phpcsFile->findNext(T_USE, ($closeBracket + 1), $tokens[$stackPtr]['scope_opener']);
3✔
282
            if ($use !== false && isset($tokens[$use]['parenthesis_closer']) === true) {
3✔
283
                $closeBracket = $tokens[$use]['parenthesis_closer'];
3✔
284
            }
285
        }
286

287
        if (isset($tokens[$stackPtr]['scope_opener']) === false) {
3✔
288
            return;
3✔
289
        }
290

291
        // The opening brace needs to be on the same line as the closing parenthesis.
292
        // There should only be one space between the closing parenthesis - or the end of the
293
        // return type - and the opening brace.
294
        $opener = $tokens[$stackPtr]['scope_opener'];
3✔
295
        if ($tokens[$opener]['line'] !== $tokens[$closeBracket]['line']) {
3✔
296
            $error = 'The closing parenthesis and the opening brace of a multi-line function declaration must be on the same line';
3✔
297
            $code  = 'NewlineBeforeOpenBrace';
3✔
298

299
            $prev = $phpcsFile->findPrevious(Tokens::EMPTY_TOKENS, ($opener - 1), $closeBracket, true);
3✔
300
            if ($tokens[$prev]['line'] === $tokens[$opener]['line']) {
3✔
301
                // End of the return type is not on the same line as the close parenthesis.
302
                $phpcsFile->addError($error, $opener, $code);
3✔
303
            } else {
304
                $fix = $phpcsFile->addFixableError($error, $opener, $code);
3✔
305
                if ($fix === true) {
3✔
306
                    $phpcsFile->fixer->beginChangeset();
3✔
307
                    $phpcsFile->fixer->addContent($prev, ' {');
3✔
308

309
                    // If the opener is on a line by itself, removing it will create
310
                    // an empty line, so remove the entire line instead.
311
                    $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($opener - 1), $closeBracket, true);
3✔
312
                    $next = $phpcsFile->findNext(T_WHITESPACE, ($opener + 1), null, true);
3✔
313

314
                    if ($tokens[$prev]['line'] < $tokens[$opener]['line']
3✔
315
                        && $tokens[$next]['line'] > $tokens[$opener]['line']
3✔
316
                    ) {
317
                        // Clear the whole line.
318
                        for ($i = ($prev + 1); $i < $next; $i++) {
3✔
319
                            if ($tokens[$i]['line'] === $tokens[$opener]['line']) {
3✔
320
                                $phpcsFile->fixer->replaceToken($i, '');
3✔
321
                            }
322
                        }
323
                    } else {
324
                        // Just remove the opener.
325
                        $phpcsFile->fixer->replaceToken($opener, '');
3✔
326
                        if ($tokens[$next]['line'] === $tokens[$opener]['line']
3✔
327
                            && ($opener + 1) !== $next
3✔
328
                        ) {
329
                            $phpcsFile->fixer->replaceToken(($opener + 1), '');
3✔
330
                        }
331
                    }
332

333
                    $phpcsFile->fixer->endChangeset();
3✔
334
                }//end if
335

336
                return;
3✔
337
            }//end if
338
        }//end if
339

340
        $prev = $tokens[($opener - 1)];
3✔
341
        if ($prev['code'] !== T_WHITESPACE) {
3✔
342
            $length = 0;
3✔
343
        } else {
344
            $length = strlen($prev['content']);
3✔
345
        }
346

347
        if ($length !== 1) {
3✔
348
            $error = 'There must be a single space between the closing parenthesis/return type and the opening brace of a multi-line function declaration; found %s spaces';
3✔
349
            $fix   = $phpcsFile->addFixableError($error, ($opener - 1), 'SpaceBeforeOpenBrace', [$length]);
3✔
350
            if ($fix === true) {
3✔
351
                if ($length === 0) {
3✔
352
                    $phpcsFile->fixer->addContentBefore($opener, ' ');
3✔
353
                } else {
354
                    $phpcsFile->fixer->replaceToken(($opener - 1), ' ');
3✔
355
                }
356
            }
357
        }
358

359
    }//end processMultiLineDeclaration()
1✔
360

361

362
    /**
363
     * Processes multi-line argument list declarations.
364
     *
365
     * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
366
     * @param int                         $stackPtr  The position of the current token
367
     *                                               in the stack passed in $tokens.
368
     * @param int                         $indent    The number of spaces code should be indented.
369
     * @param string                      $type      The type of the token the brackets
370
     *                                               belong to.
371
     *
372
     * @return void
373
     */
374
    public function processArgumentList($phpcsFile, $stackPtr, $indent, $type='function')
3✔
375
    {
376
        $tokens = $phpcsFile->getTokens();
3✔
377

378
        // We need to work out how far indented the function
379
        // declaration itself is, so we can work out how far to
380
        // indent parameters.
381
        $functionIndent = 0;
3✔
382
        for ($i = ($stackPtr - 1); $i >= 0; $i--) {
3✔
383
            if ($tokens[$i]['line'] !== $tokens[$stackPtr]['line']) {
3✔
384
                break;
3✔
385
            }
386
        }
387

388
        // Move $i back to the line the function is or to 0.
389
        $i++;
3✔
390

391
        if ($tokens[$i]['code'] === T_WHITESPACE) {
3✔
392
            $functionIndent = $tokens[$i]['length'];
3✔
393
        }
394

395
        // The closing parenthesis must be on a new line, even
396
        // when checking abstract function definitions.
397
        $closeBracket = $tokens[$stackPtr]['parenthesis_closer'];
3✔
398
        $prev         = $phpcsFile->findPrevious(
3✔
399
            T_WHITESPACE,
3✔
400
            ($closeBracket - 1),
3✔
401
            null,
3✔
402
            true
3✔
403
        );
2✔
404

405
        if ($tokens[$closeBracket]['line'] !== $tokens[$tokens[$closeBracket]['parenthesis_opener']]['line']
3✔
406
            && $tokens[$prev]['line'] === $tokens[$closeBracket]['line']
3✔
407
        ) {
408
            $error = 'The closing parenthesis of a multi-line '.$type.' declaration must be on a new line';
3✔
409
            $fix   = $phpcsFile->addFixableError($error, $closeBracket, 'CloseBracketLine');
3✔
410
            if ($fix === true) {
3✔
411
                $phpcsFile->fixer->addNewlineBefore($closeBracket);
3✔
412
            }
413
        }
414

415
        // If this is a closure and is using a USE statement, the closing
416
        // parenthesis we need to look at from now on is the closing parenthesis
417
        // of the USE statement.
418
        if ($tokens[$stackPtr]['code'] === T_CLOSURE) {
3✔
419
            $use = $phpcsFile->findNext(T_USE, ($closeBracket + 1), $tokens[$stackPtr]['scope_opener']);
3✔
420
            if ($use !== false && isset($tokens[$use]['parenthesis_closer']) === true) {
3✔
421
                $closeBracket = $tokens[$use]['parenthesis_closer'];
3✔
422

423
                $prev = $phpcsFile->findPrevious(
3✔
424
                    T_WHITESPACE,
3✔
425
                    ($closeBracket - 1),
3✔
426
                    null,
3✔
427
                    true
3✔
428
                );
2✔
429

430
                if ($tokens[$closeBracket]['line'] !== $tokens[$tokens[$closeBracket]['parenthesis_opener']]['line']
3✔
431
                    && $tokens[$prev]['line'] === $tokens[$closeBracket]['line']
3✔
432
                ) {
433
                    $error = 'The closing parenthesis of a multi-line use declaration must be on a new line';
3✔
434
                    $fix   = $phpcsFile->addFixableError($error, $closeBracket, 'UseCloseBracketLine');
3✔
435
                    if ($fix === true) {
3✔
436
                        $phpcsFile->fixer->addNewlineBefore($closeBracket);
3✔
437
                    }
438
                }
439
            }//end if
440
        }//end if
441

442
        // Each line between the parenthesis should be indented 4 spaces.
443
        $openBracket = $tokens[$stackPtr]['parenthesis_opener'];
3✔
444
        $lastLine    = $tokens[$openBracket]['line'];
3✔
445
        for ($i = ($openBracket + 1); $i < $closeBracket; $i++) {
3✔
446
            if ($tokens[$i]['line'] !== $lastLine) {
3✔
447
                if ($i === $tokens[$stackPtr]['parenthesis_closer']
3✔
448
                    || ($tokens[$i]['code'] === T_WHITESPACE
3✔
449
                    && (($i + 1) === $closeBracket
3✔
450
                    || ($i + 1) === $tokens[$stackPtr]['parenthesis_closer']))
3✔
451
                ) {
452
                    // Closing braces need to be indented to the same level
453
                    // as the function.
454
                    $expectedIndent = $functionIndent;
3✔
455
                } else {
456
                    $expectedIndent = ($functionIndent + $indent);
3✔
457
                }
458

459
                // We changed lines, so this should be a whitespace indent token.
460
                $foundIndent = 0;
3✔
461
                if ($tokens[$i]['code'] === T_WHITESPACE
3✔
462
                    && $tokens[$i]['line'] !== $tokens[($i + 1)]['line']
3✔
463
                ) {
464
                    $error = 'Blank lines are not allowed in a multi-line '.$type.' declaration';
3✔
465
                    $fix   = $phpcsFile->addFixableError($error, $i, 'EmptyLine');
3✔
466
                    if ($fix === true) {
3✔
467
                        $phpcsFile->fixer->replaceToken($i, '');
3✔
468
                    }
469

470
                    // This is an empty line, so don't check the indent.
471
                    continue;
3✔
472
                } else if ($tokens[$i]['code'] === T_WHITESPACE) {
3✔
473
                    $foundIndent = $tokens[$i]['length'];
3✔
474
                } else if ($tokens[$i]['code'] === T_DOC_COMMENT_WHITESPACE) {
3✔
475
                    $foundIndent = $tokens[$i]['length'];
3✔
476
                    ++$expectedIndent;
3✔
477
                }
478

479
                if ($expectedIndent !== $foundIndent) {
3✔
480
                    $error = 'Multi-line '.$type.' declaration not indented correctly; expected %s spaces but found %s';
3✔
481
                    $data  = [
2✔
482
                        $expectedIndent,
3✔
483
                        $foundIndent,
3✔
484
                    ];
2✔
485

486
                    $fix = $phpcsFile->addFixableError($error, $i, 'Indent', $data);
3✔
487
                    if ($fix === true) {
3✔
488
                        $spaces = str_repeat(' ', $expectedIndent);
3✔
489
                        if ($foundIndent === 0) {
3✔
490
                            $phpcsFile->fixer->addContentBefore($i, $spaces);
3✔
491
                        } else {
492
                            $phpcsFile->fixer->replaceToken($i, $spaces);
3✔
493
                        }
494
                    }
495
                }
496

497
                $lastLine = $tokens[$i]['line'];
3✔
498
            }//end if
499

500
            if ($tokens[$i]['code'] === T_OPEN_PARENTHESIS
3✔
501
                && isset($tokens[$i]['parenthesis_closer']) === true
3✔
502
            ) {
503
                $prevNonEmpty = $phpcsFile->findPrevious(Tokens::EMPTY_TOKENS, ($i - 1), null, true);
3✔
504
                if ($tokens[$prevNonEmpty]['code'] !== T_USE) {
3✔
505
                    // Since PHP 8.1, a default value can contain a class instantiation.
506
                    // Skip over these "function calls" as they have their own indentation rules.
507
                    $i        = $tokens[$i]['parenthesis_closer'];
3✔
508
                    $lastLine = $tokens[$i]['line'];
3✔
509
                    continue;
3✔
510
                }
511
            }
512

513
            if ($tokens[$i]['code'] === T_ARRAY || $tokens[$i]['code'] === T_OPEN_SHORT_ARRAY) {
3✔
514
                // Skip arrays as they have their own indentation rules.
515
                if ($tokens[$i]['code'] === T_OPEN_SHORT_ARRAY) {
3✔
516
                    $i = $tokens[$i]['bracket_closer'];
3✔
517
                } else {
518
                    $i = $tokens[$i]['parenthesis_closer'];
3✔
519
                }
520

521
                $lastLine = $tokens[$i]['line'];
3✔
522
                continue;
3✔
523
            }
524

525
            if ($tokens[$i]['code'] === T_ATTRIBUTE) {
3✔
526
                // Skip attributes as they have their own indentation rules.
527
                $i        = $tokens[$i]['attribute_closer'];
3✔
528
                $lastLine = $tokens[$i]['line'];
3✔
529
                continue;
3✔
530
            }
531
        }//end for
532

533
    }//end processArgumentList()
1✔
534

535

536
}//end class
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc