Table of contents
Namespace: Com\Tecnick\Pdf\CSS
File: SelectorMatcher.php line 61
CSS selector compiler and matcher for the SVG cascade.
Supports type, class, id and universal selectors, attribute selectors, the descendant, child, adjacent sibling and general sibling combinators, and the structural pseudo-classes that a document read in order can decide: ‘:root’, ‘:first-child’, ‘:nth-child()’, ‘:not()’ over a simple compound.
A selector that needs to look ahead of the current element (’:last-child’, ‘:only-child’, ‘:nth-last-child()’, ‘:empty’) or that uses anything else is rejected by compile(), so it applies to nothing rather than applying wrongly.
Tags
- since: 2002-08-03
- category: Library
- author: Nicola Asuni info@tecnick.com
- copyright: 2002-2026 Nicola Asuni - Tecnick.com LTD
- license: https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
- link: https://github.com/tecnickcom/tc-lib-pdf
- phpstan-type: TSelNode array{ ’name’: string, ‘id’: string, ‘classes’: array<int, string>, ‘attr’: array<string, string>, ‘index’: int, ‘depth’: int, }
- phpstan-type: TSelPart array{ ‘combinator’: string, ’type’: string, ‘id’: string, ‘classes’: array<int, string>, ‘attrs’: array<int, array{’name’: string, ‘op’: string, ‘value’: string}>, ‘pseudo’: array<int, array{’name’: string, ‘arg’: string}>, }
Methods
compile()
File: SelectorMatcher.php line 98
public static compile(string $selector) : array<int, TSelPart>|null
Parameters
- $selector : string: Selector with its white space already collapsed.
Return values
array<int, TSelPart>|null —
Compiled parts, or null when unsupported.
matches()
File: SelectorMatcher.php line 332
public static matches(array<int, TSelPart> $parts, array<int, TSelNode>}> $chain) : bool
Parameters
- $parts : array<int, TSelPart>: Compiled selector.
- $chain : array<int, TSelNode>}>: Open elements from the root to the element under test.
Return values
bool