mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-24 08:23:52 +00:00
Merge "Various code quality tweaks"
This commit is contained in:
commit
4713986eb7
|
@ -23,5 +23,9 @@
|
|||
],
|
||||
"phan": "phan -d . --long-progress-bar",
|
||||
"phpcs": "phpcs -sp --cache"
|
||||
},
|
||||
"require": {
|
||||
"ext-json": "*",
|
||||
"ext-dom": "*"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1031,15 +1031,15 @@ class CommentParser {
|
|||
* CommentItem( { level: 1, range: (p: B), replies: [
|
||||
* CommentItem( { level: 2, range: (li: C, li: C), replies: [
|
||||
* CommentItem( { level: 3, range: (li: D), replies: [
|
||||
* CommentItem( { level: 4, range: (li: E), replies: [] },
|
||||
* CommentItem( { level: 4, range: (li: F), replies: [] },
|
||||
* ] },
|
||||
* ] },
|
||||
* CommentItem( { level: 2, range: (li: G), replies: [] },
|
||||
* ] },
|
||||
* CommentItem( { level: 4, range: (li: E), replies: [] } ),
|
||||
* CommentItem( { level: 4, range: (li: F), replies: [] } ),
|
||||
* ] } ),
|
||||
* ] } ),
|
||||
* CommentItem( { level: 2, range: (li: G), replies: [] } ),
|
||||
* ] } ),
|
||||
* CommentItem( { level: 1, range: (p: H), replies: [
|
||||
* CommentItem( { level: 2, range: (li: I), replies: [] },
|
||||
* ] },
|
||||
* CommentItem( { level: 2, range: (li: I), replies: [] } ),
|
||||
* ] } ),
|
||||
* ] } )
|
||||
* ]
|
||||
*
|
||||
|
|
|
@ -20,7 +20,6 @@ use Wikimedia\Parsoid\DOM\Text;
|
|||
* setStart and setEnd are still available but return a cloned range.
|
||||
*/
|
||||
class ImmutableRange {
|
||||
private $mCollapsed;
|
||||
private $mCommonAncestorContainer;
|
||||
private $mEndContainer;
|
||||
private $mEndOffset;
|
||||
|
@ -544,6 +543,9 @@ class ImmutableRange {
|
|||
|
||||
case 'after':
|
||||
return 1;
|
||||
|
||||
default:
|
||||
throw new Error();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -118,6 +118,7 @@ class SubscribedNewCommentPresentationModel extends EchoEventPresentationModel {
|
|||
if ( !$this->isBundled() ) {
|
||||
return new RawMessage( '$1', [ Message::plaintextParam( $this->getContentSnippet() ) ] );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -720,7 +720,6 @@ Parser.prototype.nextInterestingLeafNode = function ( node ) {
|
|||
* CommentItem( { level: 2, range: (li: I) } )
|
||||
* ]
|
||||
*
|
||||
* @param {HTMLElement} rootNode
|
||||
* @return {ThreadItem[]} Thread items
|
||||
*/
|
||||
Parser.prototype.getThreadItems = function () {
|
||||
|
@ -976,15 +975,15 @@ Parser.prototype.buildThreadItems = function () {
|
|||
* CommentItem( { level: 1, range: (p: B), replies: [
|
||||
* CommentItem( { level: 2, range: (li: C, li: C), replies: [
|
||||
* CommentItem( { level: 3, range: (li: D), replies: [
|
||||
* CommentItem( { level: 4, range: (li: E), replies: [] },
|
||||
* CommentItem( { level: 4, range: (li: F), replies: [] },
|
||||
* ] },
|
||||
* ] },
|
||||
* CommentItem( { level: 2, range: (li: G), replies: [] },
|
||||
* ] },
|
||||
* CommentItem( { level: 4, range: (li: E), replies: [] } ),
|
||||
* CommentItem( { level: 4, range: (li: F), replies: [] } ),
|
||||
* ] } ),
|
||||
* ] } ),
|
||||
* CommentItem( { level: 2, range: (li: G), replies: [] } ),
|
||||
* ] } ),
|
||||
* CommentItem( { level: 1, range: (p: H), replies: [
|
||||
* CommentItem( { level: 2, range: (li: I), replies: [] },
|
||||
* ] },
|
||||
* CommentItem( { level: 2, range: (li: I), replies: [] } ),
|
||||
* ] } ),
|
||||
* ] } )
|
||||
* ]
|
||||
*
|
||||
|
|
|
@ -39,11 +39,9 @@ class CommentModifierTest extends IntegrationTestCase {
|
|||
$parser = self::createParser( $container, $title, $data );
|
||||
$comments = $parser->getCommentItems();
|
||||
|
||||
$nodes = [];
|
||||
foreach ( $comments as $comment ) {
|
||||
$node = CommentModifier::addListItem( $comment, $replyIndentation );
|
||||
$node->textContent = 'Reply to ' . $comment->getId();
|
||||
$nodes[] = $node;
|
||||
}
|
||||
|
||||
$expectedDoc = self::createDocument( $expected );
|
||||
|
|
|
@ -15,6 +15,7 @@ use Title;
|
|||
use Wikimedia\Parsoid\DOM\Element;
|
||||
use Wikimedia\Parsoid\DOM\Node;
|
||||
use Wikimedia\Parsoid\Utils\DOMCompat;
|
||||
use Wikimedia\Parsoid\Utils\DOMUtils;
|
||||
use Wikimedia\TestingAccessWrapper;
|
||||
|
||||
/**
|
||||
|
@ -55,7 +56,7 @@ class CommentParserTest extends IntegrationTestCase {
|
|||
return implode( '/', $path );
|
||||
}
|
||||
|
||||
private static function serializeComments( ThreadItem &$threadItem, Element $root ): stdClass {
|
||||
private static function serializeComments( ThreadItem $threadItem, Element $root ): stdClass {
|
||||
$serialized = new stdClass();
|
||||
|
||||
if ( $threadItem instanceof HeadingItem ) {
|
||||
|
@ -113,7 +114,10 @@ class CommentParserTest extends IntegrationTestCase {
|
|||
string $format, string $expected, string $message
|
||||
): void {
|
||||
$parser = TestingAccessWrapper::newFromObject(
|
||||
CommentParser::newFromGlobalState( new Element( 'div' ), Title::newFromText( 'Dummy' ) )
|
||||
CommentParser::newFromGlobalState(
|
||||
DOMCompat::getBody( DOMUtils::parseHTML( '' ) ),
|
||||
Title::newFromText( 'Dummy' )
|
||||
)
|
||||
);
|
||||
|
||||
// HACK: Fix differences between JS & PHP regexes
|
||||
|
@ -138,7 +142,10 @@ class CommentParserTest extends IntegrationTestCase {
|
|||
string $format, array $data, string $expected, string $message
|
||||
): void {
|
||||
$parser = TestingAccessWrapper::newFromObject(
|
||||
CommentParser::newFromGlobalState( new Element( 'div' ), Title::newFromText( 'Dummy' ) )
|
||||
CommentParser::newFromGlobalState(
|
||||
DOMCompat::getBody( DOMUtils::parseHTML( '' ) ),
|
||||
Title::newFromText( 'Dummy' )
|
||||
)
|
||||
);
|
||||
|
||||
$expected = new DateTimeImmutable( $expected );
|
||||
|
@ -160,7 +167,10 @@ class CommentParserTest extends IntegrationTestCase {
|
|||
string $timezone, array $timezoneAbbrs, string $message
|
||||
): void {
|
||||
$parser = TestingAccessWrapper::newFromObject(
|
||||
CommentParser::newFromGlobalState( new Element( 'div' ), Title::newFromText( 'Dummy' ) )
|
||||
CommentParser::newFromGlobalState(
|
||||
DOMCompat::getBody( DOMUtils::parseHTML( '' ) ),
|
||||
Title::newFromText( 'Dummy' )
|
||||
)
|
||||
);
|
||||
|
||||
$regexp = $parser->getTimestampRegexp( 'en', $format, '\\d', $timezoneAbbrs );
|
||||
|
|
Loading…
Reference in a new issue