r113576 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113575‎ | r113576 | r113577 >
Date:17:26, 11 March 2012
Author:reedy
Status:ok
Tags:
Comment:
Flesh out most of the rest of the documentation
Modified paths:
  • /trunk/extensions/LuaFoo/includes/Converter.php (modified) (history)

Diff [purge]

Index: trunk/extensions/LuaFoo/includes/Converter.php
@@ -26,7 +26,7 @@
2727
2828 /**
2929 * @param $title Title
30 - * @param $language
 30+ * @param $language string
3131 * @return string
3232 */
3333 static function convert( $title, $language ) {
@@ -35,6 +35,9 @@
3636 return $code->toString();
3737 }
3838
 39+ /**
 40+ * @param $language string
 41+ */
3942 protected function __construct( $language ) {
4043 $this->parser = new Parser;
4144 $this->preprocessor = new Preprocessor_Hash( $this->parser );
@@ -139,6 +142,10 @@
140143 }
141144 }
142145
 146+ /**
 147+ * @param $expr LuaFoo_Converter_Expression
 148+ * @param $direction string
 149+ */
143150 protected function trimConcat( $expr, $direction ) {
144151 while ( count( $expr->args ) ) {
145152 if ( $direction == 'left' ) {
@@ -168,8 +175,8 @@
169176 }
170177
171178 /**
172 - * @param $expr
173 - * @param $deps
 179+ * @param $expr LuaFoo_Converter_Expression
 180+ * @param $deps LuaFoo_Converter_Deps
174181 * @return LuaFoo_Converter_Expression
175182 */
176183 function newTrim( $expr, $deps ) {
@@ -197,9 +204,9 @@
198205 }
199206
200207 /**
201 - * @param $name
202 - * @param $args
203 - * @param $deps
 208+ * @param $name string
 209+ * @param $args array
 210+ * @param $deps LuaFoo_Converter_Deps
204211 * @return LuaFoo_Converter_Expression
205212 */
206213 function newParserFunctionCall( $name, $args, $deps ) {
@@ -227,7 +234,6 @@
228235 * @return mixed|string
229236 */
230237 function titleToIdentifier( $title ) {
231 - $id = '';
232238 if ( $title->getNamespace() == NS_TEMPLATE ) {
233239 $id = 'tpl_';
234240 } elseif ( $title->getNamespace() == NS_MAIN ) {
@@ -273,7 +279,7 @@
274280
275281 /**
276282 * @param $contextNode PPNode_Hash_Array|PPNode_Hash_Attr|PPNode_Hash_Text|PPNode_Hash_Tree
277 - * @param $deps
 283+ * @param $deps LuaFoo_Converter_Deps
278284 * @return LuaFoo_Converter_Expression|mixed
279285 * @throws MWException
280286 */
@@ -318,7 +324,7 @@
319325
320326 /**
321327 * @param $bits
322 - * @param $deps
 328+ * @param $deps LuaFoo_Converter_Deps
323329 * @return LuaFoo_Converter_Expression|mixed
324330 */
325331 function expandTemplate( $bits, $deps ) {
@@ -431,8 +437,8 @@
432438 }
433439
434440 /**
435 - * @param $piece
436 - * @param $deps
 441+ * @param $piece array
 442+ * @param $deps LuaFoo_Converter_Deps
437443 * @return LuaFoo_Converter_Expression
438444 */
439445 function expandTemplateArg( $piece, $deps ) {
@@ -466,7 +472,7 @@
467473
468474 /**
469475 * @param $args
470 - * @param $deps
 476+ * @param $deps LuaFoo_Converter_Deps
471477 * @return LuaFoo_Converter_Expression
472478 */
473479 function pfunc_if( $args, $deps ) {
@@ -499,6 +505,9 @@
500506 var $converter;
501507 var $runtimeBlocks;
502508
 509+ /**
 510+ * @param $converter
 511+ */
503512 function __construct( $converter ) {
504513 $this->converter = $converter;
505514 }
@@ -520,6 +529,8 @@
521530
522531 /**
523532 * @param $name
 533+ *
 534+ * @return LuaFoo_Converter_Block
524535 */
525536 function getRuntimeBlock( $name ) {
526537 if ( $this->runtimeBlocks === null ) {
@@ -831,7 +842,7 @@
832843 }
833844
834845 $currentBlock->addItem( $line );
835 - }
 846+ }
836847 }
837848
838849 /**
@@ -864,6 +875,9 @@
865876 class LuaFoo_Converter_Block {
866877 var $items = array(), $exprString = '', $language;
867878
 879+ /**
 880+ * @param $language
 881+ */
868882 function __construct( $language ) {
869883 $this->language = $language;
870884 }
@@ -875,18 +889,30 @@
876890 }
877891 }
878892
 893+ /**
 894+ * @param $item
 895+ */
879896 function prependItem( $item ) {
880897 array_unshift( $this->items, $item );
881898 }
882899
 900+ /**
 901+ * @param $item
 902+ */
883903 function addItem( $item ) {
884904 $this->items[] = $item;
885905 }
886906
 907+ /**
 908+ * @param $block
 909+ */
887910 function addBlock( $block ) {
888911 $this->addItems( $block->items );
889912 }
890913
 914+ /**
 915+ * @param $expr string
 916+ */
891917 function setExpressionString( $expr ) {
892918 $this->exprString = $expr;
893919 }
@@ -957,6 +983,10 @@
958984 var $language;
959985 var $variablesByHash = array();
960986
 987+ /**
 988+ * @param $language
 989+ * @param $seed string
 990+ */
961991 function __construct( $language, $seed ) {
962992 $this->language = $language;
963993 srand( crc32( $seed ) );
@@ -984,7 +1014,7 @@
9851015 }
9861016
9871017 /**
988 - * @param $expr
 1018+ * @param $expr LuaFoo_Converter_Expression
9891019 * @return bool
9901020 */
9911021 public function getVariable( $expr ) {
@@ -996,15 +1026,25 @@
9971027 }
9981028 }
9991029
 1030+ /**
 1031+ * @param $var
 1032+ * @param $expr LuaFoo_Converter_Expression
 1033+ */
10001034 public function setVariableHash( $var, $expr ) {
10011035 $hash = $expr->getHash();
10021036 $this->variablesByHash[$hash] = $var;
10031037 }
10041038
 1039+ /**
 1040+ * @return mixed
 1041+ */
10051042 protected function getRandomVowel() {
10061043 return self::$vowels[ rand( 0, strlen( self::$vowels ) - 1 ) ];
10071044 }
10081045
 1046+ /**
 1047+ * @return mixed
 1048+ */
10091049 protected function getRandomConsonant() {
10101050 return self::$consonants[ rand( 0, strlen( self::$consonants ) - 1 ) ];
10111051 }
@@ -1014,18 +1054,30 @@
10151055 var $titleTexts = array();
10161056 var $functions = array();
10171057
 1058+ /**
 1059+ * @param $t string
 1060+ */
10181061 function addTemplate( $t ) {
10191062 $this->titleTexts[$t] = true;
10201063 }
10211064
 1065+ /**
 1066+ * @param $name string
 1067+ */
10221068 function addFunction( $name ) {
10231069 $this->functions[$name] = true;
10241070 }
10251071
 1072+ /**
 1073+ * @return array
 1074+ */
10261075 function getTemplates() {
10271076 return array_keys( $this->titleTexts );
10281077 }
10291078
 1079+ /**
 1080+ * @return array
 1081+ */
10301082 function getFunctions() {
10311083 return array_keys( $this->functions );
10321084 }

Status & tagging log