Automattic\WooCommerce\Vendor\Sabberworm\CSS

Parser{}WC 1.0

This class parses CSS from text into a data structure.

No Hooks.

Usage

$Parser = new Parser();
// use class methods

Methods

  1. public __construct($sText, $oParserSettings = null, $iLineNo = 1)
  2. public getCharset()
  3. public parse()
  4. public setCharset($sCharset)
  5. ERROR: no method name found on line `/**`
  6. ERROR: no method name found on line `/**`
  7. ERROR: no method name found on line `*/`
  8. ERROR: no method name found on line `*/`
  9. ERROR: no method name found on line ``
  10. ERROR: no method name found on line ``
  11. ERROR: no method name found on line ``
  12. ERROR: no method name found on line ``
  13. ERROR: no method name found on line ``
  14. ERROR: no method name found on line ``
  15. ERROR: no method name found on line ``
  16. ERROR: no method name found on line ``
  17. ERROR: no method name found on line `// Note: The `return` statement is missing here. This is a bug that needs to be fixed.`
  18. ERROR: no method name found on line `// Note: The `return` statement is missing here. This is a bug that needs to be fixed.`
  19. ERROR: no method name found on line ``
  20. ERROR: no method name found on line ``

Parser{} code WC 10.7.0

class Parser
{
    /**
     * @var ParserState
     */
    private $oParserState;

    /**
     * @param string $sText the complete CSS as text (i.e., usually the contents of a CSS file)
     * @param Settings|null $oParserSettings
     * @param int $iLineNo the line number (starting from 1, not from 0)
     */
    public function __construct($sText, $oParserSettings = null, $iLineNo = 1)
    {
        if ($oParserSettings === null) {
            $oParserSettings = Settings::create();
        }
        $this->oParserState = new ParserState($sText, $oParserSettings, $iLineNo);
    }

    /**
     * Sets the charset to be used if the CSS does not contain an `@charset` declaration.
     *
     * @param string $sCharset
     *
     * @return void
     *
     * @deprecated since 8.7.0, will be removed in version 9.0.0 with #687
     */
    public function setCharset($sCharset)
    {
        $this->oParserState->setCharset($sCharset);
    }

    /**
     * Returns the charset that is used if the CSS does not contain an `@charset` declaration.
     *
     * @return void
     *
     * @deprecated since 8.7.0, will be removed in version 9.0.0 with #687
     */
    public function getCharset()
    {
        // Note: The `return` statement is missing here. This is a bug that needs to be fixed.
        $this->oParserState->getCharset();
    }

    /**
     * Parses the CSS provided to the constructor and creates a `Document` from it.
     *
     * @return Document
     *
     * @throws SourceException
     */
    public function parse()
    {
        return Document::parse($this->oParserState);
    }
}