Update use of css-sanitizer classes for PHP 8.0 compat

Bug: T268862
Change-Id: I13ad3abe70b693886a79ab37c64f34e0113e9071
This commit is contained in:
Reedy 2021-01-08 03:11:35 +00:00
parent 7743810422
commit 7a40a6aa3f
3 changed files with 6 additions and 6 deletions

View file

@ -1,7 +1,7 @@
{ {
"license": "GPL-2.0-or-later", "license": "GPL-2.0-or-later",
"require": { "require": {
"wikimedia/css-sanitizer": "~2.0.0" "wikimedia/css-sanitizer": "~3.0.0"
}, },
"require-dev": { "require-dev": {
"mediawiki/mediawiki-codesniffer": "31.0.0", "mediawiki/mediawiki-codesniffer": "31.0.0",

View file

@ -7,7 +7,7 @@
use MediaWiki\Revision\SlotRecord; use MediaWiki\Revision\SlotRecord;
use Wikimedia\CSS\Grammar\CheckedMatcher; use Wikimedia\CSS\Grammar\CheckedMatcher;
use Wikimedia\CSS\Grammar\Match; use Wikimedia\CSS\Grammar\GrammarMatch;
use Wikimedia\CSS\Grammar\MatcherFactory; use Wikimedia\CSS\Grammar\MatcherFactory;
use Wikimedia\CSS\Objects\ComponentValueList; use Wikimedia\CSS\Objects\ComponentValueList;
use Wikimedia\CSS\Objects\Token; use Wikimedia\CSS\Objects\Token;
@ -82,7 +82,7 @@ class TemplateStylesHooks {
$match = false; $match = false;
} else { } else {
$match = self::getMatcherFactory()->cssSimpleSelectorSeq() $match = self::getMatcherFactory()->cssSimpleSelectorSeq()
->match( $components, [ 'mark-significance' => true ] ); ->matchAgainst( $components, [ 'mark-significance' => true ] );
} }
self::$wrappers[$wrapper] = $match ? $components->toTokenArray() : false; self::$wrappers[$wrapper] = $match ? $components->toTokenArray() : false;
} }
@ -110,7 +110,7 @@ class TemplateStylesHooks {
$htmlOrBodySimpleSelectorSeqMatcher = new CheckedMatcher( $htmlOrBodySimpleSelectorSeqMatcher = new CheckedMatcher(
$matcherFactory->cssSimpleSelectorSeq(), $matcherFactory->cssSimpleSelectorSeq(),
function ( ComponentValueList $values, Match $match, array $options ) { function ( ComponentValueList $values, GrammarMatch $match, array $options ) {
foreach ( $match->getCapturedMatches() as $m ) { foreach ( $match->getCapturedMatches() as $m ) {
if ( $m->getName() !== 'element' ) { if ( $m->getName() !== 'element' ) {
continue; continue;

View file

@ -32,12 +32,12 @@ class TemplateStylesMatcherFactoryTest extends MediaWikiUnitTestCase {
$list = new ComponentValueList( [ $list = new ComponentValueList( [
new Token( Token::T_STRING, $url ) new Token( Token::T_STRING, $url )
] ); ] );
$this->assertSame( $expect, (bool)$factory->urlstring( $type )->match( $list ) ); $this->assertSame( $expect, (bool)$factory->urlstring( $type )->matchAgainst( $list ) );
$list = new ComponentValueList( [ $list = new ComponentValueList( [
new Token( Token::T_URL, $url ) new Token( Token::T_URL, $url )
] ); ] );
$this->assertSame( $expect, (bool)$factory->url( $type )->match( $list ) ); $this->assertSame( $expect, (bool)$factory->url( $type )->matchAgainst( $list ) );
} }
public static function provideUrls() { public static function provideUrls() {