Debian Codegraph @

vendor/wikimedia/css-sanitizer/src/Grammar/NonEmpty.php

raw
1 <?php
2 /**
3 * @file
4 * @license https://opensource.org/licenses/Apache-2.0 Apache-2.0
5 */
6
7 namespace Wikimedia\CSS\Grammar;
8
9 use Wikimedia\CSS\Objects\ComponentValueList;
10
11 /**
12 * Matcher that requires its sub-Matcher has only non-empty matches ("!" multiplier)
13 * @see https://www.w3.org/TR/2024/WD-css-values-4-20240312/#mult-req
14 */
15 class NonEmpty extends Matcher {
16 /** @var Matcher */
17 protected $matcher;
18
19 /**
20 * @param Matcher $matcher
21 */
22 public function __construct( Matcher $matcher ) {
23 $this->matcher = $matcher;
24 }
25
26 /** @inheritDoc */
27 protected function generateMatches( ComponentValueList $values, $start, array $options ) {
28 foreach ( $this->matcher->generateMatches( $values, $start, $options ) as $match ) {
29 if ( $match->getLength() !== 0 ) {
30 yield $this->makeMatch( $values, $start, $match->getNext(), $match );
31 }
32 }
33 }
34 }