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

PHPCSStandards / PHP_CodeSniffer / 17483947696

05 Sep 2025 04:45AM UTC coverage: 78.507% (-0.7%) from 79.184%
17483947696

push

github

web-flow
Merge pull request #1213 from PHPCSStandards/feature/remove-filelist-tests

:fire: Hot Fix: remove FileList tests

25309 of 32238 relevant lines covered (78.51%)

73.81 hits per line

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

68.42
/src/Standards/Squiz/Sniffs/Objects/ObjectMemberCommaSniff.php
1
<?php
2
/**
3
 * Ensures the last member of an object is not followed by a comma.
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
 * @deprecated 3.9.0
10
 */
11

12
namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Objects;
13

14
use PHP_CodeSniffer\Files\File;
15
use PHP_CodeSniffer\Sniffs\DeprecatedSniff;
16
use PHP_CodeSniffer\Sniffs\Sniff;
17
use PHP_CodeSniffer\Util\Tokens;
18

19
class ObjectMemberCommaSniff implements Sniff, DeprecatedSniff
20
{
21

22
    /**
23
     * A list of tokenizers this sniff supports.
24
     *
25
     * @var array
26
     */
27
    public $supportedTokenizers = ['JS'];
28

29

30
    /**
31
     * Registers the token types that this sniff wishes to listen to.
32
     *
33
     * @return array<int|string>
34
     */
35
    public function register()
3✔
36
    {
37
        return [T_CLOSE_OBJECT];
3✔
38

39
    }//end register()
40

41

42
    /**
43
     * Process the tokens that this sniff is listening for.
44
     *
45
     * @param \PHP_CodeSniffer\Files\File $phpcsFile The file where the token was found.
46
     * @param int                         $stackPtr  The position in the stack where
47
     *                                               the token was found.
48
     *
49
     * @return void
50
     */
51
    public function process(File $phpcsFile, $stackPtr)
3✔
52
    {
53
        $tokens = $phpcsFile->getTokens();
3✔
54

55
        $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true);
3✔
56
        if ($tokens[$prev]['code'] === T_COMMA) {
3✔
57
            $error = 'Last member of object must not be followed by a comma';
3✔
58
            $fix   = $phpcsFile->addFixableError($error, $prev, 'Found');
3✔
59
            if ($fix === true) {
3✔
60
                $phpcsFile->fixer->replaceToken($prev, '');
3✔
61
            }
1✔
62
        }
1✔
63

64
    }//end process()
2✔
65

66

67
    /**
68
     * Provide the version number in which the sniff was deprecated.
69
     *
70
     * @return string
71
     */
72
    public function getDeprecationVersion()
×
73
    {
74
        return 'v3.9.0';
×
75

76
    }//end getDeprecationVersion()
77

78

79
    /**
80
     * Provide the version number in which the sniff will be removed.
81
     *
82
     * @return string
83
     */
84
    public function getRemovalVersion()
×
85
    {
86
        return 'v4.0.0';
×
87

88
    }//end getRemovalVersion()
89

90

91
    /**
92
     * Provide a custom message to display with the deprecation.
93
     *
94
     * @return string
95
     */
96
    public function getDeprecationMessage()
×
97
    {
98
        return 'Support for scanning JavaScript files will be removed completely in v4.0.0.';
×
99

100
    }//end getDeprecationMessage()
101

102

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