Skip to content

Commit

Permalink
[TASK] Remove Rule::getValues (#582)
Browse files Browse the repository at this point in the history
  • Loading branch information
ziegenberg committed Jun 19, 2024
1 parent 8a6c5c7 commit c415003
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 33 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).

### Removed

- Remove `Rule::getValues()` (#582)
- Remove `Rule::setValues()` (#562)
- Remove `Document::getAllSelectors()` (#561)
- Remove `DeclarationBlock::getSelector()` (#559)
Expand Down
31 changes: 0 additions & 31 deletions src/Rule/Rule.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,37 +189,6 @@ public function setValue($mValue)
$this->mValue = $mValue;
}

/**
* @return array<int, array<int, RuleValueList>>
*
* @deprecated will be removed in version 9.0
* Old-Style 2-dimensional array returned. Retained for (some) backwards-compatibility.
* Use `getValue()` instead and check for the existence of a (nested set of) ValueList object(s).
*/
public function getValues(): array
{
if (!$this->mValue instanceof RuleValueList) {
return [[$this->mValue]];
}
if ($this->mValue->getListSeparator() === ',') {
return [$this->mValue->getListComponents()];
}
$aResult = [];
foreach ($this->mValue->getListComponents() as $mValue) {
if (!$mValue instanceof RuleValueList || $mValue->getListSeparator() !== ',') {
$aResult[] = [$mValue];
continue;
}
if ($this->mValue->getListSeparator() === ' ' || count($aResult) === 0) {
$aResult[] = [];
}
foreach ($mValue->getListComponents() as $mValue) {
$aResult[count($aResult) - 1][] = $mValue;
}
}
return $aResult;
}

/**
* Adds a value to the existing value. Value will be appended if a `RuleValueList` exists of the given type.
* Otherwise, the existing value will be wrapped by one.
Expand Down
3 changes: 1 addition & 2 deletions tests/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,7 @@ public function unicodeParsing(): void
continue;
}
$aContentRules = $oRuleSet->getRules('content');
$aContents = $aContentRules[0]->getValues();
$sString = $aContents[0][0]->__toString();
$sString = $aContentRules[0]->getValue()->__toString();
if ($sSelector == '.test-1') {
self::assertSame('" "', $sString);
}
Expand Down

0 comments on commit c415003

Please sign in to comment.