diff options
author | C. Scott Ananian <cscott@cscott.net> | 2025-04-04 09:00:40 -0400 |
---|---|---|
committer | C. Scott Ananian <cscott@cscott.net> | 2025-04-04 09:25:27 -0400 |
commit | 3bf97e3b223fd44ac092a4fc9d462bd65cbc6b71 (patch) | |
tree | 1fd7a8233896cd362935179150b4d6a2110388f1 | |
parent | 724de1902aca9cebd6975d76510bf21343c4436d (diff) | |
download | mediawikicore-3bf97e3b223fd44ac092a4fc9d462bd65cbc6b71.tar.gz mediawikicore-3bf97e3b223fd44ac092a4fc9d462bd65cbc6b71.zip |
Bump wikimedia/parsoid to 0.21.0-a24
Contains tweaks to keep phan happy with the more precise property
types introduced in Parsoid upstream in this release.
Bug: T391042
Depends-On: Ibcf6d7ae272a27905f80390a1b8e2a609d31f6ab
Change-Id: Ib475a2b82d9faccec1c5752fa6d941f8cc849ed7
-rw-r--r-- | composer.json | 2 | ||||
-rw-r--r-- | tests/parser/ParserTestRunner.php | 21 |
2 files changed, 11 insertions, 12 deletions
diff --git a/composer.json b/composer.json index 2193f5ffa6f5..ac14af55c5dc 100644 --- a/composer.json +++ b/composer.json @@ -69,7 +69,7 @@ "wikimedia/minify": "2.9.0", "wikimedia/normalized-exception": "2.1.1", "wikimedia/object-factory": "5.0.1", - "wikimedia/parsoid": "0.21.0-a23", + "wikimedia/parsoid": "0.21.0-a24", "wikimedia/php-session-serializer": "3.0.1", "wikimedia/purtle": "2.0.0", "wikimedia/relpath": "4.0.2", diff --git a/tests/parser/ParserTestRunner.php b/tests/parser/ParserTestRunner.php index e76c22e52f99..9e66e5a13a04 100644 --- a/tests/parser/ParserTestRunner.php +++ b/tests/parser/ParserTestRunner.php @@ -24,9 +24,6 @@ * @todo Make this more independent of the configuration (and if possible the database) * @file * @ingroup Testing - * @phan-file-suppress UnusedPluginSuppression,UnusedPluginFileSuppression - * Prevent phan from crashing CI if - * ParsoidParserHook::getParserTestConfigFileName() happens to exist */ use MediaWiki\Content\WikitextContent; @@ -501,10 +498,8 @@ class ParserTestRunner { ]; // Add magic words used in Parsoid-native extension modules if ( method_exists( ParsoidParserHook::class, 'getParserTestConfigFileName' ) ) { - // https://github.com/phan/phan/issues/2628 - // @phan-suppress-next-line PhanUndeclaredStaticMethod $filename = ParsoidParserHook::getParserTestConfigFileName(); - if ( $filename !== null && file_exists( $filename ) ) { + if ( file_exists( $filename ) ) { $config = json_decode( file_get_contents( $filename ), true ); $extraMagicWords = array_merge( $extraMagicWords, $config['magicwords'] ?? [] @@ -1387,10 +1382,10 @@ class ParserTestRunner { } if ( isset( $opts['maxincludesize'] ) ) { - $options->setMaxIncludeSize( $opts['maxincludesize'] ); + $options->setMaxIncludeSize( (int)$opts['maxincludesize'] ); } if ( isset( $opts['maxtemplatedepth'] ) ) { - $options->setMaxTemplateDepth( $opts['maxtemplatedepth'] ); + $options->setMaxTemplateDepth( (int)$opts['maxtemplatedepth'] ); } return [ $title, $options, $revProps['revid'] ]; @@ -1510,8 +1505,10 @@ class ParserTestRunner { $section = $opts['section']; $out = $parser->getSection( $wikitext, $section ); } elseif ( isset( $opts['replace'] ) ) { - $section = $opts['replace'][0]; - $replace = $opts['replace'][1]; + $o = $opts['replace']; + '@phan-var array $o'; // Phan gets confused about types + $section = $o[0]; + $replace = $o[1]; $out = $parser->replaceSection( $wikitext, $section, $replace ); } elseif ( isset( $opts['comment'] ) ) { $out = MediaWikiServices::getInstance()->getCommentFormatter()->format( $wikitext, $title, $local ); @@ -2063,6 +2060,7 @@ class ParserTestRunner { private function runSelserEditTest( Parsoid $parsoid, PageConfig $pageConfig, ParserTest $test, ParserTestMode $mode, Document $doc ): array { + // @phan-suppress-next-line PhanTypeMismatchArgumentNullable $test->changetree is non-null here $test->applyChanges( [], $doc, $test->changetree ); $editedHTML = ContentUtils::toXML( DOMCompat::getBody( $doc ) ); @@ -2159,7 +2157,7 @@ class ParserTestRunner { $doc = $this->fetchCachedDoc( $parsoid, $pageConfig, $test ); $test->seed = $i . ''; $test->changetree = $test->generateChanges( $doc ); - if ( $test->changetree ) { + if ( $test->changetree ) { // testing for [] not null // new mode with the generated changetree $nmode = new ParserTestMode( 'selser', $test->changetree ); [ $out, $expected ] = $this->runSelserEditTest( $parsoid, $pageConfig, $test, $nmode, $doc ); @@ -2171,6 +2169,7 @@ class ParserTestRunner { } // $test->changetree can be [] which is a NOP for testing // but not a NOP for duplicate change tree tests. + // @phan-suppress-next-line PhanTypeMismatchArgumentNullable $test->changetree is non-null here if ( $test->isDuplicateChangeTree( $test->changetree ) ) { // Once we get a duplicate change tree, we can no longer // generate and run new tests. So, be done now! |