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

PHPCSStandards / PHP_CodeSniffer / 14523709455

17 Apr 2025 07:53PM UTC coverage: 77.921% (-0.1%) from 78.02%
14523709455

push

github

web-flow
Merge pull request #1020 from PHPCSStandards/phpcs-4.0/feature/3041-tokenizer-php-namespaced-name-tokenization

Tokenizer/PHP: namespaced names as single token, mirroring PHP 8.0+

203 of 211 new or added lines in 25 files covered. (96.21%)

6 existing lines in 3 files now uncovered.

19389 of 24883 relevant lines covered (77.92%)

85.62 hits per line

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

90.22
/src/Standards/PSR2/Sniffs/Classes/ClassDeclarationSniff.php
1
<?php
2
/**
3
 * Checks the declaration of the class and its inheritance is correct.
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\PSR2\Sniffs\Classes;
11

12
use PHP_CodeSniffer\Files\File;
13
use PHP_CodeSniffer\Standards\PEAR\Sniffs\Classes\ClassDeclarationSniff as PEARClassDeclarationSniff;
14
use PHP_CodeSniffer\Util\Tokens;
15

16
class ClassDeclarationSniff extends PEARClassDeclarationSniff
17
{
18

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

26

27
    /**
28
     * Processes this test, when one of its tokens is encountered.
29
     *
30
     * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
31
     * @param int                         $stackPtr  The position of the current token
32
     *                                               in the stack passed in $tokens.
33
     *
34
     * @return void
35
     */
36
    public function process(File $phpcsFile, $stackPtr)
3✔
37
    {
38
        // We want all the errors from the PEAR standard, plus some of our own.
39
        parent::process($phpcsFile, $stackPtr);
3✔
40

41
        // Just in case.
42
        $tokens = $phpcsFile->getTokens();
3✔
43
        if (isset($tokens[$stackPtr]['scope_opener']) === false) {
3✔
44
            return;
×
45
        }
46

47
        $this->processOpen($phpcsFile, $stackPtr);
3✔
48
        $this->processClose($phpcsFile, $stackPtr);
3✔
49

50
    }//end process()
1✔
51

52

53
    /**
54
     * Processes the opening section of a class declaration.
55
     *
56
     * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
57
     * @param int                         $stackPtr  The position of the current token
58
     *                                               in the stack passed in $tokens.
59
     *
60
     * @return void
61
     */
62
    public function processOpen(File $phpcsFile, $stackPtr)
3✔
63
    {
64
        $tokens       = $phpcsFile->getTokens();
3✔
65
        $stackPtrType = strtolower($tokens[$stackPtr]['content']);
3✔
66

67
        // Check alignment of the keyword and braces.
68
        $classModifiers = [
2✔
69
            T_ABSTRACT => T_ABSTRACT,
3✔
70
            T_FINAL    => T_FINAL,
3✔
71
            T_READONLY => T_READONLY,
3✔
72
        ];
2✔
73

74
        $prevNonSpace = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
3✔
75
        $prevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true);
3✔
76

77
        if (isset($classModifiers[$tokens[$prevNonEmpty]['code']]) === true) {
3✔
78
            $spaces    = 0;
3✔
79
            $errorCode = 'SpaceBeforeKeyword';
3✔
80
            if ($tokens[$prevNonEmpty]['line'] !== $tokens[$stackPtr]['line']) {
3✔
81
                $spaces    = 'newline';
3✔
82
                $errorCode = 'NewlineBeforeKeyword';
3✔
83
            } else if ($tokens[($stackPtr - 1)]['code'] === T_WHITESPACE) {
3✔
84
                $spaces = $tokens[($stackPtr - 1)]['length'];
3✔
85
            }
86

87
            if ($spaces !== 1) {
3✔
88
                $error = 'Expected 1 space between %s and %s keywords; %s found';
3✔
89
                $data  = [
2✔
90
                    strtolower($tokens[$prevNonEmpty]['content']),
3✔
91
                    $stackPtrType,
3✔
92
                    $spaces,
3✔
93
                ];
2✔
94

95
                if ($prevNonSpace !== $prevNonEmpty) {
3✔
96
                    // Comment found between modifier and class keyword. Do not auto-fix.
97
                    $phpcsFile->addError($error, $stackPtr, $errorCode, $data);
3✔
98
                } else {
99
                    $fix = $phpcsFile->addFixableError($error, $stackPtr, $errorCode, $data);
3✔
100
                    if ($fix === true) {
3✔
101
                        if ($spaces === 0) {
3✔
102
                            $phpcsFile->fixer->addContentBefore($stackPtr, ' ');
×
103
                        } else {
104
                            $phpcsFile->fixer->beginChangeset();
3✔
105
                            $phpcsFile->fixer->replaceToken(($stackPtr - 1), ' ');
3✔
106
                            for ($i = ($stackPtr - 2); $i > $prevNonSpace; $i--) {
3✔
107
                                $phpcsFile->fixer->replaceToken($i, ' ');
3✔
108
                            }
109

110
                            $phpcsFile->fixer->endChangeset();
3✔
111
                        }
112
                    }
113
                }
114
            }//end if
115
        }//end if
116

117
        // We'll need the indent of the class/interface declaration for later.
118
        $classIndent = 0;
3✔
119
        for ($i = ($stackPtr - 1); $i > 0; $i--) {
3✔
120
            if ($tokens[$i]['line'] === $tokens[$stackPtr]['line']) {
3✔
121
                continue;
3✔
122
            }
123

124
            // We changed lines.
125
            if ($tokens[($i + 1)]['code'] === T_WHITESPACE) {
3✔
126
                $classIndent = $tokens[($i + 1)]['length'];
3✔
127
            }
128

129
            break;
3✔
130
        }
131

132
        $className    = null;
3✔
133
        $checkSpacing = true;
3✔
134

135
        if ($tokens[$stackPtr]['code'] !== T_ANON_CLASS) {
3✔
136
            $className = $phpcsFile->findNext(T_STRING, $stackPtr);
3✔
137
        } else {
138
            // Ignore the spacing check if this is a simple anon class.
139
            $next = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true);
×
140
            if ($next === $tokens[$stackPtr]['scope_opener']
×
141
                && $tokens[$next]['line'] > $tokens[$stackPtr]['line']
×
142
            ) {
143
                $checkSpacing = false;
×
144
            }
145
        }
146

147
        if ($checkSpacing === true) {
3✔
148
            // Spacing of the keyword.
149
            if ($tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE) {
3✔
150
                $gap = 0;
×
151
            } else if ($tokens[($stackPtr + 2)]['line'] !== $tokens[$stackPtr]['line']) {
3✔
152
                $gap = 'newline';
3✔
153
            } else {
154
                $gap = $tokens[($stackPtr + 1)]['length'];
3✔
155
            }
156

157
            if ($gap !== 1) {
3✔
158
                $error = 'Expected 1 space after %s keyword; %s found';
3✔
159
                $data  = [
2✔
160
                    $stackPtrType,
3✔
161
                    $gap,
3✔
162
                ];
2✔
163

164
                $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceAfterKeyword', $data);
3✔
165
                if ($fix === true) {
3✔
166
                    if ($gap === 0) {
3✔
167
                        $phpcsFile->fixer->addContent($stackPtr, ' ');
×
168
                    } else {
169
                        $phpcsFile->fixer->replaceToken(($stackPtr + 1), ' ');
3✔
170
                    }
171
                }
172
            }
173
        }//end if
174

175
        // Check after the class/interface name.
176
        if ($className !== null
3✔
177
            && $tokens[($className + 2)]['line'] === $tokens[$className]['line']
3✔
178
        ) {
179
            $gap = $tokens[($className + 1)]['content'];
3✔
180
            if (strlen($gap) !== 1) {
3✔
181
                $found = strlen($gap);
×
182
                $error = 'Expected 1 space after %s name; %s found';
×
183
                $data  = [
184
                    $stackPtrType,
×
185
                    $found,
×
186
                ];
187

188
                $fix = $phpcsFile->addFixableError($error, $className, 'SpaceAfterName', $data);
×
189
                if ($fix === true) {
×
190
                    $phpcsFile->fixer->replaceToken(($className + 1), ' ');
×
191
                }
192
            }
193
        }
194

195
        $openingBrace = $tokens[$stackPtr]['scope_opener'];
3✔
196

197
        // Check positions of the extends and implements keywords.
198
        $compareToken = $stackPtr;
3✔
199
        $compareType  = 'name';
3✔
200
        if ($tokens[$stackPtr]['code'] === T_ANON_CLASS) {
3✔
201
            if (isset($tokens[$stackPtr]['parenthesis_opener']) === true) {
×
202
                $compareToken = $tokens[$stackPtr]['parenthesis_closer'];
×
203
                $compareType  = 'closing parenthesis';
×
204
            } else {
205
                $compareType = 'keyword';
×
206
            }
207
        }
208

209
        foreach (['extends', 'implements'] as $keywordType) {
3✔
210
            $keyword = $phpcsFile->findNext(constant('T_'.strtoupper($keywordType)), ($compareToken + 1), $openingBrace);
3✔
211
            if ($keyword !== false) {
3✔
212
                if ($tokens[$keyword]['line'] !== $tokens[$compareToken]['line']) {
3✔
213
                    $error = 'The '.$keywordType.' keyword must be on the same line as the %s '.$compareType;
3✔
214
                    $data  = [$stackPtrType];
3✔
215
                    $fix   = $phpcsFile->addFixableError($error, $keyword, ucfirst($keywordType).'Line', $data);
3✔
216
                    if ($fix === true) {
3✔
217
                        $phpcsFile->fixer->beginChangeset();
3✔
218
                        $comments = [];
3✔
219

220
                        for ($i = ($compareToken + 1); $i < $keyword; ++$i) {
3✔
221
                            if ($tokens[$i]['code'] === T_COMMENT) {
3✔
222
                                $comments[] = trim($tokens[$i]['content']);
3✔
223
                            }
224

225
                            if ($tokens[$i]['code'] === T_WHITESPACE
3✔
226
                                || $tokens[$i]['code'] === T_COMMENT
3✔
227
                            ) {
228
                                $phpcsFile->fixer->replaceToken($i, ' ');
3✔
229
                            }
230
                        }
231

232
                        $phpcsFile->fixer->addContent($compareToken, ' ');
3✔
233
                        if (empty($comments) === false) {
3✔
234
                            $i = $keyword;
3✔
235
                            while ($tokens[($i + 1)]['line'] === $tokens[$keyword]['line']) {
3✔
236
                                ++$i;
3✔
237
                            }
238

239
                            $phpcsFile->fixer->addContentBefore($i, ' '.implode(' ', $comments));
3✔
240
                        }
241

242
                        $phpcsFile->fixer->endChangeset();
3✔
243
                    }//end if
244
                } else {
245
                    // Check the whitespace before. Whitespace after is checked
246
                    // later by looking at the whitespace before the first class name
247
                    // in the list.
248
                    $gap = $tokens[($keyword - 1)]['length'];
3✔
249
                    if ($gap !== 1) {
3✔
250
                        $error = 'Expected 1 space before '.$keywordType.' keyword; %s found';
3✔
251
                        $data  = [$gap];
3✔
252
                        $fix   = $phpcsFile->addFixableError($error, $keyword, 'SpaceBefore'.ucfirst($keywordType), $data);
3✔
253
                        if ($fix === true) {
3✔
254
                            $phpcsFile->fixer->replaceToken(($keyword - 1), ' ');
3✔
255
                        }
256
                    }
257
                }//end if
258
            }//end if
259
        }//end foreach
260

261
        // Check each of the extends/implements class names. If the extends/implements
262
        // keyword is the last content on the line, it means we need to check for
263
        // the multi-line format, so we do not include the class names
264
        // from the extends/implements list in the following check.
265
        // Note that classes can only extend one other class, so they can't use a
266
        // multi-line extends format, whereas an interface can extend multiple
267
        // other interfaces, and so uses a multi-line extends format.
268
        if ($tokens[$stackPtr]['code'] === T_INTERFACE) {
3✔
269
            $keywordTokenType = T_EXTENDS;
3✔
270
        } else {
271
            $keywordTokenType = T_IMPLEMENTS;
3✔
272
        }
273

274
        $implements          = $phpcsFile->findNext($keywordTokenType, ($stackPtr + 1), $openingBrace);
3✔
275
        $multiLineImplements = false;
3✔
276
        if ($implements !== false) {
3✔
277
            $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($openingBrace - 1), $implements, true);
3✔
278
            if ($tokens[$prev]['line'] !== $tokens[$implements]['line']) {
3✔
279
                $multiLineImplements = true;
3✔
280
            }
281
        }
282

283
        $find = Tokens::$nameTokens;
3✔
284
        $find[$keywordTokenType] = $keywordTokenType;
3✔
285

286
        if ($className !== null) {
3✔
287
            $start = $className;
3✔
288
        } else if (isset($tokens[$stackPtr]['parenthesis_closer']) === true) {
×
289
            $start = $tokens[$stackPtr]['parenthesis_closer'];
×
290
        } else {
291
            $start = $stackPtr;
×
292
        }
293

294
        $classNames = [];
3✔
295
        $nextClass  = $phpcsFile->findNext($find, ($start + 2), ($openingBrace - 1));
3✔
296
        while ($nextClass !== false) {
3✔
297
            $classNames[] = $nextClass;
3✔
298
            $nextClass    = $phpcsFile->findNext($find, ($nextClass + 1), ($openingBrace - 1));
3✔
299
        }
300

301
        $classCount         = count($classNames);
3✔
302
        $checkingImplements = false;
3✔
303
        $implementsToken    = null;
3✔
304
        foreach ($classNames as $n => $className) {
3✔
305
            if ($tokens[$className]['code'] === $keywordTokenType) {
3✔
306
                $checkingImplements = true;
3✔
307
                $implementsToken    = $className;
3✔
308

309
                continue;
3✔
310
            }
311

312
            if ($checkingImplements === true && $multiLineImplements === true) {
3✔
313
                $prev = $phpcsFile->findPrevious(
3✔
314
                    T_WHITESPACE,
3✔
315
                    ($className - 1),
3✔
316
                    $implements,
3✔
317
                    true
3✔
318
                );
2✔
319

320
                if ($prev === $implementsToken && $tokens[$className]['line'] !== ($tokens[$prev]['line'] + 1)) {
3✔
321
                    if ($keywordTokenType === T_EXTENDS) {
3✔
322
                        $error = 'The first item in a multi-line extends list must be on the line following the extends keyword';
×
323
                        $fix   = $phpcsFile->addFixableError($error, $className, 'FirstExtendsInterfaceSameLine');
×
324
                    } else {
325
                        $error = 'The first item in a multi-line implements list must be on the line following the implements keyword';
3✔
326
                        $fix   = $phpcsFile->addFixableError($error, $className, 'FirstInterfaceSameLine');
3✔
327
                    }
328

329
                    if ($fix === true) {
3✔
330
                        $phpcsFile->fixer->beginChangeset();
3✔
331
                        for ($i = ($prev + 1); $i < $className; $i++) {
3✔
332
                            if ($tokens[$i]['code'] !== T_WHITESPACE) {
3✔
UNCOV
333
                                break;
×
334
                            }
335

336
                            $phpcsFile->fixer->replaceToken($i, '');
3✔
337
                        }
338

339
                        $phpcsFile->fixer->addNewline($prev);
3✔
340
                        $phpcsFile->fixer->endChangeset();
3✔
341
                    }
342
                } else if ((isset(Tokens::$commentTokens[$tokens[$prev]['code']]) === false
3✔
343
                    && $tokens[$prev]['line'] !== ($tokens[$className]['line'] - 1))
3✔
344
                    || $tokens[$prev]['line'] === $tokens[$className]['line']
3✔
345
                ) {
346
                    if ($keywordTokenType === T_EXTENDS) {
3✔
347
                        $error = 'Only one interface may be specified per line in a multi-line extends declaration';
3✔
348
                        $fix   = $phpcsFile->addFixableError($error, $className, 'ExtendsInterfaceSameLine');
3✔
349
                    } else {
350
                        $error = 'Only one interface may be specified per line in a multi-line implements declaration';
3✔
351
                        $fix   = $phpcsFile->addFixableError($error, $className, 'InterfaceSameLine');
3✔
352
                    }
353

354
                    if ($fix === true) {
3✔
355
                        $phpcsFile->fixer->beginChangeset();
3✔
356
                        for ($i = ($prev + 1); $i < $className; $i++) {
3✔
357
                            if ($tokens[$i]['code'] !== T_WHITESPACE) {
3✔
UNCOV
358
                                break;
×
359
                            }
360

361
                            $phpcsFile->fixer->replaceToken($i, '');
3✔
362
                        }
363

364
                        $phpcsFile->fixer->addNewline($prev);
3✔
365
                        $phpcsFile->fixer->endChangeset();
3✔
366
                    }
367
                } else {
368
                    $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($className - 1), $implements);
3✔
369
                    if ($tokens[$prev]['line'] !== $tokens[$className]['line']) {
3✔
370
                        $found = 0;
3✔
371
                    } else {
372
                        $found = $tokens[$prev]['length'];
3✔
373
                    }
374

375
                    $expected = ($classIndent + $this->indent);
3✔
376
                    if ($found !== $expected) {
3✔
377
                        $error = 'Expected %s spaces before interface name; %s found';
3✔
378
                        $data  = [
2✔
379
                            $expected,
3✔
380
                            $found,
3✔
381
                        ];
2✔
382
                        $fix   = $phpcsFile->addFixableError($error, $className, 'InterfaceWrongIndent', $data);
3✔
383
                        if ($fix === true) {
3✔
384
                            $padding = str_repeat(' ', $expected);
3✔
385
                            if ($found === 0) {
3✔
386
                                $phpcsFile->fixer->addContent($prev, $padding);
3✔
387
                            } else {
388
                                $phpcsFile->fixer->replaceToken($prev, $padding);
3✔
389
                            }
390
                        }
391
                    }
392
                }//end if
393
            } else {
394
                if ($tokens[($className - 1)]['code'] === T_COMMA) {
3✔
395
                    $error = 'Expected 1 space before "%s"; 0 found';
3✔
396
                    $data  = [$tokens[$className]['content']];
3✔
397
                    $fix   = $phpcsFile->addFixableError($error, ($nextComma + 1), 'NoSpaceBeforeName', $data);
3✔
398
                    if ($fix === true) {
3✔
399
                        $phpcsFile->fixer->addContentBefore(($nextComma + 1), ' ');
3✔
400
                    }
401
                } else {
402
                    $prev = ($className - 1);
3✔
403

404
                    $last    = $phpcsFile->findPrevious(T_WHITESPACE, $prev, null, true);
3✔
405
                    $content = $phpcsFile->getTokensAsString(($last + 1), ($prev - $last));
3✔
406
                    if ($content !== ' ') {
3✔
407
                        $found = strlen($content);
3✔
408

409
                        $error = 'Expected 1 space before "%s"; %s found';
3✔
410
                        $data  = [
2✔
411
                            $tokens[$className]['content'],
3✔
412
                            $found,
3✔
413
                        ];
2✔
414

415
                        $fix = $phpcsFile->addFixableError($error, $className, 'SpaceBeforeName', $data);
3✔
416
                        if ($fix === true) {
3✔
417
                            if ($tokens[$prev]['code'] === T_WHITESPACE) {
3✔
418
                                $phpcsFile->fixer->beginChangeset();
3✔
419
                                $phpcsFile->fixer->replaceToken($prev, ' ');
3✔
420
                                while ($tokens[--$prev]['code'] === T_WHITESPACE) {
3✔
421
                                    $phpcsFile->fixer->replaceToken($prev, ' ');
3✔
422
                                }
423

424
                                $phpcsFile->fixer->endChangeset();
3✔
425
                            } else {
426
                                $phpcsFile->fixer->addContent($prev, ' ');
×
427
                            }
428
                        }
429
                    }//end if
430
                }//end if
431
            }//end if
432

433
            if ($checkingImplements === true
3✔
434
                && $tokens[($className + 1)]['code'] !== T_COMMA
3✔
435
            ) {
436
                if ($n !== ($classCount - 1)) {
3✔
437
                    // This is not the last class name, and the comma
438
                    // is not where we expect it to be.
439
                    if ($tokens[($className + 2)]['code'] !== $keywordTokenType) {
3✔
440
                        $error = 'Expected 0 spaces between "%s" and comma; %s found';
3✔
441
                        $data  = [
2✔
442
                            $tokens[$className]['content'],
3✔
443
                            $tokens[($className + 1)]['length'],
3✔
444
                        ];
2✔
445

446
                        $fix = $phpcsFile->addFixableError($error, $className, 'SpaceBeforeComma', $data);
3✔
447
                        if ($fix === true) {
3✔
448
                            $phpcsFile->fixer->replaceToken(($className + 1), '');
3✔
449
                        }
450
                    }
451
                }
452

453
                $nextComma = $phpcsFile->findNext(T_COMMA, $className);
3✔
454
            } else {
455
                $nextComma = ($className + 1);
3✔
456
            }//end if
457
        }//end foreach
458

459
    }//end processOpen()
1✔
460

461

462
    /**
463
     * Processes the closing section of a class declaration.
464
     *
465
     * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
466
     * @param int                         $stackPtr  The position of the current token
467
     *                                               in the stack passed in $tokens.
468
     *
469
     * @return void
470
     */
471
    public function processClose(File $phpcsFile, $stackPtr)
3✔
472
    {
473
        $tokens = $phpcsFile->getTokens();
3✔
474

475
        // Check that the closing brace comes right after the code body.
476
        $closeBrace  = $tokens[$stackPtr]['scope_closer'];
3✔
477
        $prevContent = $phpcsFile->findPrevious(T_WHITESPACE, ($closeBrace - 1), null, true);
3✔
478
        if ($prevContent !== $tokens[$stackPtr]['scope_opener']
3✔
479
            && $tokens[$prevContent]['line'] !== ($tokens[$closeBrace]['line'] - 1)
3✔
480
        ) {
481
            $error = 'The closing brace for the %s must go on the next line after the body';
3✔
482
            $data  = [$tokens[$stackPtr]['content']];
3✔
483
            $fix   = $phpcsFile->addFixableError($error, $closeBrace, 'CloseBraceAfterBody', $data);
3✔
484

485
            if ($fix === true) {
3✔
486
                $phpcsFile->fixer->beginChangeset();
3✔
487
                for ($i = ($prevContent + 1); $tokens[$i]['line'] !== $tokens[$closeBrace]['line']; $i++) {
3✔
488
                    $phpcsFile->fixer->replaceToken($i, '');
3✔
489
                }
490

491
                if (strpos($tokens[$prevContent]['content'], $phpcsFile->eolChar) === false) {
3✔
492
                    $phpcsFile->fixer->addNewline($prevContent);
3✔
493
                }
494

495
                $phpcsFile->fixer->endChangeset();
3✔
496
            }
497
        }//end if
498

499
        if ($tokens[$stackPtr]['code'] !== T_ANON_CLASS) {
3✔
500
            // Check the closing brace is on it's own line, but allow
501
            // for comments like "//end class".
502
            $ignoreTokens   = Tokens::$phpcsCommentTokens;
3✔
503
            $ignoreTokens[] = T_WHITESPACE;
3✔
504
            $ignoreTokens[] = T_COMMENT;
3✔
505
            $ignoreTokens[] = T_SEMICOLON;
3✔
506
            $nextContent    = $phpcsFile->findNext($ignoreTokens, ($closeBrace + 1), null, true);
3✔
507
            if ($tokens[$nextContent]['line'] === $tokens[$closeBrace]['line']) {
3✔
508
                $type  = strtolower($tokens[$stackPtr]['content']);
3✔
509
                $error = 'Closing %s brace must be on a line by itself';
3✔
510
                $data  = [$type];
3✔
511
                $phpcsFile->addError($error, $closeBrace, 'CloseBraceSameLine', $data);
3✔
512
            }
513
        }
514

515
    }//end processClose()
1✔
516

517

518
}//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

© 2025 Coveralls, Inc