mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-23 16:06:53 +00:00
Remove now redundant PHPDoc blocks
MediaWiki's PHPCS plugin requires documentation comments on all methods, unless those methods are fully typed (all parameters and return value). It turns out that almost all of our methods are fully typed already. Procedure: 1. Find: \*(\s*\*\s*(@param \??[\w\\]+(\|null)? &?\$\w+|@return \??[\w\\]+(\|null)?)\n)+\s*\*/ Replace with: */ This deletes type annotations, except those not representable as PHP type hints such as union types `a|b` or typed arrays `a[]`, or those with documentation beyond type hints, or those on functions with any other annotations. 2. Find: /\*\*/\n\s* Replace with nothing This deletes the remaining comments on methods that had no prose documentation. 3. Undo all changes that PHPCS complains about (those comments were not redundant) 4. Review the diff carefully, these regexps are imprecise :) Change-Id: Ic82e8b23f2996f44951208dbd9cfb4c8e0738dac
This commit is contained in:
parent
b16dd9dd96
commit
69e8e948b2
|
@ -121,9 +121,6 @@ class ApiDiscussionToolsPageInfo extends ApiBase {
|
|||
|
||||
/**
|
||||
* Get transcluded=from data for a ContentThreadItemSet
|
||||
*
|
||||
* @param ContentThreadItemSet $threadItemSet
|
||||
* @return array
|
||||
*/
|
||||
private static function getTranscludedFrom( ContentThreadItemSet $threadItemSet ): array {
|
||||
$threadItems = $threadItemSet->getThreadItems();
|
||||
|
@ -150,10 +147,6 @@ class ApiDiscussionToolsPageInfo extends ApiBase {
|
|||
|
||||
/**
|
||||
* Get thread items HTML for a ContentThreadItemSet
|
||||
*
|
||||
* @param ContentThreadItemSet $threadItemSet
|
||||
* @param bool $excludeSignatures
|
||||
* @return array
|
||||
*/
|
||||
private static function getThreadItemsHtml( ContentThreadItemSet $threadItemSet, bool $excludeSignatures ): array {
|
||||
// This function assumes that the start of the ranges associated with
|
||||
|
|
|
@ -151,19 +151,9 @@ trait ApiDiscussionToolsTrait {
|
|||
/**
|
||||
* @warning (T323357) - Calling this method writes to stash, so it should be called
|
||||
* only when we are fetching page HTML for editing.
|
||||
*
|
||||
* @param RevisionRecord $revision
|
||||
* @return array
|
||||
*/
|
||||
abstract protected function requestRestbasePageHtml( RevisionRecord $revision ): array;
|
||||
|
||||
/**
|
||||
* @param Title $title
|
||||
* @param string $html
|
||||
* @param int|null $oldid
|
||||
* @param string|null $etag
|
||||
* @return array
|
||||
*/
|
||||
abstract protected function transformHTML(
|
||||
Title $title, string $html, int $oldid = null, string $etag = null
|
||||
): array;
|
||||
|
|
|
@ -41,8 +41,6 @@ class CommentFormatter {
|
|||
* Get a comment parser object for a DOM element
|
||||
*
|
||||
* This method exists so it can mocked in tests.
|
||||
*
|
||||
* @return CommentParser
|
||||
*/
|
||||
protected static function getParser(): CommentParser {
|
||||
return MediaWikiServices::getInstance()->getService( 'DiscussionTools.CommentParser' );
|
||||
|
@ -479,13 +477,6 @@ class CommentFormatter {
|
|||
|
||||
/**
|
||||
* Replace placeholders for topic subscription buttons with the real thing.
|
||||
*
|
||||
* @param string $text
|
||||
* @param IContextSource $contextSource
|
||||
* @param SubscriptionStore $subscriptionStore
|
||||
* @param bool $isMobile
|
||||
* @param bool $useButtons
|
||||
* @return string
|
||||
*/
|
||||
public static function postprocessTopicSubscription(
|
||||
string $text, IContextSource $contextSource,
|
||||
|
@ -613,12 +604,6 @@ class CommentFormatter {
|
|||
|
||||
/**
|
||||
* Replace placeholders for reply links with the real thing.
|
||||
*
|
||||
* @param string $text
|
||||
* @param IContextSource $contextSource
|
||||
* @param bool $isMobile
|
||||
* @param bool $useButtons
|
||||
* @return string
|
||||
*/
|
||||
public static function postprocessReplyTool(
|
||||
string $text, IContextSource $contextSource, bool $isMobile, bool $useButtons
|
||||
|
@ -715,10 +700,6 @@ class CommentFormatter {
|
|||
return $JSON;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ContentHeadingItem $heading
|
||||
* @return array
|
||||
*/
|
||||
private static function getJsonForHeadingMarker( ContentHeadingItem $heading ): array {
|
||||
$JSON = $heading->jsonSerialize();
|
||||
$JSON['text'] = $heading->getText();
|
||||
|
@ -732,11 +713,6 @@ class CommentFormatter {
|
|||
* Signature timestamps don't have seconds-level accuracy, so any
|
||||
* time difference of less than 120 seconds is treated as being
|
||||
* posted "just now".
|
||||
*
|
||||
* @param MWTimestamp $timestamp
|
||||
* @param Language $lang
|
||||
* @param UserIdentity $user
|
||||
* @return string
|
||||
*/
|
||||
public static function getSignatureRelativeTime(
|
||||
MWTimestamp $timestamp, Language $lang, UserIdentity $user
|
||||
|
@ -755,11 +731,6 @@ class CommentFormatter {
|
|||
|
||||
/**
|
||||
* Post-process visual enhancements features (topic containers)
|
||||
*
|
||||
* @param string $text
|
||||
* @param IContextSource $contextSource
|
||||
* @param bool $isMobile
|
||||
* @return string
|
||||
*/
|
||||
public static function postprocessVisualEnhancements(
|
||||
string $text, IContextSource $contextSource, bool $isMobile
|
||||
|
@ -882,10 +853,6 @@ class CommentFormatter {
|
|||
|
||||
/**
|
||||
* Post-process visual enhancements features for page subtitle
|
||||
*
|
||||
* @param ParserOutput $pout
|
||||
* @param IContextSource $contextSource
|
||||
* @return ?string
|
||||
*/
|
||||
public static function postprocessVisualEnhancementsSubtitle(
|
||||
ParserOutput $pout, IContextSource $contextSource
|
||||
|
@ -930,9 +897,6 @@ class CommentFormatter {
|
|||
|
||||
/**
|
||||
* Post-process visual enhancements features for table of contents
|
||||
*
|
||||
* @param ParserOutput $pout
|
||||
* @param IContextSource $contextSource
|
||||
*/
|
||||
public static function postprocessTableOfContents(
|
||||
ParserOutput $pout, IContextSource $contextSource
|
||||
|
@ -967,9 +931,6 @@ class CommentFormatter {
|
|||
|
||||
/**
|
||||
* Check if the talk page had no comments or headings.
|
||||
*
|
||||
* @param ParserOutput $pout
|
||||
* @return bool
|
||||
*/
|
||||
public static function isEmptyTalkPage( ParserOutput $pout ): bool {
|
||||
return $pout->getExtensionData( 'DiscussionTools-isEmptyTalkPage' ) === true;
|
||||
|
@ -977,9 +938,6 @@ class CommentFormatter {
|
|||
|
||||
/**
|
||||
* Append content to an empty talk page
|
||||
*
|
||||
* @param ParserOutput $pout
|
||||
* @param string $content
|
||||
*/
|
||||
public static function appendToEmptyTalkPage( ParserOutput $pout, string $content ): void {
|
||||
$text = $pout->getRawText();
|
||||
|
@ -989,9 +947,6 @@ class CommentFormatter {
|
|||
|
||||
/**
|
||||
* Check if the talk page has content above the first heading, in the lede section.
|
||||
*
|
||||
* @param ParserOutput $pout
|
||||
* @return bool
|
||||
*/
|
||||
public static function hasLedeContent( ParserOutput $pout ): bool {
|
||||
return $pout->getExtensionData( 'DiscussionTools-hasLedeContent' ) === true;
|
||||
|
@ -999,9 +954,6 @@ class CommentFormatter {
|
|||
|
||||
/**
|
||||
* Check if the talk page has comments above the first heading, in the lede section.
|
||||
*
|
||||
* @param ParserOutput $pout
|
||||
* @return bool
|
||||
*/
|
||||
public static function hasCommentsInLedeContent( ParserOutput $pout ): bool {
|
||||
return $pout->getExtensionData( 'DiscussionTools-hasCommentsInLedeContent' ) === true;
|
||||
|
|
|
@ -24,8 +24,6 @@ class CommentModifier {
|
|||
|
||||
/**
|
||||
* Add an attribute to a list item to remove pre-whitespace in Parsoid
|
||||
*
|
||||
* @param Element $listItem
|
||||
*/
|
||||
private static function whitespaceParsoidHack( Element $listItem ): void {
|
||||
// HACK: Setting data-parsoid removes the whitespace after the list item,
|
||||
|
@ -36,9 +34,6 @@ class CommentModifier {
|
|||
|
||||
/**
|
||||
* Remove extra linebreaks from a wikitext string
|
||||
*
|
||||
* @param string $wikitext
|
||||
* @return string
|
||||
*/
|
||||
public static function sanitizeWikitextLinebreaks( string $wikitext ): string {
|
||||
$wikitext = CommentUtils::htmlTrim( $wikitext );
|
||||
|
@ -432,9 +427,6 @@ class CommentModifier {
|
|||
|
||||
/**
|
||||
* Add another list item after the given one.
|
||||
*
|
||||
* @param Element $previousItem
|
||||
* @return Element
|
||||
*/
|
||||
public static function addSiblingListItem( Element $previousItem ): Element {
|
||||
$listItem = $previousItem->ownerDocument->createElement( $previousItem->tagName );
|
||||
|
@ -444,10 +436,6 @@ class CommentModifier {
|
|||
|
||||
/**
|
||||
* Create an element that will convert to the provided wikitext
|
||||
*
|
||||
* @param Document $doc
|
||||
* @param string $wikitext
|
||||
* @return Element
|
||||
*/
|
||||
public static function createWikitextNode( Document $doc, string $wikitext ): Element {
|
||||
$span = $doc->createElement( 'span' );
|
||||
|
@ -460,9 +448,6 @@ class CommentModifier {
|
|||
|
||||
/**
|
||||
* Check if an element created by ::createWikitextNode() starts with list item markup.
|
||||
*
|
||||
* @param Element $node
|
||||
* @return bool
|
||||
*/
|
||||
private static function isWikitextNodeListItem( Element $node ): bool {
|
||||
$dataMw = json_decode( $node->getAttribute( 'data-mw' ) ?? '', true );
|
||||
|
@ -473,9 +458,6 @@ class CommentModifier {
|
|||
|
||||
/**
|
||||
* Append a user signature to the comment in the container.
|
||||
*
|
||||
* @param DocumentFragment $container
|
||||
* @param string $signature
|
||||
*/
|
||||
public static function appendSignature( DocumentFragment $container, string $signature ): void {
|
||||
$doc = $container->ownerDocument;
|
||||
|
@ -513,10 +495,6 @@ class CommentModifier {
|
|||
|
||||
/**
|
||||
* Append a user signature to the comment in the provided wikitext.
|
||||
*
|
||||
* @param string $wikitext
|
||||
* @param string $signature
|
||||
* @return string
|
||||
*/
|
||||
public static function appendSignatureWikitext( string $wikitext, string $signature ): string {
|
||||
$wikitext = CommentUtils::htmlTrim( $wikitext );
|
||||
|
|
|
@ -1287,10 +1287,6 @@ class CommentParser {
|
|||
|
||||
/**
|
||||
* Given a thread item, return an identifier for it that is unique within the page.
|
||||
*
|
||||
* @param ContentThreadItem $threadItem
|
||||
* @param ContentThreadItemSet $previousItems
|
||||
* @return string
|
||||
*/
|
||||
private function computeId( ContentThreadItem $threadItem, ContentThreadItemSet $previousItems ): string {
|
||||
$id = null;
|
||||
|
@ -1355,9 +1351,6 @@ class CommentParser {
|
|||
* revisions where this comment might appear.
|
||||
*
|
||||
* Multiple comments on a page can have the same name; use ID to distinguish them.
|
||||
*
|
||||
* @param ContentThreadItem $threadItem
|
||||
* @return string
|
||||
*/
|
||||
private function computeName( ContentThreadItem $threadItem ): string {
|
||||
$name = null;
|
||||
|
@ -1380,9 +1373,6 @@ class CommentParser {
|
|||
return $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ContentThreadItemSet $result
|
||||
*/
|
||||
private function buildThreads( ContentThreadItemSet $result ): void {
|
||||
$lastHeading = null;
|
||||
$replies = [];
|
||||
|
@ -1428,8 +1418,6 @@ class CommentParser {
|
|||
* Set the IDs and names used to refer to comments and headings.
|
||||
* This has to be a separate pass because we don't have the list of replies before
|
||||
* this point.
|
||||
*
|
||||
* @param ContentThreadItemSet $result
|
||||
*/
|
||||
private function computeIdsAndNames( ContentThreadItemSet $result ): void {
|
||||
foreach ( $result->getThreadItems() as $threadItem ) {
|
||||
|
|
|
@ -145,9 +145,6 @@ class CommentUtils {
|
|||
|
||||
/**
|
||||
* Check whether the node is a comment separator (instead of a part of the comment).
|
||||
*
|
||||
* @param Node $node
|
||||
* @return bool
|
||||
*/
|
||||
public static function isCommentSeparator( Node $node ): bool {
|
||||
if ( !( $node instanceof Element ) ) {
|
||||
|
@ -209,9 +206,6 @@ class CommentUtils {
|
|||
|
||||
/**
|
||||
* Get the index of $child in its parent
|
||||
*
|
||||
* @param Node $child
|
||||
* @return int
|
||||
*/
|
||||
public static function childIndexOf( Node $child ): int {
|
||||
$i = 0;
|
||||
|
@ -223,10 +217,6 @@ class CommentUtils {
|
|||
|
||||
/**
|
||||
* Check whether a Node contains (is an ancestor of) another Node (or is the same node)
|
||||
*
|
||||
* @param Node $ancestor
|
||||
* @param Node $descendant
|
||||
* @return bool
|
||||
*/
|
||||
public static function contains( Node $ancestor, Node $descendant ): bool {
|
||||
// TODO can we use Node->compareDocumentPosition() here maybe?
|
||||
|
@ -356,9 +346,6 @@ class CommentUtils {
|
|||
|
||||
/**
|
||||
* Trim ASCII whitespace, as defined in the HTML spec.
|
||||
*
|
||||
* @param string $str
|
||||
* @return string
|
||||
*/
|
||||
public static function htmlTrim( string $str ): string {
|
||||
// https://infra.spec.whatwg.org/#ascii-whitespace
|
||||
|
@ -369,10 +356,6 @@ class CommentUtils {
|
|||
* Get the indent level of $node, relative to $rootNode.
|
||||
*
|
||||
* The indent level is the number of lists inside of which it is nested.
|
||||
*
|
||||
* @param Node $node
|
||||
* @param Element $rootNode
|
||||
* @return int
|
||||
*/
|
||||
public static function getIndentLevel( Node $node, Element $rootNode ): int {
|
||||
$indent = 0;
|
||||
|
@ -749,11 +732,6 @@ class CommentUtils {
|
|||
* the expected author (that is: there is a signature, and either there's nothing following the
|
||||
* signature, or there's some text within the same paragraph that was detected as part of the same
|
||||
* comment).
|
||||
*
|
||||
* @param ContentThreadItemSet $itemSet
|
||||
* @param string $author
|
||||
* @param Element $rootNode
|
||||
* @return bool
|
||||
*/
|
||||
public static function isSingleCommentSignedBy(
|
||||
ContentThreadItemSet $itemSet,
|
||||
|
|
|
@ -27,9 +27,6 @@ class BetaPreferenceHooks implements GetBetaFeaturePreferencesHook {
|
|||
|
||||
/**
|
||||
* Handler for the GetBetaFeaturePreferences hook, to add and hide user beta preferences as configured
|
||||
*
|
||||
* @param User $user
|
||||
* @param array &$preferences
|
||||
*/
|
||||
public function onGetBetaFeaturePreferences( User $user, array &$preferences ) {
|
||||
if ( $this->config->get( 'DiscussionToolsBeta' ) ) {
|
||||
|
|
|
@ -30,10 +30,6 @@ class EchoHooks implements
|
|||
{
|
||||
/**
|
||||
* Add notification events to Echo
|
||||
*
|
||||
* @param array &$notifications
|
||||
* @param array &$notificationCategories
|
||||
* @param array &$icons
|
||||
*/
|
||||
public function onBeforeCreateEchoEvent(
|
||||
array &$notifications,
|
||||
|
@ -110,10 +106,6 @@ class EchoHooks implements
|
|||
$notifications['mention']['presentation-model'] = EnhancedEchoMentionPresentationModel::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Event $event
|
||||
* @param string &$bundleString
|
||||
*/
|
||||
public function onEchoGetBundleRules( Event $event, string &$bundleString ) {
|
||||
switch ( $event->getType() ) {
|
||||
case 'dt-subscribed-new-comment':
|
||||
|
@ -128,9 +120,6 @@ class EchoHooks implements
|
|||
}
|
||||
|
||||
/**
|
||||
* @param array &$events
|
||||
* @param RevisionRecord $revision
|
||||
* @param bool $isRevert
|
||||
* @throws ResourceLimitExceededException
|
||||
*/
|
||||
public function onEchoGetEventsForRevision( array &$events, RevisionRecord $revision, bool $isRevert ) {
|
||||
|
|
|
@ -484,9 +484,6 @@ class HookUtils {
|
|||
|
||||
/**
|
||||
* Check if the "New section" tab would be shown in a normal skin.
|
||||
*
|
||||
* @param IContextSource $context
|
||||
* @return bool
|
||||
*/
|
||||
public static function shouldShowNewSectionTab( IContextSource $context ): bool {
|
||||
$title = $context->getTitle();
|
||||
|
@ -506,9 +503,6 @@ class HookUtils {
|
|||
|
||||
/**
|
||||
* Check if this page view should open the new topic tool on page load.
|
||||
*
|
||||
* @param IContextSource $context
|
||||
* @return bool
|
||||
*/
|
||||
public static function shouldOpenNewTopicTool( IContextSource $context ): bool {
|
||||
$req = $context->getRequest();
|
||||
|
@ -532,9 +526,6 @@ class HookUtils {
|
|||
|
||||
/**
|
||||
* Check if this page view should display the "empty state" message for empty talk pages.
|
||||
*
|
||||
* @param IContextSource $context
|
||||
* @return bool
|
||||
*/
|
||||
public static function shouldDisplayEmptyState( IContextSource $context ): bool {
|
||||
$req = $context->getRequest();
|
||||
|
@ -576,9 +567,6 @@ class HookUtils {
|
|||
/**
|
||||
* Return whether the corresponding subject page exists, or (if the page is a user talk page,
|
||||
* excluding subpages) whether the user is registered or a valid IP address.
|
||||
*
|
||||
* @param LinkTarget $talkPage
|
||||
* @return bool
|
||||
*/
|
||||
private static function pageSubjectExists( LinkTarget $talkPage ): bool {
|
||||
$services = MediaWikiServices::getInstance();
|
||||
|
@ -602,10 +590,6 @@ class HookUtils {
|
|||
|
||||
/**
|
||||
* Check if we should be adding automatic topic subscriptions for this user on this page.
|
||||
*
|
||||
* @param UserIdentity $user
|
||||
* @param Title $title
|
||||
* @return bool
|
||||
*/
|
||||
public static function shouldAddAutoSubscription( UserIdentity $user, Title $title ): bool {
|
||||
// This duplicates the logic from isFeatureEnabledForOutput(),
|
||||
|
|
|
@ -78,8 +78,6 @@ class TagHooks implements
|
|||
|
||||
/**
|
||||
* Get DT tags from the dttags param in the request, and validate against known tags.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getDiscussionToolsTagsFromRequest(): array {
|
||||
$request = RequestContext::getMain()->getRequest();
|
||||
|
|
|
@ -84,9 +84,6 @@ class ImmutableRange {
|
|||
|
||||
/**
|
||||
* Get the root ancestor of a node
|
||||
*
|
||||
* @param Node $node
|
||||
* @return Node
|
||||
*/
|
||||
private static function getRootNode( Node $node ): Node {
|
||||
while ( $node->parentNode ) {
|
||||
|
@ -97,12 +94,6 @@ class ImmutableRange {
|
|||
return $node;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Node $startNode
|
||||
* @param int $startOffset
|
||||
* @param Node $endNode
|
||||
* @param int $endOffset
|
||||
*/
|
||||
public function __construct(
|
||||
Node $startNode, int $startOffset, Node $endNode, int $endOffset
|
||||
) {
|
||||
|
@ -142,10 +133,6 @@ class ImmutableRange {
|
|||
|
||||
/**
|
||||
* Clone range with a new start position
|
||||
*
|
||||
* @param Node $startNode
|
||||
* @param int $startOffset
|
||||
* @return self
|
||||
*/
|
||||
public function setStart( Node $startNode, int $startOffset ): self {
|
||||
return $this->setStartOrEnd( 'start', $startNode, $startOffset );
|
||||
|
@ -153,10 +140,6 @@ class ImmutableRange {
|
|||
|
||||
/**
|
||||
* Clone range with a new end position
|
||||
*
|
||||
* @param Node $endNode
|
||||
* @param int $endOffset
|
||||
* @return self
|
||||
*/
|
||||
public function setEnd( Node $endNode, int $endOffset ): self {
|
||||
return $this->setStartOrEnd( 'end', $endNode, $endOffset );
|
||||
|
@ -254,8 +237,6 @@ class ImmutableRange {
|
|||
*
|
||||
* Ported from https://github.com/TRowbotham/PHPDOM (MIT)
|
||||
* @see https://dom.spec.whatwg.org/#dom-range-extractcontents
|
||||
*
|
||||
* @return DocumentFragment
|
||||
*/
|
||||
public function extractContents(): DocumentFragment {
|
||||
$fragment = $this->mStartContainer->ownerDocument->createDocumentFragment();
|
||||
|
@ -427,8 +408,6 @@ class ImmutableRange {
|
|||
/**
|
||||
* Ported from https://github.com/TRowbotham/PHPDOM (MIT)
|
||||
* @see https://dom.spec.whatwg.org/#dom-range-clonecontents
|
||||
*
|
||||
* @return DocumentFragment
|
||||
*/
|
||||
public function cloneContents(): DocumentFragment {
|
||||
$ownerDocument = $this->mStartContainer->ownerDocument;
|
||||
|
|
|
@ -38,8 +38,6 @@ class LanguageData {
|
|||
|
||||
/**
|
||||
* Compute data we need to parse discussion threads on pages.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getLocalData(): array {
|
||||
$config = $this->config;
|
||||
|
@ -149,11 +147,6 @@ class LanguageData {
|
|||
/**
|
||||
* Convert a date format string to a different language variant, leaving all special characters
|
||||
* unchanged and applying language conversion to the plain text fragments.
|
||||
*
|
||||
* @param string $format
|
||||
* @param ILanguageConverter $langConv
|
||||
* @param string $variant
|
||||
* @return string
|
||||
*/
|
||||
private function convertDateFormat(
|
||||
string $format,
|
||||
|
|
|
@ -41,8 +41,6 @@ use Wikimedia\Parsoid\Utils\DOMUtils;
|
|||
|
||||
class EventDispatcher {
|
||||
/**
|
||||
* @param RevisionRecord $revRecord
|
||||
* @return ContentThreadItemSet
|
||||
* @throws ResourceLimitExceededException
|
||||
*/
|
||||
private static function getParsedRevision( RevisionRecord $revRecord ): ContentThreadItemSet {
|
||||
|
@ -50,8 +48,6 @@ class EventDispatcher {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param array &$events
|
||||
* @param RevisionRecord $newRevRecord
|
||||
* @throws ResourceLimitExceededException
|
||||
*/
|
||||
public static function generateEventsForRevision( array &$events, RevisionRecord $newRevRecord ): void {
|
||||
|
@ -172,13 +168,6 @@ class EventDispatcher {
|
|||
|
||||
/**
|
||||
* Helper for generateEventsForRevision(), separated out for easier testing.
|
||||
*
|
||||
* @param array &$events
|
||||
* @param ContentThreadItemSet $oldItemSet
|
||||
* @param ContentThreadItemSet $newItemSet
|
||||
* @param RevisionRecord $newRevRecord
|
||||
* @param PageIdentity $title
|
||||
* @param UserIdentity $user
|
||||
*/
|
||||
protected static function generateEventsFromItemSets(
|
||||
array &$events,
|
||||
|
@ -344,8 +333,6 @@ class EventDispatcher {
|
|||
|
||||
/**
|
||||
* Add our change tag for a revision that adds new comments.
|
||||
*
|
||||
* @param RevisionRecord $newRevRecord
|
||||
*/
|
||||
protected static function addCommentChangeTag( RevisionRecord $newRevRecord ): void {
|
||||
// Unclear if DeferredUpdates::addCallableUpdate() is needed,
|
||||
|
@ -358,10 +345,6 @@ class EventDispatcher {
|
|||
/**
|
||||
* Add an automatic subscription to the given item, assuming the user has automatic subscriptions
|
||||
* enabled.
|
||||
*
|
||||
* @param UserIdentity $user
|
||||
* @param Title $title
|
||||
* @param string $itemName
|
||||
*/
|
||||
protected static function addAutoSubscription( UserIdentity $user, Title $title, string $itemName ): void {
|
||||
$dtConfig = MediaWikiServices::getInstance()->getConfigFactory()->makeConfig( 'discussiontools' );
|
||||
|
|
|
@ -23,11 +23,6 @@ class ResourceLoaderData {
|
|||
*
|
||||
* We need all of this data *in content language*. Some of it is already available in JS, but only
|
||||
* in client language, so it's useless for us (e.g. digit transform table, month name messages).
|
||||
*
|
||||
* @param RL\Context $context
|
||||
* @param Config $config
|
||||
* @param string|null $langCode
|
||||
* @return array
|
||||
*/
|
||||
public static function getLocalData(
|
||||
RL\Context $context, Config $config, ?string $langCode = null
|
||||
|
@ -50,11 +45,6 @@ class ResourceLoaderData {
|
|||
|
||||
/**
|
||||
* Return messages in content language, for use in a ResourceLoader module.
|
||||
*
|
||||
* @param RL\Context $context
|
||||
* @param Config $config
|
||||
* @param array $messagesKeys
|
||||
* @return array
|
||||
*/
|
||||
public static function getContentLanguageMessages(
|
||||
RL\Context $context, Config $config, array $messagesKeys = []
|
||||
|
@ -93,10 +83,6 @@ class ResourceLoaderData {
|
|||
|
||||
/**
|
||||
* Return parsed terms-of-use messages, for use in a ResourceLoader module.
|
||||
*
|
||||
* @param MessageLocalizer $context
|
||||
* @param Config $config
|
||||
* @return array
|
||||
*/
|
||||
public static function getTermsOfUseMessagesParsed(
|
||||
MessageLocalizer $context, Config $config
|
||||
|
@ -111,10 +97,6 @@ class ResourceLoaderData {
|
|||
/**
|
||||
* Return information about terms-of-use messages, for use in a ResourceLoader module as
|
||||
* 'versionCallback'. This is to avoid calling the parser from version invalidation code.
|
||||
*
|
||||
* @param MessageLocalizer $context
|
||||
* @param Config $config
|
||||
* @return array
|
||||
*/
|
||||
public static function getTermsOfUseMessagesVersion(
|
||||
MessageLocalizer $context, Config $config
|
||||
|
@ -134,9 +116,6 @@ class ResourceLoaderData {
|
|||
|
||||
/**
|
||||
* Add optional dependencies to a ResourceLoader module definition depending on loaded extensions.
|
||||
*
|
||||
* @param array $info
|
||||
* @return RL\Module
|
||||
*/
|
||||
public static function addOptionalDependencies( array $info ): RL\Module {
|
||||
$extensionRegistry = ExtensionRegistry::getInstance();
|
||||
|
@ -154,9 +133,6 @@ class ResourceLoaderData {
|
|||
/**
|
||||
* Generate the test module that includes all of the test data, based on the JSON files defining
|
||||
* test cases.
|
||||
*
|
||||
* @param array $info
|
||||
* @return RL\Module
|
||||
*/
|
||||
public static function makeTestModule( array $info ): RL\Module {
|
||||
// Some tests rely on PHP-only features or are too large for the Karma test runner.
|
||||
|
|
|
@ -114,10 +114,6 @@ class SpecialFindComment extends FormSpecialPage {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $threadItems
|
||||
* @param string $msgKey
|
||||
*/
|
||||
private function displayItems( array $threadItems, string $msgKey ) {
|
||||
$out = $this->getOutput();
|
||||
|
||||
|
|
|
@ -41,31 +41,20 @@ class SubscriptionItem {
|
|||
$this->notifiedTimestamp = $notifiedTimestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return UserIdentity
|
||||
*/
|
||||
public function getUserIdentity(): UserIdentity {
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getItemName(): string {
|
||||
return $this->itemName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return LinkTarget
|
||||
*/
|
||||
public function getLinkTarget(): LinkTarget {
|
||||
return $this->linkTarget;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the creation timestamp of this entry.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCreatedTimestamp(): ?string {
|
||||
return $this->createdTimestamp;
|
||||
|
@ -73,8 +62,6 @@ class SubscriptionItem {
|
|||
|
||||
/**
|
||||
* Get the notification timestamp of this entry.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getNotificationTimestamp(): ?string {
|
||||
return $this->notifiedTimestamp;
|
||||
|
@ -91,8 +78,6 @@ class SubscriptionItem {
|
|||
|
||||
/**
|
||||
* Check if the notification is muted
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isMuted(): bool {
|
||||
return $this->state === SubscriptionStore::STATE_UNSUBSCRIBED;
|
||||
|
|
|
@ -172,12 +172,6 @@ class SubscriptionStore {
|
|||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param UserIdentity $user
|
||||
* @param LinkTarget $target
|
||||
* @param stdClass $row
|
||||
* @return SubscriptionItem
|
||||
*/
|
||||
private function getSubscriptionItemFromRow(
|
||||
UserIdentity $user,
|
||||
LinkTarget $target,
|
||||
|
@ -193,13 +187,6 @@ class SubscriptionStore {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param UserIdentity $user
|
||||
* @param LinkTarget $target
|
||||
* @param string $itemName
|
||||
* @param int $state
|
||||
* @return bool
|
||||
*/
|
||||
public function addSubscriptionForUser(
|
||||
UserIdentity $user,
|
||||
LinkTarget $target,
|
||||
|
@ -242,11 +229,6 @@ class SubscriptionStore {
|
|||
return (bool)$dbw->affectedRows();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param UserIdentity $user
|
||||
* @param string $itemName
|
||||
* @return bool
|
||||
*/
|
||||
public function removeSubscriptionForUser(
|
||||
UserIdentity $user,
|
||||
string $itemName
|
||||
|
@ -271,12 +253,6 @@ class SubscriptionStore {
|
|||
return (bool)$dbw->affectedRows();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param UserIdentity $user
|
||||
* @param LinkTarget $target
|
||||
* @param string $itemName
|
||||
* @return bool
|
||||
*/
|
||||
public function addAutoSubscriptionForUser(
|
||||
UserIdentity $user,
|
||||
LinkTarget $target,
|
||||
|
@ -340,10 +316,6 @@ class SubscriptionStore {
|
|||
* This field could be used in future to cleanup notifications
|
||||
* that are no longer needed (e.g. because the conversation has
|
||||
* been archived), so should be set for muted notifications too.
|
||||
*
|
||||
* @param UserIdentity|null $user
|
||||
* @param string $itemName
|
||||
* @return bool
|
||||
*/
|
||||
public function updateSubscriptionNotifiedTimestamp(
|
||||
?UserIdentity $user,
|
||||
|
|
|
@ -55,9 +55,6 @@ class ContentHeadingItem extends ContentThreadItem implements HeadingItem {
|
|||
return $title;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isUneditableSection(): bool {
|
||||
return $this->uneditableSection;
|
||||
}
|
||||
|
@ -84,16 +81,10 @@ class ContentHeadingItem extends ContentThreadItem implements HeadingItem {
|
|||
$this->headingLevel = $headingLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isPlaceholderHeading(): bool {
|
||||
return $this->placeholderHeading;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $placeholderHeading
|
||||
*/
|
||||
public function setPlaceholderHeading( bool $placeholderHeading ): void {
|
||||
$this->placeholderHeading = $placeholderHeading;
|
||||
}
|
||||
|
|
|
@ -123,8 +123,6 @@ abstract class ContentThreadItem implements JsonSerializable, ThreadItem {
|
|||
|
||||
/**
|
||||
* Get the number of comment items in the tree below this thread item.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getCommentCount(): int {
|
||||
$this->calculateThreadSummary();
|
||||
|
@ -133,8 +131,6 @@ abstract class ContentThreadItem implements JsonSerializable, ThreadItem {
|
|||
|
||||
/**
|
||||
* Get the latest reply in the tree below this thread item, null if there are no replies
|
||||
*
|
||||
* @return ContentCommentItem|null
|
||||
*/
|
||||
public function getLatestReply(): ?ContentCommentItem {
|
||||
$this->calculateThreadSummary();
|
||||
|
@ -143,8 +139,6 @@ abstract class ContentThreadItem implements JsonSerializable, ThreadItem {
|
|||
|
||||
/**
|
||||
* Get the oldest reply in the tree below this thread item, null if there are no replies
|
||||
*
|
||||
* @return ContentCommentItem|null
|
||||
*/
|
||||
public function getOldestReply(): ?ContentCommentItem {
|
||||
$this->calculateThreadSummary();
|
||||
|
@ -285,9 +279,6 @@ abstract class ContentThreadItem implements JsonSerializable, ThreadItem {
|
|||
$this->level = $level;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ContentThreadItem $parent
|
||||
*/
|
||||
public function setParent( ContentThreadItem $parent ): void {
|
||||
$this->parent = $parent;
|
||||
}
|
||||
|
@ -320,9 +311,6 @@ abstract class ContentThreadItem implements JsonSerializable, ThreadItem {
|
|||
$this->id = $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $warning
|
||||
*/
|
||||
public function addWarning( string $warning ): void {
|
||||
$this->warnings[] = $warning;
|
||||
}
|
||||
|
|
|
@ -45,16 +45,10 @@ class DatabaseThreadItem implements JsonSerializable, ThreadItem {
|
|||
$this->level = $level;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ProperPageIdentity
|
||||
*/
|
||||
public function getPage(): ProperPageIdentity {
|
||||
return $this->page;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return RevisionRecord
|
||||
*/
|
||||
public function getRevision(): RevisionRecord {
|
||||
return $this->rev;
|
||||
}
|
||||
|
|
|
@ -8,8 +8,5 @@ interface HeadingItem extends ThreadItem {
|
|||
*/
|
||||
public function getHeadingLevel(): int;
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isPlaceholderHeading(): bool;
|
||||
}
|
||||
|
|
|
@ -26,8 +26,6 @@ trait HeadingItemTrait {
|
|||
|
||||
/**
|
||||
* Check whether this heading can be used for topic subscriptions.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isSubscribable(): bool {
|
||||
return (
|
||||
|
|
|
@ -26,9 +26,6 @@ class ThreadItemFormatter {
|
|||
|
||||
/**
|
||||
* Make a link to a thread item on the page.
|
||||
*
|
||||
* @param DatabaseThreadItem $item
|
||||
* @return string
|
||||
*/
|
||||
public function makeLink( DatabaseThreadItem $item ): string {
|
||||
$title = TitleValue::newFromPage( $item->getPage() )->createFragmentTarget( $item->getId() );
|
||||
|
@ -46,10 +43,6 @@ class ThreadItemFormatter {
|
|||
|
||||
/**
|
||||
* Make a link to a thread item on the page, with additional information (used on special pages).
|
||||
*
|
||||
* @param DatabaseThreadItem $item
|
||||
* @param MessageLocalizer $context
|
||||
* @return string
|
||||
*/
|
||||
public function formatLine( DatabaseThreadItem $item, MessageLocalizer $context ): string {
|
||||
$contents = [];
|
||||
|
|
|
@ -66,8 +66,6 @@ class ThreadItemStore {
|
|||
/**
|
||||
* Returns true if the tables necessary for this feature haven't been created yet,
|
||||
* to allow failing softly in that case.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isDisabled(): bool {
|
||||
return !$this->config->get( 'DiscussionToolsEnablePermalinksBackend' );
|
||||
|
@ -288,10 +286,6 @@ class ThreadItemStore {
|
|||
return $threadItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SelectQueryBuilder $queryBuilder
|
||||
* @return IResultWrapper
|
||||
*/
|
||||
private function fetchItemsResultSet( SelectQueryBuilder $queryBuilder ): IResultWrapper {
|
||||
$queryBuilder
|
||||
->fields( [
|
||||
|
@ -352,12 +346,6 @@ class ThreadItemStore {
|
|||
return $revs;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param stdClass $row
|
||||
* @param DatabaseThreadItemSet|null $set
|
||||
* @param array $revs
|
||||
* @return DatabaseThreadItem|null
|
||||
*/
|
||||
private function getThreadItemFromRow(
|
||||
stdClass $row, ?DatabaseThreadItemSet $set, array $revs
|
||||
): ?DatabaseThreadItem {
|
||||
|
@ -427,9 +415,6 @@ class ThreadItemStore {
|
|||
/**
|
||||
* Find the thread item set for the given revision, assuming that it is the current revision of
|
||||
* its page.
|
||||
*
|
||||
* @param int $revId
|
||||
* @return DatabaseThreadItemSet
|
||||
*/
|
||||
public function findThreadItemsInCurrentRevision( int $revId ): DatabaseThreadItemSet {
|
||||
if ( $this->isDisabled() ) {
|
||||
|
@ -456,9 +441,6 @@ class ThreadItemStore {
|
|||
return $set;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SelectQueryBuilder
|
||||
*/
|
||||
private function getIdsNamesBuilder(): SelectQueryBuilder {
|
||||
$dbr = $this->dbProvider->getReplicaDatabase();
|
||||
|
||||
|
|
|
@ -120,10 +120,6 @@ class PersistRevisionThreadItems extends Maintenance {
|
|||
$this->process( $qb, $index );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SelectQueryBuilder $qb
|
||||
* @param array $index
|
||||
*/
|
||||
private function process( SelectQueryBuilder $qb, array $index ): void {
|
||||
$start = microtime( true );
|
||||
|
||||
|
|
|
@ -27,11 +27,6 @@ class CommentParserTest extends IntegrationTestCase {
|
|||
* Get the offset path from ancestor to offset in descendant
|
||||
*
|
||||
* Convert Unicode codepoint offsets to UTF-16 code unit offsets.
|
||||
*
|
||||
* @param Element $ancestor
|
||||
* @param Node $node
|
||||
* @param int $nodeOffset
|
||||
* @return string
|
||||
*/
|
||||
private static function getOffsetPath(
|
||||
Element $ancestor, Node $node, int $nodeOffset
|
||||
|
|
|
@ -12,9 +12,6 @@ class MockCommentFormatter extends CommentFormatter {
|
|||
|
||||
public static CommentParser $parser;
|
||||
|
||||
/**
|
||||
* @return CommentParser
|
||||
*/
|
||||
protected static function getParser(): CommentParser {
|
||||
return static::$parser;
|
||||
}
|
||||
|
|
|
@ -17,13 +17,6 @@ class MockEventDispatcher extends EventDispatcher {
|
|||
* Note that we can't use TestingAccessWrapper instead of this, because it doesn't support passing
|
||||
* arguments by reference (causes exceptions like "PHPUnit\Framework\Error\Warning: Parameter 1 to
|
||||
* ... expected to be a reference, value given").
|
||||
*
|
||||
* @param array &$events
|
||||
* @param ContentThreadItemSet $oldItemSet
|
||||
* @param ContentThreadItemSet $newItemSet
|
||||
* @param RevisionRecord $newRevRecord
|
||||
* @param PageIdentity $title
|
||||
* @param UserIdentity $user
|
||||
*/
|
||||
public static function generateEventsFromItemSets(
|
||||
array &$events,
|
||||
|
@ -45,18 +38,12 @@ class MockEventDispatcher extends EventDispatcher {
|
|||
|
||||
/**
|
||||
* No-op for testing
|
||||
*
|
||||
* @param RevisionRecord $newRevRecord
|
||||
*/
|
||||
public static function addCommentChangeTag( RevisionRecord $newRevRecord ): void {
|
||||
}
|
||||
|
||||
/**
|
||||
* No-op for testing
|
||||
*
|
||||
* @param UserIdentity $user
|
||||
* @param Title $title
|
||||
* @param string $itemName
|
||||
*/
|
||||
protected static function addAutoSubscription( UserIdentity $user, Title $title, string $itemName ): void {
|
||||
}
|
||||
|
|
|
@ -8,16 +8,10 @@ class MockLanguageData extends LanguageData {
|
|||
|
||||
private array $data;
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct( array $data ) {
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getLocalData(): array {
|
||||
return $this->data;
|
||||
}
|
||||
|
|
|
@ -24,9 +24,6 @@ trait TestUtils {
|
|||
|
||||
/**
|
||||
* Create a Document from a string.
|
||||
*
|
||||
* @param string $html
|
||||
* @return Document
|
||||
*/
|
||||
protected static function createDocument( string $html ): Document {
|
||||
return DOMUtils::parseHTML( $html );
|
||||
|
@ -34,9 +31,6 @@ trait TestUtils {
|
|||
|
||||
/**
|
||||
* Return the node that is expected to contain thread items.
|
||||
*
|
||||
* @param Document $doc
|
||||
* @return Element
|
||||
*/
|
||||
protected static function getThreadContainer( Document $doc ): Element {
|
||||
// In tests created from Parsoid output, comments are contained directly in <body>.
|
||||
|
@ -48,9 +42,6 @@ trait TestUtils {
|
|||
|
||||
/**
|
||||
* Get text from path
|
||||
*
|
||||
* @param string $relativePath
|
||||
* @return string
|
||||
*/
|
||||
protected static function getText( string $relativePath ): string {
|
||||
return file_get_contents( __DIR__ . '/../' . $relativePath );
|
||||
|
@ -58,9 +49,6 @@ trait TestUtils {
|
|||
|
||||
/**
|
||||
* Write text to path
|
||||
*
|
||||
* @param string $relativePath
|
||||
* @param string $text
|
||||
*/
|
||||
protected static function overwriteTextFile( string $relativePath, string $text ): void {
|
||||
file_put_contents( __DIR__ . '/../' . $relativePath, $text );
|
||||
|
@ -83,9 +71,6 @@ trait TestUtils {
|
|||
|
||||
/**
|
||||
* Write JSON to path
|
||||
*
|
||||
* @param string $relativePath
|
||||
* @param array $data
|
||||
*/
|
||||
protected static function overwriteJsonFile( string $relativePath, array $data ): void {
|
||||
$json = FormatJson::encode( $data, "\t", FormatJson::ALL_OK );
|
||||
|
@ -94,9 +79,6 @@ trait TestUtils {
|
|||
|
||||
/**
|
||||
* Get HTML from path
|
||||
*
|
||||
* @param string $relativePath
|
||||
* @return string
|
||||
*/
|
||||
protected static function getHtml( string $relativePath ): string {
|
||||
return file_get_contents( __DIR__ . '/../' . $relativePath );
|
||||
|
@ -104,10 +86,6 @@ trait TestUtils {
|
|||
|
||||
/**
|
||||
* Write HTML to path
|
||||
*
|
||||
* @param string $relPath
|
||||
* @param Element $container
|
||||
* @param string $origRelPath
|
||||
*/
|
||||
protected static function overwriteHtmlFile( string $relPath, Element $container, string $origRelPath ): void {
|
||||
// Do not use $doc->saveHtml(), it outputs an awful soup of HTML entities for documents with
|
||||
|
|
Loading…
Reference in a new issue