r98896 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98895‎ | r98896 | r98897 >
Date:20:25, 4 October 2011
Author:reedy
Status:resolved (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/MessageCollection.php (modified) (history)
  • /trunk/extensions/Translate/MessageGroups.php (modified) (history)
  • /trunk/extensions/Translate/ffs/Gettext.php (modified) (history)
  • /trunk/extensions/Translate/ffs/MediaWikiComplexMessages.php (modified) (history)
  • /trunk/extensions/Translate/scripts/magic-export.php (modified) (history)
  • /trunk/extensions/Translate/scripts/poimport.php (modified) (history)
  • /trunk/extensions/Translate/specials/SpecialImportTranslations.php (modified) (history)
  • /trunk/extensions/Translate/specials/SpecialMagic.php (modified) (history)
  • /trunk/extensions/Translate/specials/SpecialMyLanguage.php (modified) (history)
  • /trunk/extensions/Translate/specials/SpecialTranslationStats.php (modified) (history)
  • /trunk/extensions/Translate/tag/DeleteJob.php (modified) (history)
  • /trunk/extensions/Translate/tag/MoveJob.php (modified) (history)
  • /trunk/extensions/Translate/tag/PageTranslationHooks.php (modified) (history)
  • /trunk/extensions/Translate/tag/SpecialPageTranslation.php (modified) (history)
  • /trunk/extensions/Translate/tag/SpecialPageTranslationDeletePage.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/MessageCollection.php
@@ -591,6 +591,7 @@
592592
593593 /**
594594 * ArrayAccess methods. @{
 595+ * @return bool
595596 */
596597 public function offsetExists( $offset ) {
597598 return isset( $this->keys[$offset] );
Index: trunk/extensions/Translate/scripts/magic-export.php
@@ -274,6 +274,8 @@
275275
276276 /**
277277 * Copied from cli.inc.
 278+ * @param $codes
 279+ * @return array
278280 */
279281 private static function parseLanguageCodes( /* string */ $codes ) {
280282 $langs = array_map( 'trim', explode( ',', $codes ) );
Index: trunk/extensions/Translate/scripts/poimport.php
@@ -91,6 +91,7 @@
9292
9393 /**
9494 * Parses relevant stuff from the po file.
 95+ * @return array|bool
9596 */
9697 public function parse() {
9798 $data = file_get_contents( $this->file );
Index: trunk/extensions/Translate/MessageGroups.php
@@ -45,6 +45,7 @@
4646
4747 /**
4848 * Returns a list of optional and ignored messages in 2-d array.
 49+ * @return array
4950 */
5051 public function getBools() {
5152 return array(
@@ -129,6 +130,7 @@
130131 * This function can be used for meta message groups to list their "own"
131132 * messages. For example branched message groups can exclude the messages they
132133 * share with each other.
 134+ * @return array
133135 */
134136 public function getUniqueDefinitions() {
135137 return $this->meta ? array() : $this->getDefinitions();
@@ -197,6 +199,7 @@
198200 * @param $code \string Language code for this collection.
199201 * @param $unique \bool Whether to build collection for messages unique to this
200202 * group only.
 203+ * @return \type
201204 */
202205 public function initCollection( $code, $unique = false ) {
203206 if ( !$unique ) {
@@ -225,6 +228,7 @@
226229
227230 /**
228231 * Can be overwritten to retun false if something is wrong.
 232+ * @return bool
229233 */
230234 public function exists() {
231235 return true;
@@ -875,6 +879,7 @@
876880
877881 /**
878882 * Returns a cacher object.
 883+ * @return BagOStuff
879884 */
880885 protected static function getCache() {
881886 return wfGetCache( CACHE_ANYTHING );
@@ -1042,6 +1047,7 @@
10431048 /**
10441049 * Returns group strucuted into sub groups. First group in each subgroup is
10451050 * considered as the main group.
 1051+ * @return array
10461052 */
10471053 public static function getGroupStructure() {
10481054 global $wgTranslateGroupStructure;
Index: trunk/extensions/Translate/tag/SpecialPageTranslation.php
@@ -452,6 +452,9 @@
453453 * - Updates revtags table
454454 * - Setups renderjobs to update the translation pages
455455 * - Invalidates caches
 456+ * @param $page TranslatablePage
 457+ * @param $sections array
 458+ * @return array|bool
456459 */
457460 public function markForTranslation( TranslatablePage $page, Array $sections ) {
458461 global $wgRequest;
Index: trunk/extensions/Translate/tag/SpecialPageTranslationDeletePage.php
@@ -16,8 +16,13 @@
1717 */
1818 class SpecialPageTranslationDeletePage extends UnlistedSpecialPage {
1919 // Basic form parameters both as text and as titles
20 - protected $text, $title;
 20+ protected $text;
2121
 22+ /**
 23+ * @var Title
 24+ */
 25+ protected $title;
 26+
2227 // Other form parameters
2328 /// 'check' or 'perform'
2429 protected $subaction;
@@ -34,7 +39,11 @@
3540 /// Contains the language code if we are working with translation page
3641 protected $code;
3742
38 - /// User instance.
 43+ /**
 44+ * User instance.
 45+ *
 46+ * @var User
 47+ */
3948 protected $user;
4049
4150 public function __construct() {
@@ -107,30 +116,31 @@
108117 /**
109118 * Do the basic checks whether moving is possible and whether
110119 * the input looks anywhere near sane.
 120+ * @return bool
111121 */
112122 protected function doBasicChecks() {
113123 global $wgOut;
114124 # Check for database lock
115125 if ( wfReadOnly() ) {
116126 $wgOut->readOnlyPage();
117 - return;
 127+ return false;
118128 }
119129
120130 if ( $this->title === null ) {
121131 $wgOut->showErrorPage( 'notargettitle', 'notargettext' );
122 - return;
 132+ return false;
123133 }
124134
125135 if ( !$this->title->exists() ) {
126136 $wgOut->showErrorPage( 'nopagetitle', 'nopagetext' );
127 - return;
 137+ return false;
128138 }
129139
130140 # Check rights
131141 $permErrors = $this->title->getUserPermissionsErrors( 'delete', $this->user );
132142 if ( !empty( $permErrors ) ) {
133143 $wgOut->showPermissionsErrorPage( $permErrors );
134 - return;
 144+ return false;
135145 }
136146
137147 // Let the caller know it's safe to continue
@@ -140,6 +150,7 @@
141151 /**
142152 * Checks token. Use before real actions happen. Have to use wpEditToken
143153 * for compatibility for SpecialMovepage.php.
 154+ * @return bool
144155 */
145156 protected function checkToken() {
146157 global $wgRequest;
Index: trunk/extensions/Translate/tag/DeleteJob.php
@@ -133,6 +133,7 @@
134134
135135 /**
136136 * Get a user object for doing edits.
 137+ * @return \User
137138 */
138139 public function getUser() {
139140 return User::newFromName( $this->params['user'], false );
Index: trunk/extensions/Translate/tag/PageTranslationHooks.php
@@ -61,6 +61,9 @@
6262 /**
6363 * Set the right page content language for translated pages ("Page/xx").
6464 * Hook: PageContentLanguage
 65+ * @param $title Title
 66+ * @param $pageLang
 67+ * @return bool
6568 */
6669 public static function onPageContentLanguage( $title, &$pageLang ) {
6770 // For translation pages, parse plural, grammar etc with correct language, and set the right direction
@@ -71,13 +74,23 @@
7275 return true;
7376 }
7477
75 - // Only called from hook
 78+ /**
 79+ * Only called from hook
 80+ *
 81+ * @param $outputpage
 82+ * @param $text
 83+ * @return bool
 84+ */
7685 public static function injectCss( $outputpage, $text ) {
7786 $outputpage->addModules( 'ext.translate' );
7887
7988 return true;
8089 }
8190
 91+ /**
 92+ * @param Title $title
 93+ * @return types
 94+ */
8295 public static function titleToGroup( Title $title ) {
8396 $namespace = $title->getNamespace();
8497 $text = $title->getDBkey();
@@ -298,6 +311,16 @@
299312 /**
300313 * When attempting to save, last resort. Edit page would only display
301314 * edit conflict if there wasn't tpSyntaxCheckForEditPage
 315+ * @param $article Article
 316+ * @param $user User
 317+ * @param $text
 318+ * @param $summary string
 319+ * @param $minor bool
 320+ * @param $_
 321+ * @param $_
 322+ * @param $flags
 323+ * @param $status
 324+ * @return bool
302325 */
303326 public static function tpSyntaxCheck( $article, $user, $text, $summary,
304327 $minor, $_, $_, $flags, $status ) {
Index: trunk/extensions/Translate/tag/MoveJob.php
@@ -140,6 +140,7 @@
141141
142142 /**
143143 * Get a user object for doing edits.
 144+ * @return \User
144145 */
145146 public function getUser() {
146147 return User::newFromName( $this->params['user'], false );
Index: trunk/extensions/Translate/specials/SpecialMyLanguage.php
@@ -48,6 +48,14 @@
4949 /**
5050 * Make Special:MyLanguage links red if the target page doesn't exists.
5151 * A bit hacky because the core code is not so flexible.
 52+ * @param $dummy
 53+ * @param $target
 54+ * @param $html
 55+ * @param $customAttribs
 56+ * @param $query
 57+ * @param $options
 58+ * @param $ret
 59+ * @return bool
5260 */
5361 public static function linkfix( $dummy, $target, &$html, &$customAttribs, &$query, &$options, &$ret ) {
5462 if ( $target->getNamespace() == NS_SPECIAL ) {
Index: trunk/extensions/Translate/specials/SpecialImportTranslations.php
@@ -99,6 +99,8 @@
100100 * Checks for error state from the return value of loadFile and parseFile
101101 * functions. Prints the error and the form and returns true if there is an
102102 * error. Returns false and does nothing if there is no error.
 103+ * @param $msg array
 104+ * @return bool
103105 */
104106 protected function checkError( $msg ) {
105107 if ( $msg[0] !== 'ok' ) {
@@ -179,6 +181,8 @@
180182
181183 /**
182184 * Try to get the file data from any of the supported methods.
 185+ * @param $filedata
 186+ * @return array
183187 */
184188 protected function loadFile( &$filedata ) {
185189 $source = $this->request->getText( 'upload-type' );
@@ -226,6 +230,8 @@
227231
228232 /**
229233 * Try parsing file.
 234+ * @param $data
 235+ * @return array
230236 */
231237 protected function parseFile( $data ) {
232238 /** Construct a dummy group for us...
Index: trunk/extensions/Translate/specials/SpecialTranslationStats.php
@@ -467,6 +467,7 @@
468468 * @param $scale string One of hours, days, weeks, months
469469 * @param $cutoff int Timestamp in unix format.
470470 * @param $direction string One of earlier, later
 471+ * @return int
471472 */
472473 protected static function roundTimestampToCutoff( $scale, $cutoff, $direction = 'earlier' ) {
473474 $dir = $direction === 'earlier' ? -1 : 1;
Index: trunk/extensions/Translate/specials/SpecialMagic.php
@@ -52,6 +52,7 @@
5353 /**
5454 * Returns HTML5 output of the form
5555 * GLOBALS: $wgLang, $wgScript
 56+ * @return string
5657 */
5758 protected function getForm() {
5859 global $wgLang, $wgScript;
Index: trunk/extensions/Translate/ffs/MediaWikiComplexMessages.php
@@ -200,6 +200,9 @@
201201 }
202202
203203 /**
 204+ * @param $group
 205+ * @param $code
 206+ * @return array
204207 */
205208 protected function readVariable( $group, $code ) {
206209 $file = $group['file'];
@@ -503,6 +506,8 @@
504507
505508 /**
506509 * Returns string with quotes that should be valid php
 510+ * @param $data string
 511+ * @return string
507512 */
508513 protected function normalize( $data ) {
509514 # Escape quotes
Index: trunk/extensions/Translate/ffs/Gettext.php
@@ -242,6 +242,8 @@
243243 /**
244244 * Generates unique key for each message. Changing this WILL BREAK ALL
245245 * existing pages!
 246+ * @param $item
 247+ * @return string
246248 */
247249 public static function generateKeyFromItem( $item ) {
248250 $lang = Language::factory( 'en' );
@@ -264,6 +266,9 @@
265267 * not allowed in MediaWiki pages, the default action is to append
266268 * \-character at the end of the message. You can also choose to ignore it
267269 * and use the trim action instead.
 270+ * @param $data
 271+ * @param $whitespace string
 272+ * @return string
268273 */
269274 public static function formatForWiki( $data, $whitespace = 'mark' ) {
270275 $quotePattern = '/(^"|"$\n?)/m';

Comments

#Comment by Nikerabbit (talk | contribs)   22:24, 4 October 2011
+        * @return \type

?

#Comment by Reedy (talk | contribs)   22:51, 4 October 2011

God knows. Fixed locally, will commit later as part of other commits

#Comment by Nikerabbit (talk | contribs)   22:51, 4 October 2011

Also?

+	 * @return \User

Status & tagging log