From: Siebrand Mazeland Date: Tue, 19 Nov 2013 21:26:16 +0000 (+0100) Subject: Update formatting X-Git-Tag: 1.31.0-rc.0~18010^2~2 X-Git-Url: http://git.cyclocoop.org/%22.%28%24lien.?a=commitdiff_plain;h=3bbe32d6e90e56abcf15d4ea4e1164e290af83d5;p=lhc%2Fweb%2Fwiklou.git Update formatting Change-Id: Ieee4747cf2401d0d89a497a7637d32348192f481 --- diff --git a/includes/content/AbstractContent.php b/includes/content/AbstractContent.php index 137efb8a49..42d39feedd 100644 --- a/includes/content/AbstractContent.php +++ b/includes/content/AbstractContent.php @@ -273,6 +273,7 @@ abstract class AbstractContent implements Content { break; } } + return $titles; } @@ -293,6 +294,7 @@ abstract class AbstractContent implements Content { */ public function getUltimateRedirectTarget() { $titles = $this->getRedirectChain(); + return $titles ? array_pop( $titles ) : null; } @@ -394,8 +396,8 @@ abstract class AbstractContent implements Content { * database after deletion. */ public function getDeletionUpdates( WikiPage $page, - ParserOutput $parserOutput = null ) - { + ParserOutput $parserOutput = null + ) { return array( new LinksDeletionUpdate( $page ), ); @@ -422,8 +424,8 @@ abstract class AbstractContent implements Content { * This base implementation calls the hook ConvertContent to enable custom conversions. * Subclasses may override this to implement conversion for "their" content model. * - * @param string $toModel the desired content model, use the CONTENT_MODEL_XXX flags. - * @param string $lossy flag, set to "lossy" to allow lossy conversion. If lossy conversion is + * @param string $toModel the desired content model, use the CONTENT_MODEL_XXX flags. + * @param string $lossy flag, set to "lossy" to allow lossy conversion. If lossy conversion is * not allowed, full round-trip conversion is expected to work without losing information. * * @return Content|bool A content object with the content model $toModel, or false if @@ -439,6 +441,7 @@ abstract class AbstractContent implements Content { $result = false; wfRunHooks( 'ConvertContent', array( $this, $toModel, $lossy, &$result ) ); + return $result; } } diff --git a/includes/content/Content.php b/includes/content/Content.php index 5a90e09247..f43e88f60a 100644 --- a/includes/content/Content.php +++ b/includes/content/Content.php @@ -267,6 +267,7 @@ interface Content { public function getParserOutput( Title $title, $revId = null, ParserOptions $options = null, $generateHtml = true ); + // TODO: make RenderOutput and RenderOptions base classes /** @@ -446,9 +447,9 @@ interface Content { * @since 1.21 * * @param WikiPage $page The page to be saved. - * @param int $flags bitfield for use with EDIT_XXX constants, see WikiPage::doEditContent() - * @param int $baseRevId the ID of the current revision - * @param User $user + * @param int $flags bitfield for use with EDIT_XXX constants, see WikiPage::doEditContent() + * @param int $baseRevId the ID of the current revision + * @param User $user * * @return Status A status object indicating whether the content was successfully prepared for saving. * If the returned status indicates an error, a rollback will be performed and the @@ -491,17 +492,16 @@ interface Content { * Converts this content object into another content object with the given content model, * if that is possible. * - * @param string $toModel the desired content model, use the CONTENT_MODEL_XXX flags. - * @param string $lossy flag, set to "lossy" to allow lossy conversion. If lossy conversion is + * @param string $toModel the desired content model, use the CONTENT_MODEL_XXX flags. + * @param string $lossy flag, set to "lossy" to allow lossy conversion. If lossy conversion is * not allowed, full round-trip conversion is expected to work without losing information. * * @return Content|bool A content object with the content model $toModel, or false if * that conversion is not supported. */ public function convert( $toModel, $lossy = '' ); - - // TODO: ImagePage and CategoryPage interfere with per-content action handlers - // TODO: nice&sane integration of GeSHi syntax highlighting + // @todo ImagePage and CategoryPage interfere with per-content action handlers + // @todo nice&sane integration of GeSHi syntax highlighting // [11:59] Hooks are ugly; make CodeHighlighter interface and a // config to set the class which handles syntax highlighting // [12:00] And default it to a DummyHighlighter diff --git a/includes/content/ContentHandler.php b/includes/content/ContentHandler.php index ede43063b7..c34ac31031 100644 --- a/includes/content/ContentHandler.php +++ b/includes/content/ContentHandler.php @@ -145,8 +145,8 @@ abstract class ContentHandler { * not be unserialized using $format. */ public static function makeContent( $text, Title $title = null, - $modelId = null, $format = null ) - { + $modelId = null, $format = null + ) { if ( is_null( $modelId ) ) { if ( is_null( $title ) ) { throw new MWException( "Must provide a Title object or a content model ID." ); @@ -156,6 +156,7 @@ abstract class ContentHandler { } $handler = ContentHandler::getForModelID( $modelId ); + return $handler->unserializeContent( $text, $format ); } @@ -259,6 +260,7 @@ abstract class ContentHandler { */ public static function getForTitle( Title $title ) { $modelId = $title->getContentModel(); + return ContentHandler::getForModelID( $modelId ); } @@ -273,6 +275,7 @@ abstract class ContentHandler { */ public static function getForContent( Content $content ) { $modelId = $content->getModel(); + return ContentHandler::getForModelID( $modelId ); } @@ -335,9 +338,10 @@ abstract class ContentHandler { } wfDebugLog( 'ContentHandler', 'Created handler for ' . $modelId - . ': ' . get_class( $handler ) ); + . ': ' . get_class( $handler ) ); ContentHandler::$handlers[$modelId] = $handler; + return ContentHandler::$handlers[$modelId]; } @@ -380,6 +384,7 @@ abstract class ContentHandler { } $formats = array_unique( $formats ); + return $formats; } @@ -607,7 +612,7 @@ abstract class ContentHandler { * * @since 1.21 * - * @param Title $title the page to determine the language for. + * @param Title $title the page to determine the language for. * @param Content|null $content the page's content, if you have it handy, to avoid reloading it. * * @return Language the page's language @@ -623,6 +628,7 @@ abstract class ContentHandler { } wfRunHooks( 'PageContentLanguage', array( $title, &$pageLang, $wgLang ) ); + return wfGetLangObj( $pageLang ); } @@ -641,7 +647,7 @@ abstract class ContentHandler { * * @since 1.21 * - * @param Title $title the page to determine the language for. + * @param Title $title the page to determine the language for. * @param Content|null $content the page's content, if you have it handy, to avoid reloading it. * * @return Language the page's language for viewing @@ -735,15 +741,15 @@ abstract class ContentHandler { if ( is_object( $rt ) ) { if ( !is_object( $ot ) || !$rt->equals( $ot ) - || $ot->getFragment() != $rt->getFragment() ) - { + || $ot->getFragment() != $rt->getFragment() + ) { $truncatedtext = $newContent->getTextForSummary( 250 - - strlen( wfMessage( 'autoredircomment' )->inContentLanguage()->text() ) - - strlen( $rt->getFullText() ) ); + - strlen( wfMessage( 'autoredircomment' )->inContentLanguage()->text() ) + - strlen( $rt->getFullText() ) ); return wfMessage( 'autoredircomment', $rt->getFullText() ) - ->rawParams( $truncatedtext )->inContentLanguage()->text(); + ->rawParams( $truncatedtext )->inContentLanguage()->text(); } } @@ -756,7 +762,7 @@ abstract class ContentHandler { 200 - strlen( wfMessage( 'autosumm-new' )->inContentLanguage()->text() ) ); return wfMessage( 'autosumm-new' )->rawParams( $truncatedtext ) - ->inContentLanguage()->text(); + ->inContentLanguage()->text(); } // Blanking auto-summaries @@ -764,15 +770,15 @@ abstract class ContentHandler { return wfMessage( 'autosumm-blank' )->inContentLanguage()->text(); } elseif ( !empty( $oldContent ) && $oldContent->getSize() > 10 * $newContent->getSize() - && $newContent->getSize() < 500 ) - { + && $newContent->getSize() < 500 + ) { // Removing more than 90% of the article $truncatedtext = $newContent->getTextForSummary( 200 - strlen( wfMessage( 'autosumm-replace' )->inContentLanguage()->text() ) ); return wfMessage( 'autosumm-replace' )->rawParams( $truncatedtext ) - ->inContentLanguage()->text(); + ->inContentLanguage()->text(); } // If we reach this point, there's no applicable auto-summary for our @@ -1004,11 +1010,11 @@ abstract class ContentHandler { * Logs a deprecation warning, visible if $wgDevelopmentWarnings, but only if * self::$enableDeprecationWarnings is set to true. * - * @param string $func The name of the deprecated function - * @param string $version The version since the method is deprecated. Usually 1.21 - * for ContentHandler related stuff. - * @param string|bool $component: Component to which the function belongs. - * If false, it is assumed the function is in MediaWiki core. + * @param string $func The name of the deprecated function + * @param string $version The version since the method is deprecated. Usually 1.21 + * for ContentHandler related stuff. + * @param string|bool $component : Component to which the function belongs. + * If false, it is assumed the function is in MediaWiki core. * * @see ContentHandler::$enableDeprecationWarnings * @see wfDeprecated @@ -1037,7 +1043,8 @@ abstract class ContentHandler { * @see ContentHandler::$enableDeprecationWarnings */ public static function runLegacyHooks( $event, $args = array(), - $warn = null ) { + $warn = null + ) { if ( $warn === null ) { $warn = self::$enableDeprecationWarnings; diff --git a/includes/content/MessageContent.php b/includes/content/MessageContent.php index b36b670c78..59aca651b0 100644 --- a/includes/content/MessageContent.php +++ b/includes/content/MessageContent.php @@ -41,8 +41,8 @@ class MessageContent extends AbstractContent { protected $mMessage; /** - * @param Message|String $msg A Message object, or a message key - * @param array|null $params An optional array of message parameters + * @param Message|String $msg A Message object, or a message key + * @param array|null $params An optional array of message parameters */ public function __construct( $msg, $params = null ) { # XXX: messages may be wikitext, html or plain text! and maybe even something else entirely. @@ -153,6 +153,7 @@ class MessageContent extends AbstractContent { } $po = new ParserOutput( $html ); + return $po; } } diff --git a/includes/content/TextContent.php b/includes/content/TextContent.php index 87ebc9f357..d4a303cbb9 100644 --- a/includes/content/TextContent.php +++ b/includes/content/TextContent.php @@ -39,7 +39,7 @@ class TextContent extends AbstractContent { if ( $text === null || $text === false ) { wfWarn( "TextContent constructed with \$text = " . var_export( $text, true ) . "! " - . "This may indicate an error in the caller's scope." ); + . "This may indicate an error in the caller's scope." ); $text = ''; } @@ -74,6 +74,7 @@ class TextContent extends AbstractContent { */ public function getSize() { $text = $this->getNativeData(); + return strlen( $text ); } @@ -107,6 +108,7 @@ class TextContent extends AbstractContent { */ public function getNativeData() { $text = $this->mText; + return $text; } @@ -185,6 +187,7 @@ class TextContent extends AbstractContent { $nta = explode( "\n", $lang->segmentForDiff( $ntext ) ); $diff = new Diff( $ota, $nta ); + return $diff; } @@ -224,6 +227,7 @@ class TextContent extends AbstractContent { } $po->setText( $html ); + return $po; } @@ -259,8 +263,8 @@ class TextContent extends AbstractContent { * This implementation provides lossless conversion between content models based * on TextContent. * - * @param string $toModel the desired content model, use the CONTENT_MODEL_XXX flags. - * @param string $lossy flag, set to "lossy" to allow lossy conversion. If lossy conversion is + * @param string $toModel the desired content model, use the CONTENT_MODEL_XXX flags. + * @param string $lossy flag, set to "lossy" to allow lossy conversion. If lossy conversion is * not allowed, full round-trip conversion is expected to work without losing information. * * @return Content|bool A content object with the content model $toModel, or false if diff --git a/includes/content/TextContentHandler.php b/includes/content/TextContentHandler.php index e7f41e18b8..a6d8be8cca 100644 --- a/includes/content/TextContentHandler.php +++ b/includes/content/TextContentHandler.php @@ -43,6 +43,7 @@ class TextContentHandler extends ContentHandler { */ public function serializeContent( Content $content, $format = null ) { $this->checkFormat( $format ); + return $content->getNativeData(); } @@ -83,6 +84,7 @@ class TextContentHandler extends ContentHandler { } $mergedContent = $this->unserializeContent( $result, $format ); + return $mergedContent; } diff --git a/includes/content/WikitextContent.php b/includes/content/WikitextContent.php index 26337db947..fb186e949a 100644 --- a/includes/content/WikitextContent.php +++ b/includes/content/WikitextContent.php @@ -73,11 +73,14 @@ class WikitextContent extends TextContent { if ( $section === '' ) { wfProfileOut( __METHOD__ ); + return $with; # XXX: copy first? - } if ( $section == 'new' ) { + } + + if ( $section == 'new' ) { # Inserting a new section $subject = $sectionTitle ? wfMessage( 'newsectionheaderdefaultlevel' ) - ->rawParams( $sectionTitle )->inContentLanguage()->text() . "\n\n" : ''; + ->rawParams( $sectionTitle )->inContentLanguage()->text() . "\n\n" : ''; if ( wfRunHooks( 'PlaceNewSection', array( $this, $oldtext, $subject, &$text ) ) ) { $text = strlen( trim( $oldtext ) ) > 0 ? "{$oldtext}\n\n{$subject}{$text}" @@ -93,6 +96,7 @@ class WikitextContent extends TextContent { $newContent = new WikitextContent( $text ); wfProfileOut( __METHOD__ ); + return $newContent; } @@ -183,9 +187,11 @@ class WikitextContent extends TextContent { if ( !$title instanceof Title || !$title->isValidRedirectTarget() ) { return null; } + return $title; } } + return null; } @@ -220,7 +226,7 @@ class WikitextContent extends TextContent { * Returns true if this content is not a redirect, and this content's text * is countable according to the criteria defined by $wgArticleCountMethod. * - * @param bool $hasLinks if it is known whether this content contains + * @param bool $hasLinks if it is known whether this content contains * links, provide this information here, to avoid redundant parsing to * find out (default: null). * @param $title Title: (default: null) @@ -298,6 +304,7 @@ class WikitextContent extends TextContent { } $po = $wgParser->parse( $this->getNativeData(), $title, $options, true, true, $revId ); + return $po; }