*/ private const CACHE_KEY_SELECTOR = 0; /** * @var int<0, 1> */ private const CACHE_KEY_COMBINED_STYLES = 1; /** * Regular expression component matching a static pseudo class in a selector, without the preceding ":", * for which the applicable elements can be determined (by converting the selector to an XPath expression). * (Contains alternation without a group and is intended to be placed within a capturing, non-capturing or lookahead * group, as appropriate for the usage context.) * * @var non-empty-string */ private const PSEUDO_CLASS_MATCHER = 'empty|(?:first|last|nth(?:-last)?+|only)-(?:child|of-type)|not\\([[:ascii:]]*\\)|root'; /** * This regular expression component matches an `...of-type` pseudo class name, without the preceding ":". These * pseudo-classes can currently online be inlined if they have an associated type in the selector expression. * * @var non-empty-string */ private const OF_TYPE_PSEUDO_CLASS_MATCHER = '(?:first|last|nth(?:-last)?+|only)-of-type'; /** * regular expression component to match a selector combinator * * @var non-empty-string */ private const COMBINATOR_MATCHER = '(?:\\s++|\\s*+[>+~]\\s*+)(?=[[:alpha:]_\\-.#*:\\[])'; /** * options array key for `querySelectorAll` * * @var non-empty-string */ private const QSA_ALWAYS_THROW_PARSE_EXCEPTION = 'alwaysThrowParseException'; /** * @var array */ private $excludedSelectors = []; /** * @var array */ private $excludedCssSelectors = []; /** * @var array */ private $allowedMediaTypes = ['all' => true, 'screen' => true, 'print' => true]; /** * @var array{ * 0: array>, * 1: array * } */ private $caches = [ self::CACHE_KEY_SELECTOR => [], self::CACHE_KEY_COMBINED_STYLES => [], ]; /** * @var CssSelectorConverter|null */ private $cssSelectorConverter = null; /** * the visited nodes with the XPath paths as array keys * * @var array */ private $visitedNodes = []; /** * the styles to apply to the nodes with the XPath paths as array keys for the outer array * and the attribute names/values as key/value pairs for the inner array * * @var array> */ private $styleAttributesForNodes = []; /** * Determines whether the "style" attributes of tags in the the HTML passed to this class should be preserved. * If set to false, the value of the style attributes will be discarded. * * @var bool */ private $isInlineStyleAttributesParsingEnabled = true; /** * Determines whether the `