From 7a40a6aa3f92e3a61ee01168e4a544495312d426 Mon Sep 17 00:00:00 2001 From: Reedy Date: Fri, 8 Jan 2021 03:11:35 +0000 Subject: [PATCH] Update use of css-sanitizer classes for PHP 8.0 compat Bug: T268862 Change-Id: I13ad3abe70b693886a79ab37c64f34e0113e9071 --- composer.json | 2 +- includes/TemplateStylesHooks.php | 6 +++--- tests/phpunit/unit/TemplateStylesMatcherFactoryTest.php | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index 8847344..f2ce896 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "license": "GPL-2.0-or-later", "require": { - "wikimedia/css-sanitizer": "~2.0.0" + "wikimedia/css-sanitizer": "~3.0.0" }, "require-dev": { "mediawiki/mediawiki-codesniffer": "31.0.0", diff --git a/includes/TemplateStylesHooks.php b/includes/TemplateStylesHooks.php index 468606b..edf1b57 100644 --- a/includes/TemplateStylesHooks.php +++ b/includes/TemplateStylesHooks.php @@ -7,7 +7,7 @@ use MediaWiki\Revision\SlotRecord; use Wikimedia\CSS\Grammar\CheckedMatcher; -use Wikimedia\CSS\Grammar\Match; +use Wikimedia\CSS\Grammar\GrammarMatch; use Wikimedia\CSS\Grammar\MatcherFactory; use Wikimedia\CSS\Objects\ComponentValueList; use Wikimedia\CSS\Objects\Token; @@ -82,7 +82,7 @@ class TemplateStylesHooks { $match = false; } else { $match = self::getMatcherFactory()->cssSimpleSelectorSeq() - ->match( $components, [ 'mark-significance' => true ] ); + ->matchAgainst( $components, [ 'mark-significance' => true ] ); } self::$wrappers[$wrapper] = $match ? $components->toTokenArray() : false; } @@ -110,7 +110,7 @@ class TemplateStylesHooks { $htmlOrBodySimpleSelectorSeqMatcher = new CheckedMatcher( $matcherFactory->cssSimpleSelectorSeq(), - function ( ComponentValueList $values, Match $match, array $options ) { + function ( ComponentValueList $values, GrammarMatch $match, array $options ) { foreach ( $match->getCapturedMatches() as $m ) { if ( $m->getName() !== 'element' ) { continue; diff --git a/tests/phpunit/unit/TemplateStylesMatcherFactoryTest.php b/tests/phpunit/unit/TemplateStylesMatcherFactoryTest.php index 338bbb7..9509a1a 100644 --- a/tests/phpunit/unit/TemplateStylesMatcherFactoryTest.php +++ b/tests/phpunit/unit/TemplateStylesMatcherFactoryTest.php @@ -32,12 +32,12 @@ class TemplateStylesMatcherFactoryTest extends MediaWikiUnitTestCase { $list = new ComponentValueList( [ 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( [ 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() {