Siebrand has uploaded a new change for review.
https://gerrit.wikimedia.org/r/96368
Change subject: Update formatting
......................................................................
Update formatting
Change-Id: Ieee4747cf2401d0d89a497a7637d32348192f481
---
M includes/content/AbstractContent.php
M includes/content/Content.php
M includes/content/ContentHandler.php
M includes/content/MessageContent.php
M includes/content/TextContent.php
M includes/content/TextContentHandler.php
M includes/content/WikitextContent.php
7 files changed, 64 insertions(+), 40 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/68/96368/1
diff --git a/includes/content/AbstractContent.php
b/includes/content/AbstractContent.php
index 137efb8..42d39fe 100644
--- a/includes/content/AbstractContent.php
+++ b/includes/content/AbstractContent.php
@@ -273,6 +273,7 @@
break;
}
}
+
return $titles;
}
@@ -293,6 +294,7 @@
*/
public function getUltimateRedirectTarget() {
$titles = $this->getRedirectChain();
+
return $titles ? array_pop( $titles ) : null;
}
@@ -394,8 +396,8 @@
* database after deletion.
*/
public function getDeletionUpdates( WikiPage $page,
- ParserOutput $parserOutput = null )
- {
+ ParserOutput $parserOutput = null
+ ) {
return array(
new LinksDeletionUpdate( $page ),
);
@@ -422,8 +424,8 @@
* 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 @@
$result = false;
wfRunHooks( 'ConvertContent', array( $this, $toModel, $lossy,
&$result ) );
+
return $result;
}
}
diff --git a/includes/content/Content.php b/includes/content/Content.php
index 5a90e09..f43e88f 100644
--- a/includes/content/Content.php
+++ b/includes/content/Content.php
@@ -267,6 +267,7 @@
public function getParserOutput( Title $title,
$revId = null,
ParserOptions $options = null, $generateHtml = true );
+
// TODO: make RenderOutput and RenderOptions base classes
/**
@@ -446,9 +447,9 @@
* @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 @@
* 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] <vvv> Hooks are ugly; make CodeHighlighter interface and a
// config to set the class which handles syntax highlighting
// [12:00] <vvv> And default it to a DummyHighlighter
diff --git a/includes/content/ContentHandler.php
b/includes/content/ContentHandler.php
index ede4306..c34ac31 100644
--- a/includes/content/ContentHandler.php
+++ b/includes/content/ContentHandler.php
@@ -145,8 +145,8 @@
* 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 @@
}
$handler = ContentHandler::getForModelID( $modelId );
+
return $handler->unserializeContent( $text, $format );
}
@@ -259,6 +260,7 @@
*/
public static function getForTitle( Title $title ) {
$modelId = $title->getContentModel();
+
return ContentHandler::getForModelID( $modelId );
}
@@ -273,6 +275,7 @@
*/
public static function getForContent( Content $content ) {
$modelId = $content->getModel();
+
return ContentHandler::getForModelID( $modelId );
}
@@ -335,9 +338,10 @@
}
wfDebugLog( 'ContentHandler', 'Created handler for ' . $modelId
- . ': ' . get_class( $handler ) );
+ . ': ' . get_class( $handler ) );
ContentHandler::$handlers[$modelId] = $handler;
+
return ContentHandler::$handlers[$modelId];
}
@@ -380,6 +384,7 @@
}
$formats = array_unique( $formats );
+
return $formats;
}
@@ -607,7 +612,7 @@
*
* @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 @@
}
wfRunHooks( 'PageContentLanguage', array( $title, &$pageLang,
$wgLang ) );
+
return wfGetLangObj( $pageLang );
}
@@ -641,7 +647,7 @@
*
* @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 @@
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 @@
200 - strlen( wfMessage( 'autosumm-new'
)->inContentLanguage()->text() ) );
return wfMessage( 'autosumm-new' )->rawParams(
$truncatedtext )
- ->inContentLanguage()->text();
+ ->inContentLanguage()->text();
}
// Blanking auto-summaries
@@ -764,15 +770,15 @@
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 @@
* 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 @@
* @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 b36b670..59aca65 100644
--- a/includes/content/MessageContent.php
+++ b/includes/content/MessageContent.php
@@ -41,8 +41,8 @@
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 @@
}
$po = new ParserOutput( $html );
+
return $po;
}
}
diff --git a/includes/content/TextContent.php b/includes/content/TextContent.php
index 87ebc9f..d4a303c 100644
--- a/includes/content/TextContent.php
+++ b/includes/content/TextContent.php
@@ -39,7 +39,7 @@
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 @@
*/
public function getSize() {
$text = $this->getNativeData();
+
return strlen( $text );
}
@@ -107,6 +108,7 @@
*/
public function getNativeData() {
$text = $this->mText;
+
return $text;
}
@@ -185,6 +187,7 @@
$nta = explode( "\n", $lang->segmentForDiff( $ntext ) );
$diff = new Diff( $ota, $nta );
+
return $diff;
}
@@ -224,6 +227,7 @@
}
$po->setText( $html );
+
return $po;
}
@@ -259,8 +263,8 @@
* 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 e7f41e1..a6d8be8 100644
--- a/includes/content/TextContentHandler.php
+++ b/includes/content/TextContentHandler.php
@@ -43,6 +43,7 @@
*/
public function serializeContent( Content $content, $format = null ) {
$this->checkFormat( $format );
+
return $content->getNativeData();
}
@@ -83,6 +84,7 @@
}
$mergedContent = $this->unserializeContent( $result, $format );
+
return $mergedContent;
}
diff --git a/includes/content/WikitextContent.php
b/includes/content/WikitextContent.php
index 26337db..fb186e9 100644
--- a/includes/content/WikitextContent.php
+++ b/includes/content/WikitextContent.php
@@ -73,11 +73,14 @@
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 @@
$newContent = new WikitextContent( $text );
wfProfileOut( __METHOD__ );
+
return $newContent;
}
@@ -183,9 +187,11 @@
if ( !$title instanceof Title ||
!$title->isValidRedirectTarget() ) {
return null;
}
+
return $title;
}
}
+
return null;
}
@@ -220,7 +226,7 @@
* 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 @@
}
$po = $wgParser->parse( $this->getNativeData(), $title,
$options, true, true, $revId );
+
return $po;
}
--
To view, visit https://gerrit.wikimedia.org/r/96368
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ieee4747cf2401d0d89a497a7637d32348192f481
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Siebrand <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits