Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | n/a |
0 / 0 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
|||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Phpdftk\Css\Selector; |
| 6 | |
| 7 | /** |
| 8 | * The minimal element-shape the Selectors-4 matcher needs to traverse and |
| 9 | * test a DOM. Lives in `phpdftk/css` so the matcher can stay free of any |
| 10 | * specific DOM library; `phpdftk/html`'s `Element` implements this so the |
| 11 | * matcher works against the WHATWG DOM. |
| 12 | * |
| 13 | * Tree relationships use `MatchableElement` directly so combinators |
| 14 | * (`>` / `+` / `~`) can walk without leaking concrete DOM types. The matcher |
| 15 | * does not mutate the tree — every method here is read-only. |
| 16 | */ |
| 17 | interface MatchableElement |
| 18 | { |
| 19 | public function localName(): string; |
| 20 | |
| 21 | /** |
| 22 | * Namespace URI. `null` when not in a namespace (HTML elements typically |
| 23 | * carry `'http://www.w3.org/1999/xhtml'`); SVG / MathML elements carry |
| 24 | * their own URIs. |
| 25 | */ |
| 26 | public function namespaceUri(): ?string; |
| 27 | |
| 28 | /** Lowercased `id` attribute value, or null when absent / empty. */ |
| 29 | public function elementId(): ?string; |
| 30 | |
| 31 | /** @return list<string> Space-separated `class` attribute tokens. */ |
| 32 | public function classes(): array; |
| 33 | |
| 34 | public function hasAttribute(string $name): bool; |
| 35 | |
| 36 | public function getAttributeValue(string $name): ?string; |
| 37 | |
| 38 | /** @return array<string, string> attribute name → value, names normalised */ |
| 39 | public function allAttributes(): array; |
| 40 | |
| 41 | public function parentElement(): ?MatchableElement; |
| 42 | |
| 43 | public function previousElementSibling(): ?MatchableElement; |
| 44 | |
| 45 | public function nextElementSibling(): ?MatchableElement; |
| 46 | |
| 47 | /** @return list<MatchableElement> direct element children, in document order */ |
| 48 | public function elementChildren(): array; |
| 49 | |
| 50 | /** |
| 51 | * 1-based position among the parent's element children. Returns 1 when |
| 52 | * the element has no parent. |
| 53 | */ |
| 54 | public function indexAmongSiblings(): int; |
| 55 | |
| 56 | /** |
| 57 | * Like {@see indexAmongSiblings} but counted from the end. Used for the |
| 58 | * `nth-last-*` pseudo-classes. |
| 59 | */ |
| 60 | public function indexAmongSiblingsFromEnd(): int; |
| 61 | |
| 62 | /** |
| 63 | * 1-based position among same-tag siblings (used by `:nth-of-type`). |
| 64 | * Sibling matching uses local name + namespace URI together. |
| 65 | */ |
| 66 | public function indexAmongTypeSiblings(): int; |
| 67 | |
| 68 | public function indexAmongTypeSiblingsFromEnd(): int; |
| 69 | } |