PluginProbe
WooCommerce / 11.1.0-beta.2
WooCommerce v11.1.0-beta.2
11.1.0 11.1.0-rc.2 11.1.0-rc.1 11.1.0-beta.2 11.1.0-beta.1 11.0.1 11.0.0 11.0.0-rc.3 11.0.0-rc.2 11.0.0-rc.1 11.0.0-beta.2 11.0.0-beta.1 10.9.4 10.9.3 10.9.2 10.9.1 10.9.0 10.9.0-rc.1 10.9.0-beta.2 10.9.0-beta.1 10.8.1 10.8.0 10.8.0-rc.1 10.8.0-beta.2 10.8.0-beta.1 All 648 releases
woocommerce / lib / packages / Sabberworm / CSS / Parser.php
Parser.php
71 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Automattic\WooCommerce\Vendor\Sabberworm\CSS;
4
5 use Automattic\WooCommerce\Vendor\Sabberworm\CSS\CSSList\Document;
6 use Automattic\WooCommerce\Vendor\Sabberworm\CSS\Parsing\ParserState;
7 use Automattic\WooCommerce\Vendor\Sabberworm\CSS\Parsing\SourceException;
8
9 /**
10 * This class parses CSS from text into a data structure.
11 */
12 class Parser
13 {
14 /**
15 * @var ParserState
16 */
17 private $oParserState;
18
19 /**
20 * @param string $sText the complete CSS as text (i.e., usually the contents of a CSS file)
21 * @param Settings|null $oParserSettings
22 * @param int $iLineNo the line number (starting from 1, not from 0)
23 */
24 public function __construct($sText, $oParserSettings = null, $iLineNo = 1)
25 {
26 if ($oParserSettings === null) {
27 $oParserSettings = Settings::create();
28 }
29 $this->oParserState = new ParserState($sText, $oParserSettings, $iLineNo);
30 }
31
32 /**
33 * Sets the charset to be used if the CSS does not contain an `@charset` declaration.
34 *
35 * @param string $sCharset
36 *
37 * @return void
38 *
39 * @deprecated since 8.7.0, will be removed in version 9.0.0 with #687
40 */
41 public function setCharset($sCharset)
42 {
43 $this->oParserState->setCharset($sCharset);
44 }
45
46 /**
47 * Returns the charset that is used if the CSS does not contain an `@charset` declaration.
48 *
49 * @return void
50 *
51 * @deprecated since 8.7.0, will be removed in version 9.0.0 with #687
52 */
53 public function getCharset()
54 {
55 // Note: The `return` statement is missing here. This is a bug that needs to be fixed.
56 $this->oParserState->getCharset();
57 }
58
59 /**
60 * Parses the CSS provided to the constructor and creates a `Document` from it.
61 *
62 * @return Document
63 *
64 * @throws SourceException
65 */
66 public function parse()
67 {
68 return Document::parse($this->oParserState);
69 }
70 }
71