build: Updating mediawiki/mediawiki-phan-config to 0.9.0

One of the most significant changes is when I noticed that the $group
can never be null. We set it to DEFAULT_GROUP before. That's an empty
string.

I'm not very happy with the two @phan-suppress-next-line. Is there a
better way to fix these lines?

Change-Id: I33c1681e2f3857cb6701da71f4ed8893caff4d1e
This commit is contained in:
libraryupgrader 2019-12-21 01:25:58 +00:00 committed by Umherirrender
parent c3823ce172
commit 2e0792a0dd
5 changed files with 27 additions and 23 deletions

View file

@ -3,7 +3,7 @@
"jakub-onderka/php-console-highlighter": "0.3.2",
"jakub-onderka/php-parallel-lint": "1.0.0",
"mediawiki/mediawiki-codesniffer": "28.0.0",
"mediawiki/mediawiki-phan-config": "0.8.0",
"mediawiki/mediawiki-phan-config": "0.9.0",
"mediawiki/minus-x": "0.3.2"
},
"scripts": {

View file

@ -139,7 +139,7 @@ class Cite {
/**
* @param ?string $text
* @param ?string $group
* @param string $group
* @param ?string $name
* @param ?string $extends
* @param ?string $follow
@ -148,13 +148,16 @@ class Cite {
*/
private function validateRef(
?string $text,
?string $group,
string $group,
?string $name,
?string $extends,
?string $follow,
?string $dir
) : StatusValue {
if ( ctype_digit( $name ) || ctype_digit( $follow ) || ctype_digit( $extends ) ) {
if ( ctype_digit( (string)$name )
|| ctype_digit( (string)$extends )
|| ctype_digit( (string)$follow )
) {
// Numeric names mess up the resulting id's, potentially producing
// duplicate id's in the XHTML. The Right Thing To Do
// would be to mangle them, but it's not really high-priority
@ -204,7 +207,7 @@ class Cite {
}
}
if ( preg_match(
if ( $text !== null && preg_match(
'/<ref(erences)?\b[^>]*+>/i',
preg_replace( '#<(\w++)[^>]*+>.*?</\1\s*>|<!--.*?-->#s', '', $text )
) ) {
@ -230,7 +233,7 @@ class Cite {
private function validateRefInReferences(
?string $text,
?string $name,
?string $group
string $group
): StatusValue {
// FIXME: Some assertions make assumptions that rely on earlier tests not failing.
// These dependencies need to be explicit so they aren't accidentally broken by
@ -324,7 +327,7 @@ class Cite {
...$error['params']
);
}
} else {
} elseif ( $text !== null ) {
$groupRefs = $this->referenceStack->getGroupRefs( $group );
if ( !isset( $groupRefs[$name]['text'] ) ) {
$this->referenceStack->appendText( $group, $name, $text );

View file

@ -135,7 +135,7 @@ class ReferenceStack {
$this->groupRefSequence[$group] = 0;
}
if ( $this->refs[$group][$follow] ?? false ) {
if ( $follow && isset( $this->refs[$group][$follow] ) ) {
// We know the parent note already, so just perform the "follow" and bail out
// TODO: Separate `pushRef` from these side-effects.
$this->appendText( $group, $follow, ' ' . $text );
@ -238,6 +238,7 @@ class ReferenceStack {
}
}
// @phan-suppress-next-line PhanTypePossiblyInvalidDimOffset "key" is guaranteed to be set
$this->refCallStack[] = [ $action, $ref['key'], $group, $name, $extends, $text, $argv ];
return $ref;
}
@ -395,11 +396,11 @@ class ReferenceStack {
/**
* Return all references for a group.
*
* @param ?string $group
* @param string $group
* @return array[]
*/
public function getGroupRefs( ?string $group ) : array {
return $this->refs[$group ?? Cite::DEFAULT_GROUP] ?? [];
public function getGroupRefs( string $group ) : array {
return $this->refs[$group] ?? [];
}
/**

View file

@ -266,7 +266,7 @@ class ReferencesFormatter {
return $this->messageLocalizer->localizeDigits( $base ) .
$this->messageLocalizer->formatNum(
'.' .
str_pad( $offset, strlen( $max ), '0', STR_PAD_LEFT )
str_pad( (string)$offset, strlen( (string)$max ), '0', STR_PAD_LEFT )
);
}

View file

@ -68,7 +68,7 @@ class CiteUnitTest extends \MediaWikiUnitTestCase {
'isSectionPreview' => false,
'text' => null,
'name' => '1',
'group' => null,
'group' => '',
'follow' => null,
'extends' => null,
'dir' => null,
@ -80,7 +80,7 @@ class CiteUnitTest extends \MediaWikiUnitTestCase {
'isSectionPreview' => false,
'text' => 't',
'name' => null,
'group' => null,
'group' => '',
'follow' => '1',
'extends' => null,
'dir' => null,
@ -92,7 +92,7 @@ class CiteUnitTest extends \MediaWikiUnitTestCase {
'isSectionPreview' => false,
'text' => 't',
'name' => null,
'group' => null,
'group' => '',
'follow' => null,
'extends' => '1',
'dir' => null,
@ -104,7 +104,7 @@ class CiteUnitTest extends \MediaWikiUnitTestCase {
'isSectionPreview' => false,
'text' => 't',
'name' => 'n',
'group' => null,
'group' => '',
'follow' => 'f',
'extends' => null,
'dir' => null,
@ -116,7 +116,7 @@ class CiteUnitTest extends \MediaWikiUnitTestCase {
'isSectionPreview' => false,
'text' => 't',
'name' => null,
'group' => null,
'group' => '',
'follow' => 'f',
'extends' => 'e',
'dir' => null,
@ -129,7 +129,7 @@ class CiteUnitTest extends \MediaWikiUnitTestCase {
'isSectionPreview' => false,
'text' => 't',
'name' => null,
'group' => null,
'group' => '',
'follow' => null,
'extends' => null,
'dir' => null,
@ -141,7 +141,7 @@ class CiteUnitTest extends \MediaWikiUnitTestCase {
'isSectionPreview' => false,
'text' => '',
'name' => null,
'group' => null,
'group' => '',
'follow' => null,
'extends' => null,
'dir' => null,
@ -153,7 +153,7 @@ class CiteUnitTest extends \MediaWikiUnitTestCase {
'isSectionPreview' => false,
'text' => null,
'name' => null,
'group' => null,
'group' => '',
'follow' => null,
'extends' => null,
'dir' => null,
@ -165,7 +165,7 @@ class CiteUnitTest extends \MediaWikiUnitTestCase {
'isSectionPreview' => false,
'text' => 'Foo <ref name="bar">',
'name' => 'n',
'group' => null,
'group' => '',
'follow' => null,
'extends' => null,
'dir' => null,
@ -251,7 +251,7 @@ class CiteUnitTest extends \MediaWikiUnitTestCase {
'isSectionPreview' => false,
'text' => 'not empty',
'name' => 'n',
'group' => null,
'group' => '',
'follow' => null,
'extends' => null,
'dir' => 'RTL',
@ -263,7 +263,7 @@ class CiteUnitTest extends \MediaWikiUnitTestCase {
'isSectionPreview' => false,
'text' => 'not empty',
'name' => 'n',
'group' => null,
'group' => '',
'follow' => null,
'extends' => null,
'dir' => 'foobar',