Update use of css-sanitizer classes for PHP 8.0 compat

Bug: T268862
Depends-On: Ia33f51d54f0e0f51249c999c2bd6a0091aac0b66
Change-Id: I13ad3abe70b693886a79ab37c64f34e0113e9071
This commit is contained in:
Reedy 2021-01-08 03:11:35 +00:00 committed by Jforrester
parent f3ff772296
commit 24cb62e044
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": "34.0.0", "mediawiki/mediawiki-codesniffer": "34.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\ComponentValue; use Wikimedia\CSS\Objects\ComponentValue;
use Wikimedia\CSS\Objects\ComponentValueList; use Wikimedia\CSS\Objects\ComponentValueList;
@ -73,7 +73,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->toComponentValueArray() : false; self::$wrappers[$wrapper] = $match ? $components->toComponentValueArray() : false;
} }
@ -100,7 +100,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() {