mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-27 17:51:09 +00:00
build: Updating composer dependencies
* mediawiki/mediawiki-codesniffer: 35.0.0 → 36.0.0 * php-parallel-lint/php-parallel-lint: 1.2.0 → 1.3.0 Change-Id: I5c152292e83e7f3441e2c08b7d0ad23ac90f194b
This commit is contained in:
parent
c618139b9c
commit
12fb65b9f1
|
@ -1,10 +1,10 @@
|
||||||
{
|
{
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"mediawiki/mediawiki-codesniffer": "35.0.0",
|
"mediawiki/mediawiki-codesniffer": "36.0.0",
|
||||||
"mediawiki/mediawiki-phan-config": "0.10.6",
|
"mediawiki/mediawiki-phan-config": "0.10.6",
|
||||||
"mediawiki/minus-x": "1.1.1",
|
"mediawiki/minus-x": "1.1.1",
|
||||||
"php-parallel-lint/php-console-highlighter": "0.5.0",
|
"php-parallel-lint/php-console-highlighter": "0.5.0",
|
||||||
"php-parallel-lint/php-parallel-lint": "1.2.0"
|
"php-parallel-lint/php-parallel-lint": "1.3.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": [
|
"test": [
|
||||||
|
|
|
@ -229,7 +229,7 @@ class CommentFormatter {
|
||||||
|
|
||||||
$text = preg_replace_callback(
|
$text = preg_replace_callback(
|
||||||
'/<!--__DTSUBSCRIBE__(.*?)-->/',
|
'/<!--__DTSUBSCRIBE__(.*?)-->/',
|
||||||
function ( $matches ) use ( $doc, $itemsByName ) {
|
static function ( $matches ) use ( $doc, $itemsByName ) {
|
||||||
$itemName = $matches[1];
|
$itemName = $matches[1];
|
||||||
$isSubscribed = isset( $itemsByName[ $itemName ] ) && !$itemsByName[ $itemName ]->isMuted();
|
$isSubscribed = isset( $itemsByName[ $itemName ] ) && !$itemsByName[ $itemName ]->isMuted();
|
||||||
$subscribe = $doc->createElement( 'span' );
|
$subscribe = $doc->createElement( 'span' );
|
||||||
|
|
|
@ -162,7 +162,7 @@ class CommentParser {
|
||||||
* @return string Regular expression
|
* @return string Regular expression
|
||||||
*/
|
*/
|
||||||
private static function regexpAlternateGroup( array $values ) : string {
|
private static function regexpAlternateGroup( array $values ) : string {
|
||||||
return '(' . implode( '|', array_map( function ( string $x ) {
|
return '(' . implode( '|', array_map( static function ( string $x ) {
|
||||||
return preg_quote( $x, '/' );
|
return preg_quote( $x, '/' );
|
||||||
}, $values ) ) . ')';
|
}, $values ) ) . ')';
|
||||||
}
|
}
|
||||||
|
@ -319,13 +319,13 @@ class CommentParser {
|
||||||
private function getTimestampParser(
|
private function getTimestampParser(
|
||||||
string $contLangVariant, string $format, ?array $digits, string $localTimezone, array $tzAbbrs
|
string $contLangVariant, string $format, ?array $digits, string $localTimezone, array $tzAbbrs
|
||||||
) : callable {
|
) : callable {
|
||||||
$untransformDigits = function ( string $text ) use ( $digits ) {
|
$untransformDigits = static function ( string $text ) use ( $digits ) {
|
||||||
if ( !$digits ) {
|
if ( !$digits ) {
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
return preg_replace_callback(
|
return preg_replace_callback(
|
||||||
'/[' . implode( '', $digits ) . ']/u',
|
'/[' . implode( '', $digits ) . ']/u',
|
||||||
function ( array $m ) use ( $digits ) {
|
static function ( array $m ) use ( $digits ) {
|
||||||
return (string)array_search( $m[0], $digits );
|
return (string)array_search( $m[0], $digits );
|
||||||
},
|
},
|
||||||
$text
|
$text
|
||||||
|
@ -387,7 +387,7 @@ class CommentParser {
|
||||||
if ( is_array( $match[0] ) ) {
|
if ( is_array( $match[0] ) ) {
|
||||||
// Strip PREG_OFFSET_CAPTURE data
|
// Strip PREG_OFFSET_CAPTURE data
|
||||||
unset( $match['offset'] );
|
unset( $match['offset'] );
|
||||||
$match = array_map( function ( array $tuple ) {
|
$match = array_map( static function ( array $tuple ) {
|
||||||
return $tuple[0];
|
return $tuple[0];
|
||||||
}, $match );
|
}, $match );
|
||||||
}
|
}
|
||||||
|
|
|
@ -317,12 +317,12 @@ class CommentUtils {
|
||||||
$startOffset = $item->getRange()->startOffset;
|
$startOffset = $item->getRange()->startOffset;
|
||||||
$endOffset = $item->getRange()->endOffset;
|
$endOffset = $item->getRange()->endOffset;
|
||||||
|
|
||||||
$isIgnored = function ( $node ) {
|
$isIgnored = static function ( $node ) {
|
||||||
// Ignore empty text nodes
|
// Ignore empty text nodes
|
||||||
return $node->nodeType === XML_TEXT_NODE && CommentUtils::htmlTrim( $node->nodeValue ) === '';
|
return $node->nodeType === XML_TEXT_NODE && CommentUtils::htmlTrim( $node->nodeValue ) === '';
|
||||||
};
|
};
|
||||||
|
|
||||||
$isFirstNonemptyChild = function ( $node ) use ( $isIgnored ) {
|
$isFirstNonemptyChild = static function ( $node ) use ( $isIgnored ) {
|
||||||
while ( ( $node = $node->previousSibling ) ) {
|
while ( ( $node = $node->previousSibling ) ) {
|
||||||
if ( !$isIgnored( $node ) ) {
|
if ( !$isIgnored( $node ) ) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -331,7 +331,7 @@ class CommentUtils {
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
$isLastNonemptyChild = function ( $node ) use ( $isIgnored ) {
|
$isLastNonemptyChild = static function ( $node ) use ( $isIgnored ) {
|
||||||
while ( ( $node = $node->nextSibling ) ) {
|
while ( ( $node = $node->nextSibling ) ) {
|
||||||
if ( !$isIgnored( $node ) ) {
|
if ( !$isIgnored( $node ) ) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -78,7 +78,7 @@ class Data {
|
||||||
// Avoid DateTimeZone::listAbbreviations(), it returns some half-baked list that is different
|
// Avoid DateTimeZone::listAbbreviations(), it returns some half-baked list that is different
|
||||||
// from the timezone data used by everything else in PHP.
|
// from the timezone data used by everything else in PHP.
|
||||||
$timezoneAbbrs = array_values( array_unique(
|
$timezoneAbbrs = array_values( array_unique(
|
||||||
array_map( function ( $transition ) {
|
array_map( static function ( $transition ) {
|
||||||
return $transition['abbr'];
|
return $transition['abbr'];
|
||||||
}, ( new DateTimeZone( $localTimezone ) )->getTransitions() )
|
}, ( new DateTimeZone( $localTimezone ) )->getTransitions() )
|
||||||
) );
|
) );
|
||||||
|
@ -86,7 +86,7 @@ class Data {
|
||||||
$data['timezones'] = [];
|
$data['timezones'] = [];
|
||||||
foreach ( $langConv->getVariants() as $variant ) {
|
foreach ( $langConv->getVariants() as $variant ) {
|
||||||
$data['timezones'][$variant] = array_combine(
|
$data['timezones'][$variant] = array_combine(
|
||||||
array_map( function ( string $tzMsg ) use ( $lang, $langConv, $variant ) {
|
array_map( static function ( string $tzMsg ) use ( $lang, $langConv, $variant ) {
|
||||||
// MWTimestamp::getTimezoneMessage()
|
// MWTimestamp::getTimezoneMessage()
|
||||||
// Parser::pstPass2()
|
// Parser::pstPass2()
|
||||||
// Messages used here: 'timezone-utc' and so on
|
// Messages used here: 'timezone-utc' and so on
|
||||||
|
@ -119,7 +119,7 @@ class Data {
|
||||||
foreach ( $langConv->getVariants() as $variant ) {
|
foreach ( $langConv->getVariants() as $variant ) {
|
||||||
$data['contLangMessages'][$variant] = array_combine(
|
$data['contLangMessages'][$variant] = array_combine(
|
||||||
$messagesKeys,
|
$messagesKeys,
|
||||||
array_map( function ( $key ) use ( $lang, $langConv, $variant ) {
|
array_map( static function ( $key ) use ( $lang, $langConv, $variant ) {
|
||||||
$text = wfMessage( $key )->inLanguage( $lang )->text();
|
$text = wfMessage( $key )->inLanguage( $lang )->text();
|
||||||
return $langConv->translate( $text, $variant );
|
return $langConv->translate( $text, $variant );
|
||||||
}, $messagesKeys )
|
}, $messagesKeys )
|
||||||
|
@ -229,7 +229,7 @@ class Data {
|
||||||
) : array {
|
) : array {
|
||||||
return array_combine(
|
return array_combine(
|
||||||
$messagesKeys,
|
$messagesKeys,
|
||||||
array_map( function ( $key ) {
|
array_map( static function ( $key ) {
|
||||||
return wfMessage( $key )->inContentLanguage()->text();
|
return wfMessage( $key )->inContentLanguage()->text();
|
||||||
}, $messagesKeys )
|
}, $messagesKeys )
|
||||||
);
|
);
|
||||||
|
|
|
@ -66,7 +66,7 @@ class PreferenceHooks implements
|
||||||
|
|
||||||
$preferences['discussiontools-editmode'] = [
|
$preferences['discussiontools-editmode'] = [
|
||||||
'type' => 'api',
|
'type' => 'api',
|
||||||
'validation-callback' => function ( $value ) {
|
'validation-callback' => static function ( $value ) {
|
||||||
return in_array( $value, [ '', 'source', 'visual' ], true );
|
return in_array( $value, [ '', 'source', 'visual' ], true );
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
|
@ -155,7 +155,7 @@ class EventDispatcher {
|
||||||
);
|
);
|
||||||
|
|
||||||
// TODD: Have this return an Iterator instead?
|
// TODD: Have this return an Iterator instead?
|
||||||
$users = array_map( function ( SubscriptionItem $item ) {
|
$users = array_map( static function ( SubscriptionItem $item ) {
|
||||||
return $item->getUserIdentity();
|
return $item->getUserIdentity();
|
||||||
}, $subscriptionItems );
|
}, $subscriptionItems );
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ abstract class ThreadItem implements JsonSerializable {
|
||||||
'type' => $this->type,
|
'type' => $this->type,
|
||||||
'level' => $this->level,
|
'level' => $this->level,
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
'replies' => array_map( function ( ThreadItem $comment ) {
|
'replies' => array_map( static function ( ThreadItem $comment ) {
|
||||||
return $comment->getId();
|
return $comment->getId();
|
||||||
}, $this->replies )
|
}, $this->replies )
|
||||||
];
|
];
|
||||||
|
@ -63,7 +63,7 @@ abstract class ThreadItem implements JsonSerializable {
|
||||||
*/
|
*/
|
||||||
public function getAuthorsBelow() : array {
|
public function getAuthorsBelow() : array {
|
||||||
$authors = [];
|
$authors = [];
|
||||||
$getAuthorSet = function ( ThreadItem $comment ) use ( &$authors, &$getAuthorSet ) {
|
$getAuthorSet = static function ( ThreadItem $comment ) use ( &$authors, &$getAuthorSet ) {
|
||||||
if ( $comment instanceof CommentItem ) {
|
if ( $comment instanceof CommentItem ) {
|
||||||
$author = $comment->getAuthor();
|
$author = $comment->getAuthor();
|
||||||
if ( $author ) {
|
if ( $author ) {
|
||||||
|
|
|
@ -23,7 +23,7 @@ class ThreadItemTest extends IntegrationTestCase {
|
||||||
$node = $doc->createElement( 'div' );
|
$node = $doc->createElement( 'div' );
|
||||||
$range = new ImmutableRange( $node, 0, $node, 0 );
|
$range = new ImmutableRange( $node, 0, $node, 0 );
|
||||||
|
|
||||||
$makeThreadItem = function ( array $arr ) use ( &$makeThreadItem, $range ) : ThreadItem {
|
$makeThreadItem = static function ( array $arr ) use ( &$makeThreadItem, $range ) : ThreadItem {
|
||||||
if ( $arr['type'] === 'comment' ) {
|
if ( $arr['type'] === 'comment' ) {
|
||||||
$item = new CommentItem( 1, $range, [], 'TIMESTAMP', $arr['author'] );
|
$item = new CommentItem( 1, $range, [], 'TIMESTAMP', $arr['author'] );
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -28,12 +28,12 @@ class CommentUtilsTest extends MediaWikiUnitTestCase {
|
||||||
$expected = self::getJson( $expectedPath );
|
$expected = self::getJson( $expectedPath );
|
||||||
|
|
||||||
$actual = [];
|
$actual = [];
|
||||||
CommentUtils::linearWalk( $fragment, function ( $event, $node ) use ( &$actual ) {
|
CommentUtils::linearWalk( $fragment, static function ( $event, $node ) use ( &$actual ) {
|
||||||
$actual[] = "$event {$node->nodeName}({$node->nodeType})";
|
$actual[] = "$event {$node->nodeName}({$node->nodeType})";
|
||||||
} );
|
} );
|
||||||
|
|
||||||
$actualBackwards = [];
|
$actualBackwards = [];
|
||||||
CommentUtils::linearWalkBackwards( $fragment, function ( $event, $node ) use ( &$actualBackwards ) {
|
CommentUtils::linearWalkBackwards( $fragment, static function ( $event, $node ) use ( &$actualBackwards ) {
|
||||||
$actualBackwards[] = "$event {$node->nodeName}({$node->nodeType})";
|
$actualBackwards[] = "$event {$node->nodeName}({$node->nodeType})";
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ class CommentUtilsTest extends MediaWikiUnitTestCase {
|
||||||
|
|
||||||
self::assertEquals( $expected, $actual, $name );
|
self::assertEquals( $expected, $actual, $name );
|
||||||
|
|
||||||
$expectedBackwards = array_map( function ( $a ) {
|
$expectedBackwards = array_map( static function ( $a ) {
|
||||||
return ( substr( $a, 0, 5 ) === 'enter' ? 'leave' : 'enter' ) . substr( $a, 5 );
|
return ( substr( $a, 0, 5 ) === 'enter' ? 'leave' : 'enter' ) . substr( $a, 5 );
|
||||||
}, array_reverse( $expected ) );
|
}, array_reverse( $expected ) );
|
||||||
self::assertEquals( $expectedBackwards, $actualBackwards, $name . ' (backwards)' );
|
self::assertEquals( $expectedBackwards, $actualBackwards, $name . ' (backwards)' );
|
||||||
|
|
Loading…
Reference in a new issue