Skip to content

Commit be5df80

Browse files
committed
Comments and minor refactoring
1 parent 1f7d7c2 commit be5df80

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/MoodleHQ/RTLCSS/RTLCSS.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
use Sabberworm\CSS\CSSList\Document;
2929
use Sabberworm\CSS\Parser;
3030
use Sabberworm\CSS\Rule\Rule;
31+
use Sabberworm\CSS\RuleSet\DeclarationBlock;
3132
use Sabberworm\CSS\RuleSet\RuleSet;
3233
use Sabberworm\CSS\Value\CSSFunction;
3334
use Sabberworm\CSS\Value\RuleValueList;
@@ -135,12 +136,12 @@ protected function parseComments(array $comments) {
135136

136137

137138
/**
138-
* @param CSSBlockList $block
139+
* @param CSSBlockList|CSSList $block
139140
*/
140141
protected function processBlock($block) {
141142
$contents = [];
142143

143-
/** @var RuleSet $node */
144+
/** @var DeclarationBlock|CSSList|RuleSet $node */
144145
foreach ($block->getContents() as $node) {
145146
$this->parseComments($node->getComments());
146147

@@ -153,8 +154,9 @@ protected function processBlock($block) {
153154

154155
if ($this->shouldRemoveNext()) {
155156
continue;
157+
}
156158

157-
} else if (!$this->shouldIgnoreNext()) {
159+
if (!$this->shouldIgnoreNext()) {
158160
if ($node instanceof CSSList) {
159161
$this->processBlock($node);
160162
}
@@ -170,19 +172,25 @@ protected function processBlock($block) {
170172
}
171173

172174
/**
173-
* @param RuleSet $node
175+
* @param DeclarationBlock|RuleSet $node
174176
*/
175177
protected function processDeclaration($node) {
176178
$rules = [];
177179

180+
/**
181+
* @var int $key
182+
* @var Rule $rule
183+
*/
178184
foreach ($node->getRules() as $key => $rule) {
179185
$this->parseComments($rule->getComments());
180186

181187
if ($toAdd = $this->shouldAddCss()) {
182188
foreach ($toAdd as $add) {
183189
$parser = new Parser('.wrapper{' . $add . '}');
184190
$tree = $parser->parse();
191+
/** @var DeclarationBlock[] $contents */
185192
$contents = $tree->getContents();
193+
/** @var Rule $newRule */
186194
foreach ($contents[0]->getRules() as $newRule) {
187195
$rules[] = $newRule;
188196
}
@@ -191,8 +199,9 @@ protected function processDeclaration($node) {
191199

192200
if ($this->shouldRemoveNext()) {
193201
continue;
202+
}
194203

195-
} else if (!$this->shouldIgnoreNext()) {
204+
if (!$this->shouldIgnoreNext()) {
196205
$this->processRule($rule);
197206
}
198207

0 commit comments

Comments
 (0)