Debian Codegraph @

vendor/wikimedia/css-sanitizer/src/Grammar/NoWhitespace.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 use Wikimedia\CSS\Objects\Token;
11
12 /**
13 * Matcher that asserts there was no whitespace before the current position.
14 */
15 class NoWhitespace extends Matcher {
16
17 /** @inheritDoc */
18 protected function generateMatches( ComponentValueList $values, $start, array $options ) {
19 // @phan-suppress-next-line PhanCoalescingNeverNull
20 $cv = $values[$start - 1] ?? null;
21 if ( !$cv instanceof Token || $cv->type() !== Token::T_WHITESPACE ) {
22 yield $this->makeMatch( $values, $start, $start );
23 }
24 }
25 }