PluginProbe
WCPOS – Point of Sale (POS) plugin for WooCommerce / 1.10.18
WCPOS – Point of Sale (POS) plugin for WooCommerce v1.10.18
1.10.19 1.10.18 1.10.17 1.10.16 1.10.15 1.10.13 1.10.14 1.10.12 1.10.11 1.10.10 1.10.9 1.10.8 untagged-3d9b7ccddc54df87c672 1.10.7 1.10.6 1.10.5 1.10.3 1.10.4 1.10.2 1.10.1 1.10.0 1.9.17 1.9.15 1.9.16 1.9.14 All 163 releases
woocommerce-pos / vendor_prefixed / sabberworm / php-css-parser / src / OutputFormat.php

OutputFormat.php in WCPOS – Point of Sale (POS) plugin for WooCommerce 1.10.18, at vendor_prefixed/sabberworm/php-css-parser/src/OutputFormat.php

640 lines 16.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare (strict_types=1);
4 namespace WCPOS\Vendor\Sabberworm\CSS;
5
6 final class OutputFormat
7 {
8 /**
9 * @var '"'|"'"
10 */
11 private $stringQuotingType = '"';
12 /**
13 * Output RGB colors in hash notation if possible
14 *
15 * @var bool
16 */
17 private $usesRgbHashNotation = \true;
18 /**
19 * Declaration format
20 *
21 * Semicolon after the last rule of a declaration block can be omitted. To do that, set this false.
22 *
23 * @var bool
24 */
25 private $renderSemicolonAfterLastRule = \true;
26 /**
27 * Spacing
28 * Note that these strings are not sanity-checked: the value should only consist of whitespace
29 * Any newline character will be indented according to the current level.
30 * The triples (After, Before, Between) can be set using a wildcard
31 * (e.g. `$outputFormat->set('Space*Rules', "\n");`)
32 *
33 * @var string
34 */
35 private $spaceAfterRuleName = ' ';
36 /**
37 * @var string
38 */
39 private $spaceBeforeRules = '';
40 /**
41 * @var string
42 */
43 private $spaceAfterRules = '';
44 /**
45 * @var string
46 */
47 private $spaceBetweenRules = '';
48 /**
49 * @var string
50 */
51 private $spaceBeforeBlocks = '';
52 /**
53 * @var string
54 */
55 private $spaceAfterBlocks = '';
56 /**
57 * @var string
58 */
59 private $spaceBetweenBlocks = "\n";
60 /**
61 * Content injected in and around at-rule blocks.
62 *
63 * @var string
64 */
65 private $contentBeforeAtRuleBlock = '';
66 /**
67 * @var string
68 */
69 private $contentAfterAtRuleBlock = '';
70 /**
71 * This is what’s printed before and after the comma if a declaration block contains multiple selectors.
72 *
73 * @var string
74 */
75 private $spaceBeforeSelectorSeparator = '';
76 /**
77 * @var string
78 */
79 private $spaceAfterSelectorSeparator = ' ';
80 /**
81 * @var string
82 */
83 private $spaceAroundSelectorCombinator = ' ';
84 /**
85 * This is what’s inserted before the separator in value lists, by default.
86 *
87 * @var string
88 */
89 private $spaceBeforeListArgumentSeparator = '';
90 /**
91 * Keys are separators (e.g. `,`). Values are the space sequence to insert, or an empty string.
92 *
93 * @var array<non-empty-string, string>
94 */
95 private $spaceBeforeListArgumentSeparators = [];
96 /**
97 * This is what’s inserted after the separator in value lists, by default.
98 *
99 * @var string
100 */
101 private $spaceAfterListArgumentSeparator = '';
102 /**
103 * Keys are separators (e.g. `,`). Values are the space sequence to insert, or an empty string.
104 *
105 * @var array<non-empty-string, string>
106 */
107 private $spaceAfterListArgumentSeparators = [];
108 /**
109 * @var string
110 */
111 private $spaceBeforeOpeningBrace = ' ';
112 /**
113 * Content injected in and around declaration blocks.
114 *
115 * @var string
116 */
117 private $contentBeforeDeclarationBlock = '';
118 /**
119 * @var string
120 */
121 private $contentAfterDeclarationBlockSelectors = '';
122 /**
123 * @var string
124 */
125 private $contentAfterDeclarationBlock = '';
126 /**
127 * Indentation character(s) per level. Only applicable if newlines are used in any of the spacing settings.
128 *
129 * @var string
130 */
131 private $indentation = "\t";
132 /**
133 * Output exceptions.
134 *
135 * @var bool
136 */
137 private $shouldIgnoreExceptions = \false;
138 /**
139 * Render comments for lists and RuleSets
140 *
141 * @var bool
142 */
143 private $shouldRenderComments = \false;
144 /**
145 * @var OutputFormatter|null
146 */
147 private $outputFormatter;
148 /**
149 * @var OutputFormat|null
150 */
151 private $nextLevelFormat;
152 /**
153 * @var int<0, max>
154 */
155 private $indentationLevel = 0;
156 /**
157 * @return '"'|"'"
158 *
159 * @internal
160 */
161 public function getStringQuotingType() : string
162 {
163 return $this->stringQuotingType;
164 }
165 /**
166 * @param '"'|"'" $quotingType
167 *
168 * @return $this fluent interface
169 */
170 public function setStringQuotingType(string $quotingType) : self
171 {
172 $this->stringQuotingType = $quotingType;
173 return $this;
174 }
175 /**
176 * @internal
177 */
178 public function usesRgbHashNotation() : bool
179 {
180 return $this->usesRgbHashNotation;
181 }
182 /**
183 * @return $this fluent interface
184 */
185 public function setRGBHashNotation(bool $usesRgbHashNotation) : self
186 {
187 $this->usesRgbHashNotation = $usesRgbHashNotation;
188 return $this;
189 }
190 /**
191 * @internal
192 */
193 public function shouldRenderSemicolonAfterLastRule() : bool
194 {
195 return $this->renderSemicolonAfterLastRule;
196 }
197 /**
198 * @return $this fluent interface
199 */
200 public function setSemicolonAfterLastRule(bool $renderSemicolonAfterLastRule) : self
201 {
202 $this->renderSemicolonAfterLastRule = $renderSemicolonAfterLastRule;
203 return $this;
204 }
205 /**
206 * @internal
207 */
208 public function getSpaceAfterRuleName() : string
209 {
210 return $this->spaceAfterRuleName;
211 }
212 /**
213 * @return $this fluent interface
214 */
215 public function setSpaceAfterRuleName(string $whitespace) : self
216 {
217 $this->spaceAfterRuleName = $whitespace;
218 return $this;
219 }
220 /**
221 * @internal
222 */
223 public function getSpaceBeforeRules() : string
224 {
225 return $this->spaceBeforeRules;
226 }
227 /**
228 * @return $this fluent interface
229 */
230 public function setSpaceBeforeRules(string $whitespace) : self
231 {
232 $this->spaceBeforeRules = $whitespace;
233 return $this;
234 }
235 /**
236 * @internal
237 */
238 public function getSpaceAfterRules() : string
239 {
240 return $this->spaceAfterRules;
241 }
242 /**
243 * @return $this fluent interface
244 */
245 public function setSpaceAfterRules(string $whitespace) : self
246 {
247 $this->spaceAfterRules = $whitespace;
248 return $this;
249 }
250 /**
251 * @internal
252 */
253 public function getSpaceBetweenRules() : string
254 {
255 return $this->spaceBetweenRules;
256 }
257 /**
258 * @return $this fluent interface
259 */
260 public function setSpaceBetweenRules(string $whitespace) : self
261 {
262 $this->spaceBetweenRules = $whitespace;
263 return $this;
264 }
265 /**
266 * @internal
267 */
268 public function getSpaceBeforeBlocks() : string
269 {
270 return $this->spaceBeforeBlocks;
271 }
272 /**
273 * @return $this fluent interface
274 */
275 public function setSpaceBeforeBlocks(string $whitespace) : self
276 {
277 $this->spaceBeforeBlocks = $whitespace;
278 return $this;
279 }
280 /**
281 * @internal
282 */
283 public function getSpaceAfterBlocks() : string
284 {
285 return $this->spaceAfterBlocks;
286 }
287 /**
288 * @return $this fluent interface
289 */
290 public function setSpaceAfterBlocks(string $whitespace) : self
291 {
292 $this->spaceAfterBlocks = $whitespace;
293 return $this;
294 }
295 /**
296 * @internal
297 */
298 public function getSpaceBetweenBlocks() : string
299 {
300 return $this->spaceBetweenBlocks;
301 }
302 /**
303 * @return $this fluent interface
304 */
305 public function setSpaceBetweenBlocks(string $whitespace) : self
306 {
307 $this->spaceBetweenBlocks = $whitespace;
308 return $this;
309 }
310 /**
311 * @internal
312 */
313 public function getContentBeforeAtRuleBlock() : string
314 {
315 return $this->contentBeforeAtRuleBlock;
316 }
317 /**
318 * @return $this fluent interface
319 */
320 public function setBeforeAtRuleBlock(string $content) : self
321 {
322 $this->contentBeforeAtRuleBlock = $content;
323 return $this;
324 }
325 /**
326 * @internal
327 */
328 public function getContentAfterAtRuleBlock() : string
329 {
330 return $this->contentAfterAtRuleBlock;
331 }
332 /**
333 * @return $this fluent interface
334 */
335 public function setAfterAtRuleBlock(string $content) : self
336 {
337 $this->contentAfterAtRuleBlock = $content;
338 return $this;
339 }
340 /**
341 * @internal
342 */
343 public function getSpaceBeforeSelectorSeparator() : string
344 {
345 return $this->spaceBeforeSelectorSeparator;
346 }
347 /**
348 * @return $this fluent interface
349 */
350 public function setSpaceBeforeSelectorSeparator(string $whitespace) : self
351 {
352 $this->spaceBeforeSelectorSeparator = $whitespace;
353 return $this;
354 }
355 /**
356 * @internal
357 */
358 public function getSpaceAfterSelectorSeparator() : string
359 {
360 return $this->spaceAfterSelectorSeparator;
361 }
362 /**
363 * @return $this fluent interface
364 */
365 public function setSpaceAfterSelectorSeparator(string $whitespace) : self
366 {
367 $this->spaceAfterSelectorSeparator = $whitespace;
368 return $this;
369 }
370 /**
371 * @internal
372 */
373 public function getSpaceAroundSelectorCombinator() : string
374 {
375 return $this->spaceAroundSelectorCombinator;
376 }
377 /**
378 * The spacing set is also used for the descendent combinator, which is whitespace only,
379 * unless an empty string is set, in which case a space will be used.
380 *
381 * @return $this fluent interface
382 */
383 public function setSpaceAroundSelectorCombinator(string $whitespace) : self
384 {
385 $this->spaceAroundSelectorCombinator = $whitespace;
386 return $this;
387 }
388 /**
389 * @internal
390 */
391 public function getSpaceBeforeListArgumentSeparator() : string
392 {
393 return $this->spaceBeforeListArgumentSeparator;
394 }
395 /**
396 * @return $this fluent interface
397 */
398 public function setSpaceBeforeListArgumentSeparator(string $whitespace) : self
399 {
400 $this->spaceBeforeListArgumentSeparator = $whitespace;
401 return $this;
402 }
403 /**
404 * @return array<non-empty-string, string>
405 *
406 * @internal
407 */
408 public function getSpaceBeforeListArgumentSeparators() : array
409 {
410 return $this->spaceBeforeListArgumentSeparators;
411 }
412 /**
413 * @param array<non-empty-string, string> $separatorSpaces
414 *
415 * @return $this fluent interface
416 */
417 public function setSpaceBeforeListArgumentSeparators(array $separatorSpaces) : self
418 {
419 $this->spaceBeforeListArgumentSeparators = $separatorSpaces;
420 return $this;
421 }
422 /**
423 * @internal
424 */
425 public function getSpaceAfterListArgumentSeparator() : string
426 {
427 return $this->spaceAfterListArgumentSeparator;
428 }
429 /**
430 * @return $this fluent interface
431 */
432 public function setSpaceAfterListArgumentSeparator(string $whitespace) : self
433 {
434 $this->spaceAfterListArgumentSeparator = $whitespace;
435 return $this;
436 }
437 /**
438 * @return array<non-empty-string, string>
439 *
440 * @internal
441 */
442 public function getSpaceAfterListArgumentSeparators() : array
443 {
444 return $this->spaceAfterListArgumentSeparators;
445 }
446 /**
447 * @param array<non-empty-string, string> $separatorSpaces
448 *
449 * @return $this fluent interface
450 */
451 public function setSpaceAfterListArgumentSeparators(array $separatorSpaces) : self
452 {
453 $this->spaceAfterListArgumentSeparators = $separatorSpaces;
454 return $this;
455 }
456 /**
457 * @internal
458 */
459 public function getSpaceBeforeOpeningBrace() : string
460 {
461 return $this->spaceBeforeOpeningBrace;
462 }
463 /**
464 * @return $this fluent interface
465 */
466 public function setSpaceBeforeOpeningBrace(string $whitespace) : self
467 {
468 $this->spaceBeforeOpeningBrace = $whitespace;
469 return $this;
470 }
471 /**
472 * @internal
473 */
474 public function getContentBeforeDeclarationBlock() : string
475 {
476 return $this->contentBeforeDeclarationBlock;
477 }
478 /**
479 * @return $this fluent interface
480 */
481 public function setBeforeDeclarationBlock(string $content) : self
482 {
483 $this->contentBeforeDeclarationBlock = $content;
484 return $this;
485 }
486 /**
487 * @internal
488 */
489 public function getContentAfterDeclarationBlockSelectors() : string
490 {
491 return $this->contentAfterDeclarationBlockSelectors;
492 }
493 /**
494 * @return $this fluent interface
495 */
496 public function setAfterDeclarationBlockSelectors(string $content) : self
497 {
498 $this->contentAfterDeclarationBlockSelectors = $content;
499 return $this;
500 }
501 /**
502 * @internal
503 */
504 public function getContentAfterDeclarationBlock() : string
505 {
506 return $this->contentAfterDeclarationBlock;
507 }
508 /**
509 * @return $this fluent interface
510 */
511 public function setAfterDeclarationBlock(string $content) : self
512 {
513 $this->contentAfterDeclarationBlock = $content;
514 return $this;
515 }
516 /**
517 * @internal
518 */
519 public function getIndentation() : string
520 {
521 return $this->indentation;
522 }
523 /**
524 * @return $this fluent interface
525 */
526 public function setIndentation(string $indentation) : self
527 {
528 $this->indentation = $indentation;
529 return $this;
530 }
531 /**
532 * @internal
533 */
534 public function shouldIgnoreExceptions() : bool
535 {
536 return $this->shouldIgnoreExceptions;
537 }
538 /**
539 * @return $this fluent interface
540 */
541 public function setIgnoreExceptions(bool $ignoreExceptions) : self
542 {
543 $this->shouldIgnoreExceptions = $ignoreExceptions;
544 return $this;
545 }
546 /**
547 * @internal
548 */
549 public function shouldRenderComments() : bool
550 {
551 return $this->shouldRenderComments;
552 }
553 /**
554 * @return $this fluent interface
555 */
556 public function setRenderComments(bool $renderComments) : self
557 {
558 $this->shouldRenderComments = $renderComments;
559 return $this;
560 }
561 /**
562 * @return int<0, max>
563 *
564 * @internal
565 */
566 public function getIndentationLevel() : int
567 {
568 return $this->indentationLevel;
569 }
570 /**
571 * @param int<1, max> $numberOfTabs
572 *
573 * @return $this fluent interface
574 */
575 public function indentWithTabs(int $numberOfTabs = 1) : self
576 {
577 return $this->setIndentation(\str_repeat("\t", $numberOfTabs));
578 }
579 /**
580 * @param int<1, max> $numberOfSpaces
581 *
582 * @return $this fluent interface
583 */
584 public function indentWithSpaces(int $numberOfSpaces = 2) : self
585 {
586 return $this->setIndentation(\str_repeat(' ', $numberOfSpaces));
587 }
588 /**
589 * @internal since V8.8.0
590 */
591 public function nextLevel() : self
592 {
593 if ($this->nextLevelFormat === null) {
594 $this->nextLevelFormat = clone $this;
595 $this->nextLevelFormat->indentationLevel++;
596 $this->nextLevelFormat->outputFormatter = null;
597 }
598 return $this->nextLevelFormat;
599 }
600 public function beLenient() : void
601 {
602 $this->shouldIgnoreExceptions = \true;
603 }
604 /**
605 * @internal since 8.8.0
606 */
607 public function getFormatter() : OutputFormatter
608 {
609 if ($this->outputFormatter === null) {
610 $this->outputFormatter = new OutputFormatter($this);
611 }
612 return $this->outputFormatter;
613 }
614 /**
615 * Creates an instance of this class without any particular formatting settings.
616 */
617 public static function create() : self
618 {
619 return new OutputFormat();
620 }
621 /**
622 * Creates an instance of this class with a preset for compact formatting.
623 */
624 public static function createCompact() : self
625 {
626 $format = self::create();
627 $format->setSpaceBeforeRules('')->setSpaceBetweenRules('')->setSpaceAfterRules('')->setSpaceBeforeBlocks('')->setSpaceBetweenBlocks('')->setSpaceAfterBlocks('')->setSpaceAfterRuleName('')->setSpaceBeforeOpeningBrace('')->setSpaceAfterSelectorSeparator('')->setSpaceAroundSelectorCombinator('')->setSemicolonAfterLastRule(\false)->setRenderComments(\false);
628 return $format;
629 }
630 /**
631 * Creates an instance of this class with a preset for pretty formatting.
632 */
633 public static function createPretty() : self
634 {
635 $format = self::create();
636 $format->setSpaceBeforeRules("\n")->setSpaceBetweenRules("\n")->setSpaceAfterRules("\n")->setSpaceBeforeBlocks("\n")->setSpaceBetweenBlocks("\n\n")->setSpaceAfterBlocks("\n")->setSpaceAfterListArgumentSeparators([',' => ' '])->setRenderComments(\true);
637 return $format;
638 }
639 }
640