|
9 | 9 | use Sabberworm\CSS\Parsing\ParserState; |
10 | 10 | use Sabberworm\CSS\Parsing\UnexpectedTokenException; |
11 | 11 | use Sabberworm\CSS\Property\Selector\Combinator; |
| 12 | +use Sabberworm\CSS\Property\Selector\Component; |
12 | 13 | use Sabberworm\CSS\Property\Selector\CompoundSelector; |
13 | 14 | use Sabberworm\CSS\Property\Selector\SpecificityCalculator; |
14 | 15 | use Sabberworm\CSS\Renderable; |
@@ -76,11 +77,11 @@ final public function __construct(string $selector) |
76 | 77 | /** |
77 | 78 | * @param list<Comment> $comments |
78 | 79 | * |
79 | | - * @throws UnexpectedTokenException |
| 80 | + * @return list<Component> |
80 | 81 | * |
81 | | - * @internal |
| 82 | + * @throws UnexpectedTokenException |
82 | 83 | */ |
83 | | - public static function parse(ParserState $parserState, array &$comments = []): self |
| 84 | + private static function parseComponents(ParserState $parserState, array &$comments = []): array |
84 | 85 | { |
85 | 86 | // Whitespace is a descendent combinator, not allowed around a compound selector. |
86 | 87 | // (It is allowed within, e.g. as part of a string or within a function like `:not()`.) |
@@ -109,6 +110,20 @@ public static function parse(ParserState $parserState, array &$comments = []): s |
109 | 110 | } |
110 | 111 | } |
111 | 112 |
|
| 113 | + return $selectorParts; |
| 114 | + } |
| 115 | + |
| 116 | + /** |
| 117 | + * @param list<Comment> $comments |
| 118 | + * |
| 119 | + * @throws UnexpectedTokenException |
| 120 | + * |
| 121 | + * @internal |
| 122 | + */ |
| 123 | + public static function parse(ParserState $parserState, array &$comments = []): self |
| 124 | + { |
| 125 | + $selectorParts = self::parseComponents($parserState, $comments); |
| 126 | + |
112 | 127 | // Check that the selector has been fully parsed: |
113 | 128 | if (!\in_array($parserState->peek(), ['{', '}', ',', ''], true)) { |
114 | 129 | throw new UnexpectedTokenException( |
|
0 commit comments