Skip to content

Commit 10c9095

Browse files
authored
Merge pull request #276 from oliverklee/cleanup/types-outputformat
Add type annotations for `OutputFormat`
2 parents c7acc48 + 4aeff35 commit 10c9095

File tree

1 file changed

+89
-6
lines changed

1 file changed

+89
-6
lines changed

src/OutputFormat.php

Lines changed: 89 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,34 @@ class OutputFormat
4141
*/
4242
public $sSpaceAfterRuleName = ' ';
4343

44+
/**
45+
* @var string
46+
*/
4447
public $sSpaceBeforeRules = '';
4548

49+
/**
50+
* @var string
51+
*/
4652
public $sSpaceAfterRules = '';
4753

54+
/**
55+
* @var string
56+
*/
4857
public $sSpaceBetweenRules = '';
4958

59+
/**
60+
* @var string
61+
*/
5062
public $sSpaceBeforeBlocks = '';
5163

64+
/**
65+
* @var string
66+
*/
5267
public $sSpaceAfterBlocks = '';
5368

69+
/**
70+
* @var string
71+
*/
5472
public $sSpaceBetweenBlocks = "\n";
5573

5674
/**
@@ -60,6 +78,9 @@ class OutputFormat
6078
*/
6179
public $sBeforeAtRuleBlock = '';
6280

81+
/**
82+
* @var string
83+
*/
6384
public $sAfterAtRuleBlock = '';
6485

6586
/**
@@ -69,6 +90,9 @@ class OutputFormat
6990
*/
7091
public $sSpaceBeforeSelectorSeparator = '';
7192

93+
/**
94+
* @var string
95+
*/
7296
public $sSpaceAfterSelectorSeparator = ' ';
7397

7498
/**
@@ -78,8 +102,14 @@ class OutputFormat
78102
*/
79103
public $sSpaceBeforeListArgumentSeparator = '';
80104

105+
/**
106+
* @var string
107+
*/
81108
public $sSpaceAfterListArgumentSeparator = '';
82109

110+
/**
111+
* @var string
112+
*/
83113
public $sSpaceBeforeOpeningBrace = ' ';
84114

85115
/**
@@ -89,8 +119,14 @@ class OutputFormat
89119
*/
90120
public $sBeforeDeclarationBlock = '';
91121

122+
/**
123+
* @var string
124+
*/
92125
public $sAfterDeclarationBlockSelectors = '';
93126

127+
/**
128+
* @var string
129+
*/
94130
public $sAfterDeclarationBlock = '';
95131

96132
/**
@@ -107,16 +143,30 @@ class OutputFormat
107143
*/
108144
public $bIgnoreExceptions = false;
109145

146+
/**
147+
* @var OutputFormatter|null
148+
*/
110149
private $oFormatter = null;
111150

151+
/**
152+
* @var OutputFormat|null
153+
*/
112154
private $oNextLevelFormat = null;
113155

156+
/**
157+
* @var int
158+
*/
114159
private $iIndentationLevel = 0;
115160

116161
public function __construct()
117162
{
118163
}
119164

165+
/**
166+
* @param string $sName
167+
*
168+
* @return string|null
169+
*/
120170
public function get($sName)
121171
{
122172
$aVarPrefixes = ['a', 's', 'm', 'b', 'f', 'o', 'c', 'i'];
@@ -131,6 +181,9 @@ public function get($sName)
131181

132182
/**
133183
* @param array<array-key, string>|string $aNames
184+
* @param mixed $mValue
185+
*
186+
* @return self|false
134187
*/
135188
public function set($aNames, $mValue)
136189
{
@@ -162,6 +215,14 @@ public function set($aNames, $mValue)
162215
return false;
163216
}
164217

218+
/**
219+
* @param string $sMethodName
220+
* @param array<array-key, mixed> $aArguments
221+
*
222+
* @return mixed
223+
*
224+
* @throws \Exception
225+
*/
165226
public function __call($sMethodName, array $aArguments)
166227
{
167228
if (strpos($sMethodName, 'set') === 0) {
@@ -175,16 +236,29 @@ public function __call($sMethodName, array $aArguments)
175236
}
176237
}
177238

239+
/**
240+
* @param int $iNumber
241+
*
242+
* @return self
243+
*/
178244
public function indentWithTabs($iNumber = 1)
179245
{
180246
return $this->setIndentation(str_repeat("\t", $iNumber));
181247
}
182248

249+
/**
250+
* @param int $iNumber
251+
*
252+
* @return self
253+
*/
183254
public function indentWithSpaces($iNumber = 2)
184255
{
185256
return $this->setIndentation(str_repeat(" ", $iNumber));
186257
}
187258

259+
/**
260+
* @return OutputFormat
261+
*/
188262
public function nextLevel()
189263
{
190264
if ($this->oNextLevelFormat === null) {
@@ -195,11 +269,17 @@ public function nextLevel()
195269
return $this->oNextLevelFormat;
196270
}
197271

272+
/**
273+
* @return void
274+
*/
198275
public function beLenient()
199276
{
200277
$this->bIgnoreExceptions = true;
201278
}
202279

280+
/**
281+
* @return OutputFormatter
282+
*/
203283
public function getFormatter()
204284
{
205285
if ($this->oFormatter === null) {
@@ -208,25 +288,28 @@ public function getFormatter()
208288
return $this->oFormatter;
209289
}
210290

291+
/**
292+
* @return int
293+
*/
211294
public function level()
212295
{
213296
return $this->iIndentationLevel;
214297
}
215298

216299
/**
217-
* Create format.
300+
* Creates an instance of this class without any particular formatting settings.
218301
*
219-
* @return OutputFormat Format.
302+
* @return self
220303
*/
221304
public static function create()
222305
{
223306
return new OutputFormat();
224307
}
225308

226309
/**
227-
* Create compact format.
310+
* Creates an instance of this class with a preset for compact formatting.
228311
*
229-
* @return OutputFormat Format.
312+
* @return self
230313
*/
231314
public static function createCompact()
232315
{
@@ -237,9 +320,9 @@ public static function createCompact()
237320
}
238321

239322
/**
240-
* Create pretty format.
323+
* Creates an instance of this class with a preset for pretty formatting.
241324
*
242-
* @return OutputFormat Format.
325+
* @return self
243326
*/
244327
public static function createPretty()
245328
{

0 commit comments

Comments
 (0)