Skip to content

Commit 966b11b

Browse files
committed
[TASK] Make the OutputFormat properties private
Also use the accessors as necessary. Fixes #882
1 parent e1f8bd3 commit 966b11b

File tree

4 files changed

+31
-81
lines changed

4 files changed

+31
-81
lines changed

src/CSSList/AtRuleBlockList.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ public function __toString(): string
5353
public function render(OutputFormat $outputFormat): string
5454
{
5555
$result = $outputFormat->comments($this);
56-
$result .= $outputFormat->sBeforeAtRuleBlock;
56+
$result .= $outputFormat->getBeforeAtRuleBlock();
5757
$arguments = $this->arguments;
5858
if ($arguments) {
5959
$arguments = ' ' . $arguments;
6060
}
6161
$result .= "@{$this->type}$arguments{$outputFormat->spaceBeforeOpeningBrace()}{";
6262
$result .= $this->renderListContents($outputFormat);
6363
$result .= '}';
64-
$result .= $outputFormat->sAfterAtRuleBlock;
64+
$result .= $outputFormat->getAfterAtRuleBlock();
6565
return $result;
6666
}
6767

src/OutputFormat.php

Lines changed: 25 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,24 @@ class OutputFormat
1010
* Value format: `"` means double-quote, `'` means single-quote
1111
*
1212
* @var string
13-
*
14-
* @internal since 8.8.0, will be made private in 9.0.0
1513
*/
16-
public $stringQuotingType = '"';
14+
private $stringQuotingType = '"';
1715

1816
/**
1917
* Output RGB colors in hash notation if possible
2018
*
2119
* @var bool
22-
*
23-
* @internal since 8.8.0, will be made private in 9.0.0
2420
*/
25-
public $bRGBHashNotation = true;
21+
private $bRGBHashNotation = true;
2622

2723
/**
2824
* Declaration format
2925
*
3026
* Semicolon after the last rule of a declaration block can be omitted. To do that, set this false.
3127
*
3228
* @var bool
33-
*
34-
* @internal since 8.8.0, will be made private in 9.0.0
3529
*/
36-
public $bSemicolonAfterLastRule = true;
30+
private $bSemicolonAfterLastRule = true;
3731

3832
/**
3933
* Spacing
@@ -43,177 +37,133 @@ class OutputFormat
4337
* (e.g. `$outputFormat->set('Space*Rules', "\n");`)
4438
*
4539
* @var string
46-
*
47-
* @internal since 8.8.0, will be made private in 9.0.0
4840
*/
49-
public $sSpaceAfterRuleName = ' ';
41+
private $sSpaceAfterRuleName = ' ';
5042

5143
/**
5244
* @var string
53-
*
54-
* @internal since 8.8.0, will be made private in 9.0.0
5545
*/
56-
public $sSpaceBeforeRules = '';
46+
private $sSpaceBeforeRules = '';
5747

5848
/**
5949
* @var string
60-
*
61-
* @internal since 8.8.0, will be made private in 9.0.0
6250
*/
63-
public $sSpaceAfterRules = '';
51+
private $sSpaceAfterRules = '';
6452

6553
/**
6654
* @var string
67-
*
68-
* @internal since 8.8.0, will be made private in 9.0.0
6955
*/
70-
public $sSpaceBetweenRules = '';
56+
private $sSpaceBetweenRules = '';
7157

7258
/**
7359
* @var string
74-
*
75-
* @internal since 8.8.0, will be made private in 9.0.0
7660
*/
77-
public $sSpaceBeforeBlocks = '';
61+
private $sSpaceBeforeBlocks = '';
7862

7963
/**
8064
* @var string
81-
*
82-
* @internal since 8.8.0, will be made private in 9.0.0
8365
*/
84-
public $sSpaceAfterBlocks = '';
66+
private $sSpaceAfterBlocks = '';
8567

8668
/**
8769
* @var string
88-
*
89-
* @internal since 8.8.0, will be made private in 9.0.0
9070
*/
91-
public $sSpaceBetweenBlocks = "\n";
71+
private $sSpaceBetweenBlocks = "\n";
9272

9373
/**
9474
* Content injected in and around at-rule blocks.
9575
*
9676
* @var string
97-
*
98-
* @internal since 8.8.0, will be made private in 9.0.0
9977
*/
100-
public $sBeforeAtRuleBlock = '';
78+
private $sBeforeAtRuleBlock = '';
10179

10280
/**
10381
* @var string
104-
*
105-
* @internal since 8.8.0, will be made private in 9.0.0
10682
*/
107-
public $sAfterAtRuleBlock = '';
83+
private $sAfterAtRuleBlock = '';
10884

10985
/**
11086
* This is what’s printed before and after the comma if a declaration block contains multiple selectors.
11187
*
11288
* @var string
113-
*
114-
* @internal since 8.8.0, will be made private in 9.0.0
11589
*/
116-
public $sSpaceBeforeSelectorSeparator = '';
90+
private $sSpaceBeforeSelectorSeparator = '';
11791

11892
/**
11993
* @var string
120-
*
121-
* @internal since 8.8.0, will be made private in 9.0.0
12294
*/
123-
public $sSpaceAfterSelectorSeparator = ' ';
95+
private $sSpaceAfterSelectorSeparator = ' ';
12496

12597
/**
12698
* This is what’s inserted before the separator in value lists, by default.
12799
*
128100
* @var string
129-
*
130-
* @internal since 8.8.0, will be made private in 9.0.0
131101
*/
132-
public $sSpaceBeforeListArgumentSeparator = '';
102+
private $sSpaceBeforeListArgumentSeparator = '';
133103

134104
/**
135105
* Keys are separators (e.g. `,`). Values are the space sequence to insert, or an empty string.
136106
*
137107
* @var array<non-empty-string, string>
138-
*
139-
* @internal since 8.8.0, will be made private in 9.0.0
140108
*/
141-
public $aSpaceBeforeListArgumentSeparators = [];
109+
private $aSpaceBeforeListArgumentSeparators = [];
142110

143111
/**
144112
* This is what’s inserted after the separator in value lists, by default.
145113
*
146114
* @var string
147-
*
148-
* @internal since 8.8.0, will be made private in 9.0.0
149115
*/
150-
public $sSpaceAfterListArgumentSeparator = '';
116+
private $sSpaceAfterListArgumentSeparator = '';
151117

152118
/**
153119
* Keys are separators (e.g. `,`). Values are the space sequence to insert, or an empty string.
154120
*
155121
* @var array<non-empty-string, string>
156-
*
157-
* @internal since 8.8.0, will be made private in 9.0.0
158122
*/
159-
public $aSpaceAfterListArgumentSeparators = [];
123+
private $aSpaceAfterListArgumentSeparators = [];
160124

161125
/**
162126
* @var string
163-
*
164-
* @internal since 8.8.0, will be made private in 9.0.0
165127
*/
166-
public $sSpaceBeforeOpeningBrace = ' ';
128+
private $sSpaceBeforeOpeningBrace = ' ';
167129

168130
/**
169131
* Content injected in and around declaration blocks.
170132
*
171133
* @var string
172-
*
173-
* @internal since 8.8.0, will be made private in 9.0.0
174134
*/
175-
public $sBeforeDeclarationBlock = '';
135+
private $sBeforeDeclarationBlock = '';
176136

177137
/**
178138
* @var string
179-
*
180-
* @internal since 8.8.0, will be made private in 9.0.0
181139
*/
182-
public $sAfterDeclarationBlockSelectors = '';
140+
private $sAfterDeclarationBlockSelectors = '';
183141

184142
/**
185143
* @var string
186-
*
187-
* @internal since 8.8.0, will be made private in 9.0.0
188144
*/
189-
public $sAfterDeclarationBlock = '';
145+
private $sAfterDeclarationBlock = '';
190146

191147
/**
192148
* Indentation character(s) per level. Only applicable if newlines are used in any of the spacing settings.
193149
*
194150
* @var string
195-
*
196-
* @internal since 8.8.0, will be made private in 9.0.0
197151
*/
198-
public $sIndentation = "\t";
152+
private $sIndentation = "\t";
199153

200154
/**
201155
* Output exceptions.
202156
*
203157
* @var bool
204-
*
205-
* @internal since 8.8.0, will be made private in 9.0.0
206158
*/
207-
public $bIgnoreExceptions = false;
159+
private $bIgnoreExceptions = false;
208160

209161
/**
210162
* Render comments for lists and RuleSets
211163
*
212164
* @var bool
213-
*
214-
* @internal since 8.8.0, will be made private in 9.0.0
215165
*/
216-
public $bRenderComments = false;
166+
private $bRenderComments = false;
217167

218168
/**
219169
* @var OutputFormatter|null

src/OutputFormatter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,6 @@ private function prepareSpace(string $spaceString): string
225225

226226
private function indent(): string
227227
{
228-
return \str_repeat($this->outputFormat->sIndentation, $this->outputFormat->getIndentationLevel());
228+
return \str_repeat($this->outputFormat->getIndentation(), $this->outputFormat->getIndentationLevel());
229229
}
230230
}

src/RuleSet/DeclarationBlock.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,16 +160,16 @@ public function render(OutputFormat $outputFormat): string
160160
// If all the selectors have been removed, this declaration block becomes invalid
161161
throw new OutputException('Attempt to print declaration block with missing selector', $this->lineNumber);
162162
}
163-
$result .= $outputFormat->sBeforeDeclarationBlock;
163+
$result .= $outputFormat->getBeforeDeclarationBlock();
164164
$result .= $outputFormat->implode(
165165
$outputFormat->spaceBeforeSelectorSeparator() . ',' . $outputFormat->spaceAfterSelectorSeparator(),
166166
$this->selectors
167167
);
168-
$result .= $outputFormat->sAfterDeclarationBlockSelectors;
168+
$result .= $outputFormat->getAfterDeclarationBlockSelectors();
169169
$result .= $outputFormat->spaceBeforeOpeningBrace() . '{';
170170
$result .= $this->renderRules($outputFormat);
171171
$result .= '}';
172-
$result .= $outputFormat->sAfterDeclarationBlock;
172+
$result .= $outputFormat->getAfterDeclarationBlock();
173173
return $result;
174174
}
175175
}

0 commit comments

Comments
 (0)