Skip to content

Commit 9f662e6

Browse files
committed
Merge branch 'report-memory-improvements' into phpcs-fixer
2 parents e7a9818 + dbfaa21 commit 9f662e6

File tree

4 files changed

+35
-8
lines changed

4 files changed

+35
-8
lines changed

CodeSniffer/Standards/Squiz/Sniffs/CSS/LowercaseStyleDefinitionSniff.php

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,30 @@ public function register()
5959
*/
6060
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
6161
{
62-
$tokens = $phpcsFile->getTokens();
63-
$start = ($stackPtr + 1);
64-
$end = ($tokens[$stackPtr]['bracket_closer'] - 1);
62+
$tokens = $phpcsFile->getTokens();
63+
$start = ($stackPtr + 1);
64+
$end = ($tokens[$stackPtr]['bracket_closer'] - 1);
65+
$inStyle = false;
6566

6667
for ($i = $start; $i <= $end; $i++) {
67-
if ($tokens[$i]['code'] === T_STRING || $tokens[$i]['code'] === T_STYLE) {
68+
// Skip nested definitions as they are checked individually.
69+
if ($tokens[$i]['code'] === T_OPEN_CURLY_BRACKET) {
70+
$i = $tokens[$i]['bracket_closer'];
71+
continue;
72+
}
73+
74+
if ($tokens[$i]['code'] === T_STYLE) {
75+
$inStyle = true;
76+
}
77+
78+
if ($tokens[$i]['code'] === T_SEMICOLON) {
79+
$inStyle = false;
80+
}
81+
82+
if ($tokens[$i]['code'] === T_STYLE
83+
|| ($inStyle === true
84+
&& $tokens[$i]['code'] === T_STRING)
85+
) {
6886
$expected = strtolower($tokens[$i]['content']);
6987
if ($expected !== $tokens[$i]['content']) {
7088
$error = 'Style definitions must be lowercase; expected %s but found %s';
@@ -79,7 +97,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
7997
}
8098
}
8199
}
82-
}
100+
}//end for
83101

84102
}//end process()
85103

CodeSniffer/Standards/Squiz/Tests/CSS/LowercaseStyleDefinitionUnitTest.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,10 @@
44
background-color: #DA9393;
55
BACKGROUND-IMAGE: URL(Warning_Close.png);
66
}
7+
8+
@media screen and (max-device-width: 769px) {
9+
10+
.SettingsTabPaneWidgetType-tab-mid {
11+
Font-Family: arial;
12+
}
13+
}

CodeSniffer/Standards/Squiz/Tests/CSS/LowercaseStyleDefinitionUnitTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,10 @@ class Squiz_Tests_CSS_LowercaseStyleDefinitionUnitTest extends AbstractSniffUnit
4040
public function getErrorList()
4141
{
4242
return array(
43-
2 => 1,
44-
3 => 1,
45-
5 => 2,
43+
2 => 1,
44+
3 => 1,
45+
5 => 2,
46+
11 => 1,
4647
);
4748

4849
}//end getErrorList()

package.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
4848
-- Thanks to Szabolcs Sulik for the patch
4949
- Squiz and MySource File and Function comment sniffs now allow all tags and don't require a particular licence
5050
- Squiz standard now allows lines to be 120 characters long before warning; up from 85
51+
- Squiz LowercaseStyleDefinitionSniff no longer throws errors for class names in nested style definitions
5152
- Fixed bug #20026 : Check for multi-line arrays that should be single-line is slightly wrong
5253
-- Adds new error message for single-line arrays that end with a comma
5354
- Fixed bug #20029 : ForbiddenFunction sniff incorrectly recognizes methods in USE clauses

0 commit comments

Comments
 (0)