r99101 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99100‎ | r99101 | r99102 >
Date:13:30, 6 October 2011
Author:reedy
Status:ok (Comments)
Tags:
Comment:
More documentation

Added 1 TODO
Modified paths:
  • /trunk/extensions/Translate/FFS.php (modified) (history)
  • /trunk/extensions/Translate/MessageCollection.php (modified) (history)
  • /trunk/extensions/Translate/MessageGroups.php (modified) (history)
  • /trunk/extensions/Translate/RcFilter.php (modified) (history)
  • /trunk/extensions/Translate/TranslateEditAddons.php (modified) (history)
  • /trunk/extensions/Translate/TranslateHooks.php (modified) (history)
  • /trunk/extensions/Translate/TranslateTasks.php (modified) (history)
  • /trunk/extensions/Translate/utils/Font.php (modified) (history)
  • /trunk/extensions/Translate/utils/HTMLJsSelectToInputField.php (modified) (history)
  • /trunk/extensions/Translate/utils/MessageGroupCache.php (modified) (history)
  • /trunk/extensions/Translate/utils/MessageGroupStats.php (modified) (history)
  • /trunk/extensions/Translate/utils/MessageWebImporter.php (modified) (history)
  • /trunk/extensions/Translate/utils/StringMatcher.php (modified) (history)
  • /trunk/extensions/Translate/utils/TranslateYaml.php (modified) (history)
  • /trunk/extensions/Translate/utils/TranslationEditPage.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/MessageCollection.php
@@ -251,6 +251,9 @@
252252 }
253253 }
254254
 255+ /**
 256+ * @return array
 257+ */
255258 public static function getAvailableFilters() {
256259 return array(
257260 'fuzzy',
Index: trunk/extensions/Translate/FFS.php
@@ -224,7 +224,7 @@
225225
226226 /**
227227 * @param $collection MessageCollection
228 - * @return
 228+ * @return string
229229 */
230230 public function writeIntoVariable( MessageCollection $collection ) {
231231 $sourceFile = $this->group->getSourceFilePath( $collection->code );
Index: trunk/extensions/Translate/MessageGroups.php
@@ -79,10 +79,15 @@
8080 * branches one can set a message key mangler.
8181 */
8282 protected $mangler = null;
 83+
 84+ /**
 85+ * @return StringMatcher
 86+ */
8387 public function getMangler() {
8488 $mangler = $this->mangler;
8589
8690 if ( !$mangler ) {
 91+ // TODO: Shouldn't this set $this->mangler
8792 $mangler = StringMatcher::emptyMatcher();
8893 }
8994
@@ -97,6 +102,9 @@
98103 return null;
99104 }
100105
 106+ /**
 107+ * @return SimpleFormatWriter
 108+ */
101109 public function getWriter() {
102110 return new SimpleFormatWriter( $this );
103111 }
@@ -459,6 +467,11 @@
460468 }
461469 }
462470
 471+ /**
 472+ * @param $label
 473+ * @param $id
 474+ * @return ExtensionMessageGroup
 475+ */
463476 public static function factory( $label, $id ) {
464477 $group = new ExtensionMessageGroup;
465478 $group->setLabel( $label );
@@ -519,6 +532,9 @@
520533 return is_readable( $this->getMessageFileWithPath( $this->getSourceLanguage() ) );
521534 }
522535
 536+ /**
 537+ * @return MediaWikiMessageChecker
 538+ */
523539 public function getChecker() {
524540 $checker = new MediaWikiMessageChecker( $this );
525541 $checker->setChecks( array(
@@ -757,6 +773,9 @@
758774 return $this->title;
759775 }
760776
 777+ /**
 778+ * @return array
 779+ */
761780 public function getDefinitions() {
762781 $dbr = wfGetDB( DB_SLAVE );
763782 $tables = 'translate_sections';
@@ -817,6 +836,9 @@
818837 return $rev->getText();
819838 }
820839
 840+ /**
 841+ * @return MediaWikiMessageChecker
 842+ */
821843 public function getChecker() {
822844 $checker = new MediaWikiMessageChecker( $this );
823845 $checker->setChecks( array(
@@ -916,9 +938,9 @@
917939 $deps[] = new GlobalDependency( 'wgTranslateEC' );
918940 $deps[] = new GlobalDependency( 'wgTranslateCC' );
919941 $deps[] = new GlobalDependency( 'wgTranslateExtensionDirectory' );
920 - $deps[] = New FileDependency( dirname( __FILE__ ) . '/groups/mediawiki-defines.txt' );
921 - $deps[] = New FileDependency( dirname( __FILE__ ) . '/groups/Wikia/extensions.txt' );
922 - $deps[] = New FileDependency( dirname( __FILE__ ) . '/groups/Toolserver/toolserver-textdomains.txt' );
 942+ $deps[] = new FileDependency( dirname( __FILE__ ) . '/groups/mediawiki-defines.txt' );
 943+ $deps[] = new FileDependency( dirname( __FILE__ ) . '/groups/Wikia/extensions.txt' );
 944+ $deps[] = new FileDependency( dirname( __FILE__ ) . '/groups/Toolserver/toolserver-textdomains.txt' );
923945
924946 if ( $wgTranslateAddMWExtensionGroups ) {
925947 $a = new PremadeMediawikiExtensionGroups;
Index: trunk/extensions/Translate/TranslateEditAddons.php
@@ -212,6 +212,7 @@
213213 }
214214
215215 /**
 216+ * @param $title Title
216217 * @return Array of the message and the language
217218 */
218219 public static function figureMessage( Title $title ) {
@@ -229,6 +230,10 @@
230231 return array( $key, $code );
231232 }
232233
 234+ /**
 235+ * @param $title Title
 236+ * @return array
 237+ */
233238 public static function getKeyCodeGroup( Title $title ) {
234239 list( $key, $code ) = self::figureMessage( $title );
235240 $group = self::getMessageGroup( $title->getNamespace(), $key );
@@ -261,6 +266,10 @@
262267 return $mg;
263268 }
264269
 270+ /**
 271+ * @param $object
 272+ * @return String
 273+ */
265274 private static function editBoxes( $object ) {
266275 global $wgOut, $wgRequest;
267276
@@ -316,7 +325,12 @@
317326 return true;
318327 }
319328
320 - /// Hook: EditPage::showEditForm:fields
 329+ /**
 330+ * Hook: EditPage::showEditForm:fields
 331+ * @param $edit
 332+ * @param $out OutputPage
 333+ * @return bool
 334+ */
321335 public static function keepFields( $edit, $out ) {
322336 global $wgRequest;
323337
@@ -329,7 +343,19 @@
330344 return true;
331345 }
332346
333 - /// Hook: ArticleSaveComplete
 347+ /**
 348+ * @Hook: ArticleSaveComplete
 349+ * @param $article Article
 350+ * @param $user User
 351+ * @param $text string
 352+ * @param $summary string
 353+ * @param $minor bool
 354+ * @param $_
 355+ * @param $_
 356+ * @param $flags
 357+ * @param $revision Revision
 358+ * @return bool
 359+ */
334360 public static function onSave( $article, $user, $text, $summary,
335361 $minor, $_, $_, $flags, $revision
336362 ) {
@@ -358,6 +384,11 @@
359385 return true;
360386 }
361387
 388+ /**
 389+ * @param $handle MessageHandle
 390+ * @param $text
 391+ * @return bool
 392+ */
362393 protected static function checkNeedsFuzzy( MessageHandle $handle, $text ) {
363394 // Check for explicit tag.
364395 $fuzzy = self::hasFuzzyString( $text );
@@ -389,6 +420,11 @@
390421 return $fuzzy;
391422 }
392423
 424+ /**
 425+ * @param $title Title
 426+ * @param $revision
 427+ * @param $fuzzy
 428+ */
393429 protected static function updateFuzzyTag( Title $title, $revision, $fuzzy ) {
394430 $dbw = wfGetDB( DB_MASTER );
395431
@@ -448,6 +484,10 @@
449485 return true;
450486 }
451487
 488+ /**
 489+ * @param $text string
 490+ * @return string
 491+ */
452492 public static function preserveWhitespaces( $text ) {
453493 $text = wfEscapeWikiText( $text );
454494 $text = preg_replace( '/^ /m', ' ', $text );
@@ -457,7 +497,12 @@
458498 return $text;
459499 }
460500
461 - /// Hook: LanguageGetTranslatedLanguageNames
 501+ /**
 502+ * Hook: LanguageGetTranslatedLanguageNames
 503+ * @param $names
 504+ * @param $code
 505+ * @return bool
 506+ */
462507 public static function translateMessageDocumentationLanguage( &$names, $code ) {
463508 global $wgTranslateDocumentationLanguageCode;
464509 if ( $wgTranslateDocumentationLanguageCode ) {
@@ -467,7 +512,12 @@
468513 return true;
469514 }
470515
471 - /// Hook: ArticlePrepareTextForEdit
 516+ /**
 517+ * Hook: ArticlePrepareTextForEdit
 518+ * @param $article Article
 519+ * @param $popts ParserOptions
 520+ * @return bool
 521+ */
472522 public static function disablePreSaveTransform( $article, $popts ) {
473523 global $wgTranslateDocumentationLanguageCode;
474524
@@ -481,7 +531,12 @@
482532 return true;
483533 }
484534
485 - /// Hook: ArticleContentOnDiff
 535+ /**
 536+ * Hook: ArticleContentOnDiff
 537+ * @param $de DifferenceEngine
 538+ * @param $out OutputPage
 539+ * @return bool
 540+ */
486541 public static function displayOnDiff( $de, $out ) {
487542 $title = $de->getTitle();
488543 $handle = new MessageHandle( $title );
@@ -507,7 +562,11 @@
508563 return false;
509564 }
510565
511 - /// Hook: SpecialSearchProfiles
 566+ /**
 567+ * Hook: SpecialSearchProfiles
 568+ * @param $profiles array
 569+ * @return bool
 570+ */
512571 public static function searchProfile( &$profiles ) {
513572 global $wgTranslateMessageNamespaces;
514573 $insert = array();
@@ -521,7 +580,15 @@
522581 return true;
523582 }
524583
525 - /// Hook: SpecialSearchProfileForm
 584+ /**
 585+ * Hook: SpecialSearchProfileForm
 586+ * @param $search
 587+ * @param $form
 588+ * @param $profile
 589+ * @param $term
 590+ * @param $opts
 591+ * @return bool
 592+ */
526593 public static function searchProfileForm( $search, &$form, $profile, $term, $opts ) {
527594 if ( $profile !== 'translation' ) {
528595 return true;
@@ -568,7 +635,13 @@
569636 return false;
570637 }
571638
572 - /// Hook: SpecialSearchSetupEngine
 639+ /**
 640+ * Hook: SpecialSearchSetupEngine
 641+ * @param $search
 642+ * @param $profile
 643+ * @param $engine
 644+ * @return bool
 645+ */
573646 public static function searchProfileSetupEngine( $search, $profile, $engine ) {
574647 if ( $profile !== 'translation' ) {
575648 return true;
Index: trunk/extensions/Translate/TranslateHooks.php
@@ -63,7 +63,6 @@
6464 $wgLogActionsHandlers['pagetranslation/deletelnok'] = 'PageTranslationHooks::formatLogEntry';
6565 $wgLogActionsHandlers['pagetranslation/deletefnok'] = 'PageTranslationHooks::formatLogEntry';
6666
67 -
6867 global $wgJobClasses;
6968 $wgJobClasses['RenderJob'] = 'RenderJob';
7069 $wgJobClasses['MoveJob'] = 'MoveJob';
@@ -154,7 +153,11 @@
155154 return true;
156155 }
157156
158 - /// Hook: UnitTestsList
 157+ /**
 158+ * Hook: UnitTestsList
 159+ * @param $files array
 160+ * @return bool
 161+ */
159162 public static function setupUnitTests( &$files ) {
160163 $testDir = dirname( __FILE__ ) . '/tests/';
161164 $files[] = $testDir . 'MessageGroupBaseTest.php';
@@ -179,14 +182,17 @@
180183 return true;
181184 }
182185
183 - /// Hook: ParserTestTables
 186+ /**
 187+ * Hook: ParserTestTables
 188+ * @param $tables array
 189+ * @return bool
 190+ */
184191 public static function parserTestTables( &$tables ) {
185192 $tables[] = 'revtag';
186193 $tables[] = 'translate_groupstats';
187194 return true;
188195 }
189196
190 -
191197 /**
192198 * Set the right page content language for message group translations ("Page/xx").
193199 * Hook: PageContentLanguage
Index: trunk/extensions/Translate/TranslateTasks.php
@@ -102,11 +102,22 @@
103103 return false;
104104 }
105105
106 - protected $group; ///< \type{MessageGroup} Message group.
107 - protected $collection; ///< \type{MessageCollection} Messages.
108 - protected $options; ///< \type{TaskOptions} Options.
 106+ /**
 107+ * @var MessageGroup
 108+ */
 109+ protected $group;
109110
110111 /**
 112+ * @var MessageCollection Options
 113+ */
 114+ protected $collection;
 115+
 116+ /**
 117+ * @var TaskOptions Options
 118+ */
 119+ protected $options;
 120+
 121+ /**
111122 * Constructor.
112123 * @param $group \type{MessageGroup} Message group.
113124 * @param $options \type{TaskOptions} Options.
Index: trunk/extensions/Translate/utils/TranslationEditPage.php
@@ -46,6 +46,7 @@
4747
4848 /**
4949 * Change the title of the page we are working on.
 50+ * @param $title Title
5051 */
5152 public function setTitle( Title $title ) { $this->title = $title; }
5253 /**
Index: trunk/extensions/Translate/utils/UserToggles.php
@@ -46,6 +46,8 @@
4747 * Add 'translate-editlangs' preference.
4848 * These are the languages also shown when translating.
4949 *
 50+ * @param $user User
 51+ * @param $preferences array
5052 * @return \bool true
5153 */
5254 public static function translationAssistLanguages( $user, &$preferences ) {
@@ -73,6 +75,8 @@
7476 * Add 'translate-jsedit' preference.
7577 * An option to disable the javascript edit interface.
7678 *
 79+ * @param $user User
 80+ * @param $preferences array
7781 * @return \bool true
7882 */
7983 public static function translationJsedit( $user, &$preferences ) {
Index: trunk/extensions/Translate/utils/MessageWebImporter.php
@@ -439,6 +439,9 @@
440440 return array( 'translate-manage-import-fuzzy', "\n" . $text );
441441 }
442442
 443+ /**
 444+ * @return User
 445+ */
443446 public static function getFuzzyBot() {
444447 global $wgTranslateFuzzyBotName;
445448
Index: trunk/extensions/Translate/utils/Font.php
@@ -93,6 +93,9 @@
9494 return $chosen;
9595 }
9696
 97+ /**
 98+ * @return BagOStuff
 99+ */
97100 protected static function getCache() {
98101 return wfGetCache( CACHE_ANYTHING );
99102 }
Index: trunk/extensions/Translate/utils/StringMatcher.php
@@ -101,6 +101,10 @@
102102 }
103103 }
104104
 105+ /**
 106+ * @param $string string
 107+ * @return bool
 108+ */
105109 public function match( $string ) {
106110 if ( in_array( $string, $this->aExact ) ) {
107111 return true;
Index: trunk/extensions/Translate/utils/MessageGroupStats.php
@@ -186,8 +186,6 @@
187187 return $flattened;
188188 }
189189
190 -
191 -
192190 protected static function forGroupInternal( $group, $stats = array() ) {
193191 $id = $group->getId();
194192 $res = self::selectRowsIdLang( $id, null );
Index: trunk/extensions/Translate/utils/TranslateYaml.php
@@ -56,7 +56,11 @@
5757 return $base;
5858 }
5959
60 -
 60+ /**
 61+ * @param $text string
 62+ * @return array
 63+ * @throws MWException
 64+ */
6165 public static function loadString( $text ) {
6266 global $wgTranslateYamlLibrary;
6367
@@ -76,6 +80,10 @@
7781 }
7882 }
7983
 84+ /**
 85+ * @param $yaml array
 86+ * @return array
 87+ */
8088 public static function fixSyckBooleans( &$yaml ) {
8189 foreach ( $yaml as &$value ) {
8290 if ( is_array( $value ) ) {
@@ -87,6 +95,10 @@
8896 return $yaml;
8997 }
9098
 99+ /**
 100+ * @param $yaml array
 101+ * @return array
 102+ */
91103 public static function fixSpycSpaces( &$yaml ) {
92104 foreach ( $yaml as $key => &$value ) {
93105 if ( is_array( $value ) ) {
@@ -172,8 +184,8 @@
173185 'sub deutf8 {' .
174186 'if(ref($_[0]) eq "HASH") {' .
175187 'return { map { deutf8($_) } %{$_[0]} };' .
176 - '} elsif(ref($_[0]) eq "ARRAY") {' .
177 - 'return [ map { deutf8($_) } @{$_[0]} ];' .
 188+ '} elsif(ref($_[0]) eq "ARRAY") {' .
 189+ 'return [ map { deutf8($_) } @{$_[0]} ];' .
178190 '} else {' .
179191 'my $s = $_[0];' .
180192 'utf8::decode($s);' .
Index: trunk/extensions/Translate/utils/TranslationHelpers.php
@@ -226,6 +226,9 @@
227227 }
228228 }
229229
 230+ /**
 231+ * @return array
 232+ */
230233 public function getBoxNames() {
231234 return array(
232235 'other-languages' => array( $this, 'getOtherLanguagesBox' ),
@@ -323,6 +326,11 @@
324327 return $result;
325328 }
326329
 330+ /**
 331+ * @param $async bool
 332+ * @return null|string
 333+ * @throws MWException
 334+ */
327335 public function getSuggestionBox( $async = false ) {
328336 global $wgTranslateTranslationServices;
329337
Index: trunk/extensions/Translate/utils/MessageGroupCache.php
@@ -14,10 +14,17 @@
1515 * of the actual format.
1616 */
1717 class MessageGroupCache {
18 - /// \string
 18+
 19+ /**
 20+ * @var MessageGroup
 21+ */
1922 protected $group;
20 - /// CdbReader
 23+
 24+ /**
 25+ * @var CdbReader
 26+ */
2127 protected $cache;
 28+
2229 /// \string
2330 protected $code;
2431
Index: trunk/extensions/Translate/utils/HTMLJsSelectToInputField.php
@@ -11,6 +11,11 @@
1212 * Implementation of JsSelectToInput class which is extends HTMLTextField.
1313 */
1414 class HTMLJsSelectToInputField extends HTMLTextField {
 15+
 16+ /**
 17+ * @param $value
 18+ * @return string
 19+ */
1520 function getInputHTML( $value ) {
1621 $input = parent::getInputHTML( $value );
1722
@@ -21,6 +26,10 @@
2227 return $input;
2328 }
2429
 30+ /**
 31+ * @param $value
 32+ * @return array
 33+ */
2534 function tidy( $value ) {
2635 $value = array_map( 'trim', explode( ',', $value ) );
2736 $value = array_unique( array_filter( $value ) );
@@ -28,6 +37,11 @@
2938 return $value;
3039 }
3140
 41+ /**
 42+ * @param $value
 43+ * @param $alldata
 44+ * @return bool|String
 45+ */
3246 function validate( $value, $alldata ) {
3347 $p = parent::validate( $value, $alldata );
3448
@@ -55,6 +69,11 @@
5670 return true;
5771 }
5872
 73+ /**
 74+ * @param $value
 75+ * @param $alldata
 76+ * @return string
 77+ */
5978 function filter( $value, $alldata ) {
6079 $value = parent::filter( $value, $alldata );
6180 return implode( ', ', $this->tidy( $value ) );
Index: trunk/extensions/Translate/RcFilter.php
@@ -24,6 +24,10 @@
2525 * documentation of the function parameters.
2626 *
2727 * Appends SQL filter conditions into $conds.
 28+ * @param $conds array
 29+ * @param $tables array|stromg
 30+ * @param $join_conds array
 31+ * @param $opts
2832 * @return \bool true
2933 */
3034 public static function translationFilter( &$conds, &$tables, &$join_conds, $opts ) {

Comments

#Comment by Nikerabbit (talk | contribs)   17:26, 6 October 2011
+	/**
+	 * @return MediaWikiMessageChecker
+	 */
 	public function getChecker() {

I'd argue it's implementation detail what kind of MessageChecker it returns.

+	 * @param $tables array|stromg

omg?


I don't see the point of documenting params of hook functions.

Status & tagging log