• 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

83.33
/src/Standards/Squiz/Sniffs/CSS/MissingColonSniff.php
1
<?php
2
/**
3
 * Ensure that all style definitions have a colon.
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 MissingColonSniff 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

54
        if (isset($tokens[$stackPtr]['bracket_closer']) === false) {
3✔
55
            // Syntax error or live coding, bow out.
56
            return;
3✔
57
        }
58

59
        $lastLine = $tokens[$stackPtr]['line'];
3✔
60
        $end      = $tokens[$stackPtr]['bracket_closer'];
3✔
61

62
        // Do not check nested style definitions as, for example, in @media style rules.
63
        $nested = $phpcsFile->findNext(T_OPEN_CURLY_BRACKET, ($stackPtr + 1), $end);
3✔
64
        if ($nested !== false) {
3✔
65
            return;
3✔
66
        }
67

68
        $foundColon  = false;
3✔
69
        $foundString = false;
3✔
70
        for ($i = ($stackPtr + 1); $i <= $end; $i++) {
3✔
71
            if ($tokens[$i]['line'] !== $lastLine) {
3✔
72
                // We changed lines.
73
                if ($foundColon === false && $foundString !== false) {
3✔
74
                    // We didn't find a colon on the previous line.
75
                    $error = 'No style definition found on line; check for missing colon';
3✔
76
                    $phpcsFile->addError($error, $foundString, 'Found');
3✔
77
                }
1✔
78

79
                $foundColon  = false;
3✔
80
                $foundString = false;
3✔
81
                $lastLine    = $tokens[$i]['line'];
3✔
82
            }
1✔
83

84
            if ($tokens[$i]['code'] === T_STRING) {
3✔
85
                $foundString = $i;
3✔
86
            } else if ($tokens[$i]['code'] === T_COLON) {
3✔
87
                $foundColon = $i;
3✔
88
            }
1✔
89
        }//end for
1✔
90

91
    }//end process()
2✔
92

93

94
    /**
95
     * Provide the version number in which the sniff was deprecated.
96
     *
97
     * @return string
98
     */
99
    public function getDeprecationVersion()
×
100
    {
101
        return 'v3.9.0';
×
102

103
    }//end getDeprecationVersion()
104

105

106
    /**
107
     * Provide the version number in which the sniff will be removed.
108
     *
109
     * @return string
110
     */
111
    public function getRemovalVersion()
×
112
    {
113
        return 'v4.0.0';
×
114

115
    }//end getRemovalVersion()
116

117

118
    /**
119
     * Provide a custom message to display with the deprecation.
120
     *
121
     * @return string
122
     */
123
    public function getDeprecationMessage()
×
124
    {
125
        return 'Support for scanning CSS files will be removed completely in v4.0.0.';
×
126

127
    }//end getDeprecationMessage()
128

129

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