Index: trunk/extensions/LuaFoo/includes/Converter.php |
— | — | @@ -26,7 +26,7 @@ |
27 | 27 | |
28 | 28 | /** |
29 | 29 | * @param $title Title |
30 | | - * @param $language |
| 30 | + * @param $language string |
31 | 31 | * @return string |
32 | 32 | */ |
33 | 33 | static function convert( $title, $language ) { |
— | — | @@ -35,6 +35,9 @@ |
36 | 36 | return $code->toString(); |
37 | 37 | } |
38 | 38 | |
| 39 | + /** |
| 40 | + * @param $language string |
| 41 | + */ |
39 | 42 | protected function __construct( $language ) { |
40 | 43 | $this->parser = new Parser; |
41 | 44 | $this->preprocessor = new Preprocessor_Hash( $this->parser ); |
— | — | @@ -139,6 +142,10 @@ |
140 | 143 | } |
141 | 144 | } |
142 | 145 | |
| 146 | + /** |
| 147 | + * @param $expr LuaFoo_Converter_Expression |
| 148 | + * @param $direction string |
| 149 | + */ |
143 | 150 | protected function trimConcat( $expr, $direction ) { |
144 | 151 | while ( count( $expr->args ) ) { |
145 | 152 | if ( $direction == 'left' ) { |
— | — | @@ -168,8 +175,8 @@ |
169 | 176 | } |
170 | 177 | |
171 | 178 | /** |
172 | | - * @param $expr |
173 | | - * @param $deps |
| 179 | + * @param $expr LuaFoo_Converter_Expression |
| 180 | + * @param $deps LuaFoo_Converter_Deps |
174 | 181 | * @return LuaFoo_Converter_Expression |
175 | 182 | */ |
176 | 183 | function newTrim( $expr, $deps ) { |
— | — | @@ -197,9 +204,9 @@ |
198 | 205 | } |
199 | 206 | |
200 | 207 | /** |
201 | | - * @param $name |
202 | | - * @param $args |
203 | | - * @param $deps |
| 208 | + * @param $name string |
| 209 | + * @param $args array |
| 210 | + * @param $deps LuaFoo_Converter_Deps |
204 | 211 | * @return LuaFoo_Converter_Expression |
205 | 212 | */ |
206 | 213 | function newParserFunctionCall( $name, $args, $deps ) { |
— | — | @@ -227,7 +234,6 @@ |
228 | 235 | * @return mixed|string |
229 | 236 | */ |
230 | 237 | function titleToIdentifier( $title ) { |
231 | | - $id = ''; |
232 | 238 | if ( $title->getNamespace() == NS_TEMPLATE ) { |
233 | 239 | $id = 'tpl_'; |
234 | 240 | } elseif ( $title->getNamespace() == NS_MAIN ) { |
— | — | @@ -273,7 +279,7 @@ |
274 | 280 | |
275 | 281 | /** |
276 | 282 | * @param $contextNode PPNode_Hash_Array|PPNode_Hash_Attr|PPNode_Hash_Text|PPNode_Hash_Tree |
277 | | - * @param $deps |
| 283 | + * @param $deps LuaFoo_Converter_Deps |
278 | 284 | * @return LuaFoo_Converter_Expression|mixed |
279 | 285 | * @throws MWException |
280 | 286 | */ |
— | — | @@ -318,7 +324,7 @@ |
319 | 325 | |
320 | 326 | /** |
321 | 327 | * @param $bits |
322 | | - * @param $deps |
| 328 | + * @param $deps LuaFoo_Converter_Deps |
323 | 329 | * @return LuaFoo_Converter_Expression|mixed |
324 | 330 | */ |
325 | 331 | function expandTemplate( $bits, $deps ) { |
— | — | @@ -431,8 +437,8 @@ |
432 | 438 | } |
433 | 439 | |
434 | 440 | /** |
435 | | - * @param $piece |
436 | | - * @param $deps |
| 441 | + * @param $piece array |
| 442 | + * @param $deps LuaFoo_Converter_Deps |
437 | 443 | * @return LuaFoo_Converter_Expression |
438 | 444 | */ |
439 | 445 | function expandTemplateArg( $piece, $deps ) { |
— | — | @@ -466,7 +472,7 @@ |
467 | 473 | |
468 | 474 | /** |
469 | 475 | * @param $args |
470 | | - * @param $deps |
| 476 | + * @param $deps LuaFoo_Converter_Deps |
471 | 477 | * @return LuaFoo_Converter_Expression |
472 | 478 | */ |
473 | 479 | function pfunc_if( $args, $deps ) { |
— | — | @@ -499,6 +505,9 @@ |
500 | 506 | var $converter; |
501 | 507 | var $runtimeBlocks; |
502 | 508 | |
| 509 | + /** |
| 510 | + * @param $converter |
| 511 | + */ |
503 | 512 | function __construct( $converter ) { |
504 | 513 | $this->converter = $converter; |
505 | 514 | } |
— | — | @@ -520,6 +529,8 @@ |
521 | 530 | |
522 | 531 | /** |
523 | 532 | * @param $name |
| 533 | + * |
| 534 | + * @return LuaFoo_Converter_Block |
524 | 535 | */ |
525 | 536 | function getRuntimeBlock( $name ) { |
526 | 537 | if ( $this->runtimeBlocks === null ) { |
— | — | @@ -831,7 +842,7 @@ |
832 | 843 | } |
833 | 844 | |
834 | 845 | $currentBlock->addItem( $line ); |
835 | | - } |
| 846 | + } |
836 | 847 | } |
837 | 848 | |
838 | 849 | /** |
— | — | @@ -864,6 +875,9 @@ |
865 | 876 | class LuaFoo_Converter_Block { |
866 | 877 | var $items = array(), $exprString = '', $language; |
867 | 878 | |
| 879 | + /** |
| 880 | + * @param $language |
| 881 | + */ |
868 | 882 | function __construct( $language ) { |
869 | 883 | $this->language = $language; |
870 | 884 | } |
— | — | @@ -875,18 +889,30 @@ |
876 | 890 | } |
877 | 891 | } |
878 | 892 | |
| 893 | + /** |
| 894 | + * @param $item |
| 895 | + */ |
879 | 896 | function prependItem( $item ) { |
880 | 897 | array_unshift( $this->items, $item ); |
881 | 898 | } |
882 | 899 | |
| 900 | + /** |
| 901 | + * @param $item |
| 902 | + */ |
883 | 903 | function addItem( $item ) { |
884 | 904 | $this->items[] = $item; |
885 | 905 | } |
886 | 906 | |
| 907 | + /** |
| 908 | + * @param $block |
| 909 | + */ |
887 | 910 | function addBlock( $block ) { |
888 | 911 | $this->addItems( $block->items ); |
889 | 912 | } |
890 | 913 | |
| 914 | + /** |
| 915 | + * @param $expr string |
| 916 | + */ |
891 | 917 | function setExpressionString( $expr ) { |
892 | 918 | $this->exprString = $expr; |
893 | 919 | } |
— | — | @@ -957,6 +983,10 @@ |
958 | 984 | var $language; |
959 | 985 | var $variablesByHash = array(); |
960 | 986 | |
| 987 | + /** |
| 988 | + * @param $language |
| 989 | + * @param $seed string |
| 990 | + */ |
961 | 991 | function __construct( $language, $seed ) { |
962 | 992 | $this->language = $language; |
963 | 993 | srand( crc32( $seed ) ); |
— | — | @@ -984,7 +1014,7 @@ |
985 | 1015 | } |
986 | 1016 | |
987 | 1017 | /** |
988 | | - * @param $expr |
| 1018 | + * @param $expr LuaFoo_Converter_Expression |
989 | 1019 | * @return bool |
990 | 1020 | */ |
991 | 1021 | public function getVariable( $expr ) { |
— | — | @@ -996,15 +1026,25 @@ |
997 | 1027 | } |
998 | 1028 | } |
999 | 1029 | |
| 1030 | + /** |
| 1031 | + * @param $var |
| 1032 | + * @param $expr LuaFoo_Converter_Expression |
| 1033 | + */ |
1000 | 1034 | public function setVariableHash( $var, $expr ) { |
1001 | 1035 | $hash = $expr->getHash(); |
1002 | 1036 | $this->variablesByHash[$hash] = $var; |
1003 | 1037 | } |
1004 | 1038 | |
| 1039 | + /** |
| 1040 | + * @return mixed |
| 1041 | + */ |
1005 | 1042 | protected function getRandomVowel() { |
1006 | 1043 | return self::$vowels[ rand( 0, strlen( self::$vowels ) - 1 ) ]; |
1007 | 1044 | } |
1008 | 1045 | |
| 1046 | + /** |
| 1047 | + * @return mixed |
| 1048 | + */ |
1009 | 1049 | protected function getRandomConsonant() { |
1010 | 1050 | return self::$consonants[ rand( 0, strlen( self::$consonants ) - 1 ) ]; |
1011 | 1051 | } |
— | — | @@ -1014,18 +1054,30 @@ |
1015 | 1055 | var $titleTexts = array(); |
1016 | 1056 | var $functions = array(); |
1017 | 1057 | |
| 1058 | + /** |
| 1059 | + * @param $t string |
| 1060 | + */ |
1018 | 1061 | function addTemplate( $t ) { |
1019 | 1062 | $this->titleTexts[$t] = true; |
1020 | 1063 | } |
1021 | 1064 | |
| 1065 | + /** |
| 1066 | + * @param $name string |
| 1067 | + */ |
1022 | 1068 | function addFunction( $name ) { |
1023 | 1069 | $this->functions[$name] = true; |
1024 | 1070 | } |
1025 | 1071 | |
| 1072 | + /** |
| 1073 | + * @return array |
| 1074 | + */ |
1026 | 1075 | function getTemplates() { |
1027 | 1076 | return array_keys( $this->titleTexts ); |
1028 | 1077 | } |
1029 | 1078 | |
| 1079 | + /** |
| 1080 | + * @return array |
| 1081 | + */ |
1030 | 1082 | function getFunctions() { |
1031 | 1083 | return array_keys( $this->functions ); |
1032 | 1084 | } |