r98897 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98896‎ | r98897 | r98898 >
Date:20:25, 4 October 2011
Author:reedy
Status:deferred (Comments)
Tags:
Comment:
Documentation

Swap some return; to return false; so more consistent with success

Splitting the commit so CR doesn't complain too much
Modified paths:
  • /trunk/extensions/Translate/TranslateEditAddons.php (modified) (history)
  • /trunk/extensions/Translate/TranslateHooks.php (modified) (history)
  • /trunk/extensions/Translate/TranslateUtils.php (modified) (history)
  • /trunk/extensions/Translate/tag/SpecialPageTranslationMovePage.php (modified) (history)
  • /trunk/extensions/Translate/tag/TPParse.php (modified) (history)
  • /trunk/extensions/Translate/tag/TranslatablePage.php (modified) (history)
  • /trunk/extensions/Translate/utils/Html.php (modified) (history)
  • /trunk/extensions/Translate/utils/JsSelectToInput.php (modified) (history)
  • /trunk/extensions/Translate/utils/MessageGroupCache.php (modified) (history)
  • /trunk/extensions/Translate/utils/MessageGroupStats.php (modified) (history)
  • /trunk/extensions/Translate/utils/RevTag.php (modified) (history)
  • /trunk/extensions/Translate/utils/StatsTable.php (modified) (history)
  • /trunk/extensions/Translate/utils/TranslationHelpers.php (modified) (history)
  • /trunk/extensions/Translate/utils/UserToggles.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/tag/TranslatablePage.php
@@ -57,6 +57,11 @@
5858 * Constructs a translatable page from given text.
5959 * Some functions will fail unless you set revision
6060 * parameter manually.
 61+ *
 62+ * @param $title Title
 63+ * @param $text string
 64+ *
 65+ * @return TranslatablePage
6166 */
6267 public static function newFromText( Title $title, $text ) {
6368 $obj = new self( $title );
@@ -314,12 +319,20 @@
315320
316321 /**
317322 * Returns a random string that can be used as placeholder.
 323+ * @return string
318324 */
319325 protected static function getUniq() {
320326 static $i = 0;
321327 return "\x7fUNIQ" . dechex( mt_rand( 0, 0x7fffffff ) ) . dechex( mt_rand( 0, 0x7fffffff ) ) . '|' . $i++;
322328 }
323329
 330+ /**
 331+ * @param $string string
 332+ * @param $rep
 333+ * @param $start
 334+ * @param $end
 335+ * @return string
 336+ */
324337 protected static function index_replace( $string, $rep, $start, $end ) {
325338 return substr( $string, 0, $start ) . $rep . substr( $string, $end );
326339 }
Index: trunk/extensions/Translate/tag/TPParse.php
@@ -223,6 +223,8 @@
224224 /**
225225 * Replaces variables from given text.
226226 * @todo Is plain str_replace not enough (even the loop is not needed)?
 227+ *
 228+ * @return string
227229 */
228230 protected static function replaceVariables( $variables, $text ) {
229231 foreach ( $variables as $key => $value ) {
Index: trunk/extensions/Translate/tag/SpecialPageTranslationMovePage.php
@@ -143,30 +143,31 @@
144144 /**
145145 * Do the basic checks whether moving is possible and whether
146146 * the input looks anywhere near sane.
 147+ * @return bool
147148 */
148149 protected function doBasicChecks() {
149150 global $wgOut;
150151 # Check for database lock
151152 if ( wfReadOnly() ) {
152153 $wgOut->readOnlyPage();
153 - return;
 154+ return false;
154155 }
155156
156157 if ( $this->oldTitle === null ) {
157158 $wgOut->showErrorPage( 'notargettitle', 'notargettext' );
158 - return;
 159+ return false;
159160 }
160161
161162 if ( !$this->oldTitle->exists() ) {
162163 $wgOut->showErrorPage( 'nopagetitle', 'nopagetext' );
163 - return;
 164+ return false;
164165 }
165166
166167 # Check rights
167168 $permErrors = $this->oldTitle->getUserPermissionsErrors( 'move', $this->user );
168169 if ( !empty( $permErrors ) ) {
169170 $wgOut->showPermissionsErrorPage( $permErrors );
170 - return;
 171+ return false;
171172 }
172173
173174 // Let the caller know it's safe to continue
Index: trunk/extensions/Translate/TranslateEditAddons.php
@@ -122,6 +122,8 @@
123123 /**
124124 * Keep the usual diiba daaba hidden from translators.
125125 * Hook: AlternateEdit
 126+ * @param $editpage EditPage
 127+ * @return bool
126128 */
127129 public static function intro( $editpage ) {
128130 $editpage->suppressIntro = true;
@@ -137,6 +139,8 @@
138140 /**
139141 * Adds the translation aids and navigation to the normal edit page.
140142 * Hook: EditPage::showEditForm:initial
 143+ * @param $object
 144+ * @return bool
141145 */
142146 static function addTools( $object ) {
143147 $handle = new MessageHandle( $object->mTitle );
@@ -152,6 +156,10 @@
153157 * Replace the normal save button with one that says if you are editing
154158 * message documentation to try to avoid accidents.
155159 * Hook: EditPageBeforeEditButtons
 160+ * @param $editpage EditPage
 161+ * @param $buttons
 162+ * @param $tabindex
 163+ * @return bool
156164 */
157165 static function buttonHack( $editpage, &$buttons, $tabindex ) {
158166 global $wgTranslateDocumentationLanguageCode, $wgLang;
@@ -293,6 +301,9 @@
294302 /**
295303 * Removes protection tab for message namespaces - not useful.
296304 * Hook: SkinTemplateTabs
 305+ * @param $skin Skin
 306+ * @param $tabs
 307+ * @return bool
297308 */
298309 public static function tabs( $skin, &$tabs ) {
299310 $handle = new MessageHandle( $skin->getTitle() );
@@ -357,7 +368,7 @@
358369 if ( $code === $wgTranslateDocumentationLanguageCode ) {
359370 return $fuzzy;
360371 }
361 -
 372+
362373 // Not all groups have checkers
363374 $group = $handle->getGroup();
364375 $checker = $group->getChecker();
@@ -386,7 +397,7 @@
387398 'rt_type' => RevTag::getType( 'fuzzy' ),
388399 'rt_revision' => $revision
389400 );
390 -
 401+
391402 // Replace the existing fuzzy tag, if any
392403 if ( $fuzzy !== false ) {
393404 $index = array_keys( $conds );
@@ -402,6 +413,11 @@
403414 * This is used to show diff against current version of source message
404415 * when updating a translation.
405416 * Hook: Translate:newTranslation
 417+ * @param $handle MessageHandle
 418+ * @param $revision Revision
 419+ * @param $text string
 420+ * @param $user User
 421+ * @return bool
406422 */
407423 public static function updateTransverTag( MessageHandle $handle, $revision, $text, User $user ) {
408424 $group = $handle->getGroup();
Index: trunk/extensions/Translate/TranslateHooks.php
@@ -143,6 +143,10 @@
144144 /**
145145 * Hook: ParserFirstCallInit
146146 * Registers \<languages> tag with the parser.
 147+ *
 148+ * @param $parser Parser
 149+ *
 150+ * @return bool
147151 */
148152 public static function setupParserHooks( $parser ) {
149153 // For nice language list in-page
@@ -182,6 +186,9 @@
183187 /**
184188 * Set the right page content language for message group translations ("Page/xx").
185189 * Hook: PageContentLanguage
 190+ * @param $title Title
 191+ * @param $pageLang
 192+ * @return bool
186193 */
187194 public static function onPageContentLanguage( $title, &$pageLang ) {
188195 global $wgTranslateMessageNamespaces;
Index: trunk/extensions/Translate/utils/JsSelectToInput.php
@@ -93,6 +93,7 @@
9494 * @param $msg \string Message key.
9595 * @param $source \string Html id.
9696 * @param $target \string Html id.
 97+ * @return string
9798 */
9899 protected function getButton( $msg, $source, $target ) {
99100 $source = Xml::escapeJsString( $source );
Index: trunk/extensions/Translate/utils/UserToggles.php
@@ -87,6 +87,7 @@
8888
8989 /**
9090 * JavsScript selector for language codes.
 91+ * @return \JsSelectToInput
9192 */
9293 protected static function languageSelector() {
9394 global $wgLang;
Index: trunk/extensions/Translate/utils/Html.php
@@ -140,6 +140,8 @@
141141
142142 /**
143143 * Shortcut for param( name = id ). Chain-accessor.
 144+ * @param $value
 145+ * @return mixed
144146 */
145147 public function id( $value = null ) {
146148 return $this->param( 'id', $value );
Index: trunk/extensions/Translate/utils/StatsTable.php
@@ -223,7 +223,7 @@
224224 */
225225 public function getGroupDescription( MessageGroup $group ) {
226226 $code = $this->lang->getCode();
227 -
 227+
228228 $cache = wfGetCache( CACHE_ANYTHING );
229229 $key = wfMemckey( "translate-groupdesc-$code-" . $group->getId() );
230230 $desc = $cache->get( $key );
@@ -275,6 +275,8 @@
276276 /**
277277 * Used to circumvent ugly tooltips when newlines are used in the
278278 * message content ("x\ny" becomes "x y").
 279+ * @param $text
 280+ * @return string
279281 */
280282 public static function formatTooltip( $text ) {
281283 $wordSeparator = wfMessage( 'word-separator' )->text();
Index: trunk/extensions/Translate/utils/MessageGroupStats.php
@@ -154,6 +154,7 @@
155155
156156 /**
157157 * Returns an array of needed database fields.
 158+ * @return array
158159 */
159160 protected static function extractNumbers( $row ) {
160161 return array(
@@ -317,7 +318,7 @@
318319 /**
319320 * Converts input to "+2" "-4" type of string.
320321 * @param $number int
321 - * @returns string
 322+ * @return string
322323 */
323324 protected static function stringifyNumber( $number ) {
324325 $number = intval( $number );
Index: trunk/extensions/Translate/utils/TranslationHelpers.php
@@ -1147,6 +1147,8 @@
11481148
11491149 /**
11501150 * Checks whether the given service has exceeded failure count
 1151+ * @param $service string
 1152+ * @return bool
11511153 */
11521154 public static function checkTranslationServiceFailure( $service ) {
11531155 global $wgMemc;
Index: trunk/extensions/Translate/utils/MessageGroupCache.php
@@ -14,7 +14,7 @@
1515 * of the actual format.
1616 */
1717 class MessageGroupCache {
18 - /// \string
 18+ /// \string
1919 protected $group;
2020 /// CdbReader
2121 protected $cache;
@@ -210,6 +210,7 @@
211211
212212 /**
213213 * Returns full path the the cache file.
 214+ * @return string
214215 */
215216 protected function getCacheFileName() {
216217 return TranslateUtils::cacheFile( "translate_groupcache-{$this->group->getId()}-{$this->code}.cdb" );
Index: trunk/extensions/Translate/utils/RevTag.php
@@ -74,7 +74,7 @@
7575
7676 /**
7777 * Loads the list of tags from database using the old schema
78 - * return array tag names => tag id
 78+ * @return array tag names => tag id
7979 */
8080 protected static function loadTags() {
8181 static $tags = null;
Index: trunk/extensions/Translate/TranslateUtils.php
@@ -132,7 +132,7 @@
133133 "ORDER BY lang ASC, rc_timestamp DESC";
134134
135135 $res = $dbr->query( $sql, __METHOD__ );
136 - $rows = iterator_to_array( $res );
 136+ $rows = iterator_to_array( $res );
137137 return $rows;
138138 }
139139
@@ -195,6 +195,7 @@
196196 * @param $language \string Language code of the language the names should
197197 * be localised to.
198198 * @param $selectedId \string The language code that is selected by default.
 199+ * @return string
199200 */
200201 public static function languageSelector( $language, $selectedId ) {
201202 if ( is_callable( array( 'LanguageNames', 'getNames' ) ) ) {

Comments

#Comment by Nikerabbit (talk | contribs)   05:48, 5 October 2011

That's not Revision, but revision number.

+	 * @param $revision Revision

Status & tagging log