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

PHPCSStandards / PHP_CodeSniffer / 15036337869

15 May 2025 04:03AM UTC coverage: 78.375% (-0.2%) from 78.556%
15036337869

Pull #856

github

web-flow
Merge 93f570b46 into f5e7943d0
Pull Request #856: [Doc] Cover all errors of PEAR ClassDeclaration

25112 of 32041 relevant lines covered (78.37%)

69.4 hits per line

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

86.36
/src/Standards/Squiz/Sniffs/CSS/LowercaseStyleDefinitionSniff.php
1
<?php
2
/**
3
 * Ensure that all style definitions are in lowercase.
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\CSS;
13

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

18
class LowercaseStyleDefinitionSniff implements Sniff, DeprecatedSniff
19
{
20

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

28

29
    /**
30
     * Returns the token types that this sniff is interested in.
31
     *
32
     * @return array<int|string>
33
     */
34
    public function register()
3✔
35
    {
36
        return [T_OPEN_CURLY_BRACKET];
3✔
37

38
    }//end register()
39

40

41
    /**
42
     * Processes the tokens that this sniff is interested in.
43
     *
44
     * @param \PHP_CodeSniffer\Files\File $phpcsFile The file where the token was found.
45
     * @param int                         $stackPtr  The position in the stack where
46
     *                                               the token was found.
47
     *
48
     * @return void
49
     */
50
    public function process(File $phpcsFile, $stackPtr)
3✔
51
    {
52
        $tokens  = $phpcsFile->getTokens();
3✔
53
        $start   = ($stackPtr + 1);
3✔
54
        $end     = ($tokens[$stackPtr]['bracket_closer'] - 1);
3✔
55
        $inStyle = null;
3✔
56

57
        for ($i = $start; $i <= $end; $i++) {
3✔
58
            // Skip nested definitions as they are checked individually.
59
            if ($tokens[$i]['code'] === T_OPEN_CURLY_BRACKET) {
3✔
60
                $i = $tokens[$i]['bracket_closer'];
3✔
61
                continue;
3✔
62
            }
63

64
            if ($tokens[$i]['code'] === T_STYLE) {
3✔
65
                $inStyle = $tokens[$i]['content'];
3✔
66
            }
1✔
67

68
            if ($tokens[$i]['code'] === T_SEMICOLON) {
3✔
69
                $inStyle = null;
3✔
70
            }
1✔
71

72
            if ($inStyle === 'progid') {
3✔
73
                // Special case for IE filters.
74
                continue;
3✔
75
            }
76

77
            if ($tokens[$i]['code'] === T_STYLE
3✔
78
                || ($inStyle !== null
3✔
79
                && $tokens[$i]['code'] === T_STRING)
3✔
80
            ) {
1✔
81
                $expected = strtolower($tokens[$i]['content']);
3✔
82
                if ($expected !== $tokens[$i]['content']) {
3✔
83
                    $error = 'Style definitions must be lowercase; expected %s but found %s';
3✔
84
                    $data  = [
1✔
85
                        $expected,
3✔
86
                        $tokens[$i]['content'],
3✔
87
                    ];
2✔
88

89
                    $fix = $phpcsFile->addFixableError($error, $i, 'FoundUpper', $data);
3✔
90
                    if ($fix === true) {
3✔
91
                        $phpcsFile->fixer->replaceToken($i, $expected);
3✔
92
                    }
1✔
93
                }
1✔
94
            }
1✔
95
        }//end for
1✔
96

97
    }//end process()
2✔
98

99

100
    /**
101
     * Provide the version number in which the sniff was deprecated.
102
     *
103
     * @return string
104
     */
105
    public function getDeprecationVersion()
×
106
    {
107
        return 'v3.9.0';
×
108

109
    }//end getDeprecationVersion()
110

111

112
    /**
113
     * Provide the version number in which the sniff will be removed.
114
     *
115
     * @return string
116
     */
117
    public function getRemovalVersion()
×
118
    {
119
        return 'v4.0.0';
×
120

121
    }//end getRemovalVersion()
122

123

124
    /**
125
     * Provide a custom message to display with the deprecation.
126
     *
127
     * @return string
128
     */
129
    public function getDeprecationMessage()
×
130
    {
131
        return 'Support for scanning CSS files will be removed completely in v4.0.0.';
×
132

133
    }//end getDeprecationMessage()
134

135

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