Skip to content

Commit 6524b63

Browse files
committed
[BUGFIX] Ensure column number set after RuleSet::addRule()
Note that this bug (or inconsistency) only occurs following the addtion of `getColumnNumber()` returning a nullable `int` (#1221 and #1225). These changes are not yet included in any release. Part of #974.
1 parent 9bc6622 commit 6524b63

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Please also have a look at our
1919
- Methods `getLineNumber` and `getColumnNumber` which return a nullable `int`
2020
for the following classes:
2121
`Comment`, `CSSList`, `SourceException`, `Charset`, `CSSNamespace`, `Import`,
22-
`Rule`, `DeclarationBlock`, `RuleSet`, `CSSFunction`, `Value` (#1225)
22+
`Rule`, `DeclarationBlock`, `RuleSet`, `CSSFunction`, `Value` (#1225, #1263)
2323
- `Positionable` interface for CSS items that may have a position
2424
(line and perhaps column number) in the parsed CSS (#1221)
2525
- Partial support for CSS Color Module Level 4:

src/RuleSet/RuleSet.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ public function addRule(Rule $ruleToAdd, ?Rule $sibling = null): void
118118
$last = $rules[$rulesCount - 1];
119119
$ruleToAdd->setPosition($last->getLineNo() + 1, 0);
120120
}
121+
} elseif ($ruleToAdd->getColumnNumber() === null) {
122+
$ruleToAdd->setPosition($ruleToAdd->getLineNumber(), 0);
121123
}
122124

123125
\array_splice($this->rules[$propertyName], $position, 0, [$ruleToAdd]);

tests/Unit/RuleSet/RuleSetTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,6 @@ public function addRuleWithOnlyLineNumberAddsRuleAndSetsColumnNumberPreservingLi
123123
array $initialPropertyNames,
124124
string $propertyNameToAdd
125125
): void {
126-
self::markTestSkipped('currently broken - does not set column number');
127-
128126
$ruleToAdd = new Rule($propertyNameToAdd);
129127
$ruleToAdd->setPosition(42);
130128
$this->setRulesFromPropertyNames($initialPropertyNames);

0 commit comments

Comments
 (0)