From 24cb62e04457925fb48a4b37700cc3693587ab2b 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 Depends-On: Ia33f51d54f0e0f51249c999c2bd6a0091aac0b66 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 fdc1f85..3780c0f 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": "34.0.0", diff --git a/includes/TemplateStylesHooks.php b/includes/TemplateStylesHooks.php index 0aba7ed..1b493a8 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\ComponentValue; use Wikimedia\CSS\Objects\ComponentValueList; @@ -73,7 +73,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->toComponentValueArray() : false; } @@ -100,7 +100,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() {