http://www.mediawiki.org/wiki/Special:Code/MediaWiki/98645
Revision: 98645 Author: reedy Date: 2011-10-01 23:27:42 +0000 (Sat, 01 Oct 2011) Log Message: ----------- Moar documentations Modified Paths: -------------- trunk/extensions/Translate/FFS.php trunk/extensions/Translate/TranslateEditAddons.php trunk/extensions/Translate/specials/SpecialMagic.php trunk/extensions/Translate/tag/RenderJob.php trunk/extensions/Translate/utils/Font.php trunk/extensions/Translate/utils/RevTag.php trunk/extensions/Translate/utils/TranslateYaml.php trunk/extensions/Translate/utils/TranslationHelpers.php trunk/extensions/Translate/utils/TranslationMemoryUpdater.php Modified: trunk/extensions/Translate/FFS.php =================================================================== --- trunk/extensions/Translate/FFS.php 2011-10-01 23:25:19 UTC (rev 98644) +++ trunk/extensions/Translate/FFS.php 2011-10-01 23:27:42 UTC (rev 98645) @@ -73,7 +73,12 @@ * @ingroup FFS */ class SimpleFFS implements FFS { + + /** + * @var FileBasedMessageGroup + */ protected $group; + protected $writePath; protected $extra; @@ -83,12 +88,30 @@ $this->extra = $conf['FILES']; } + /** + * @param $group FileBasedMessageGroup + */ public function setGroup( FileBasedMessageGroup $group ) { $this->group = $group; } + + /** + * @return FileBasedMessageGroup + */ public function getGroup() { return $this->group; } + /** + * @param $writePath string + */ public function setWritePath( $writePath ) { $this->writePath = $writePath; } + + /** + * @return string + */ public function getWritePath() { return $this->writePath; } + /** + * @param $code string|bool + * @return bool + */ public function exists( $code = false ) { if ( $code === false ) { $code = $this->group->getSourceLanguage(); @@ -106,6 +129,11 @@ return true; } + /** + * @param $code string + * @return array|bool + * @throws MWException + */ public function read( $code ) { if ( !$this->exists( $code ) ) { return false; @@ -120,6 +148,11 @@ return $this->readFromVariable( $input ); } + /** + * @param $data array + * @return array + * @throws MWException + */ public function readFromVariable( $data ) { $parts = explode( "\0\0\0\0", $data ); @@ -155,6 +188,9 @@ ); } + /** + * @param $collection MessageCollection + */ public function write( MessageCollection $collection ) { $writePath = $this->writePath; @@ -186,6 +222,10 @@ } } + /** + * @param $collection MessageCollection + * @return + */ public function writeIntoVariable( MessageCollection $collection ) { $sourceFile = $this->group->getSourceFilePath( $collection->code ); $this->tryReadSource( $sourceFile, $collection ); @@ -193,6 +233,10 @@ return $this->writeReal( $collection ); } + /** + * @param $collection MessageCollection + * @return string + */ protected function writeReal( MessageCollection $collection ) { $output = ''; @@ -212,6 +256,10 @@ return $output; } + /** + * @param $filename string + * @param $collection MessageCollection + */ protected function tryReadSource( $filename, $collection ) { $sourceText = $this->tryReadFile( $filename ); @@ -224,6 +272,11 @@ } } + /** + * @param $filename string + * @return bool|string + * @throws MWException + */ protected function tryReadFile( $filename ) { if ( !$filename ) { return false; @@ -245,6 +298,11 @@ return $data; } + /** + * @param $authors array + * @param $code string + * @return array + */ protected function filterAuthors( array $authors, $code ) { global $wgTranslateAuthorBlacklist; $groupId = $this->group->getId(); @@ -274,6 +332,10 @@ return $authors; } + /** + * @param $data string + * @return string + */ public static function fixNewLines( $data ) { $data = str_replace( "\r\n", "\n", $data ); $data = str_replace( "\r", "\n", $data ); @@ -294,6 +356,9 @@ class JavaFFS extends SimpleFFS { protected $keySeparator = '='; + /** + * @param $group FileBasedMessageGroup + */ public function __construct( FileBasedMessageGroup $group ) { parent::__construct( $group ); @@ -304,12 +369,18 @@ // READ + /** + * @param $data array + * @return array + * @throws MWException + */ public function readFromVariable( $data ) { $data = self::fixNewLines( $data ); $lines = array_map( 'ltrim', explode( "\n", $data ) ); $authors = $messages = array(); $linecontinuation = false; + $value = ''; foreach ( $lines as $line ) { if ( $linecontinuation ) { $linecontinuation = false; @@ -364,6 +435,10 @@ // Write + /** + * @param $collection MessageCollection + * @return string + */ protected function writeReal( MessageCollection $collection ) { $header = $this->doHeader( $collection ); $header .= $this->doAuthors( $collection ); @@ -397,6 +472,10 @@ } } + /** + * @param $collection MessageCollection + * @return string + */ protected function doHeader( MessageCollection $collection ) { if ( isset( $this->extra['header'] ) ) { $output = $this->extra['header']; @@ -413,6 +492,10 @@ return $output; } + /** + * @param $collection MessageCollection + * @return string + */ protected function doAuthors( MessageCollection $collection ) { $output = ''; $authors = $collection->getAuthors(); @@ -433,11 +516,18 @@ abstract class JavaScriptFFS extends SimpleFFS { /** * Message keys format. + * + * @param $string + * + * @return string */ abstract protected function transformKey( $key ); /** * Header of message file. + * + * @param $code string + * @param $authors array */ abstract protected function header( $code, $authors ); @@ -446,6 +536,10 @@ */ abstract protected function footer(); + /** + * @param $data array + * @return array + */ public function readFromVariable( $data ) { /* Parse authors list */ $authors = preg_replace( "#/\* Translators\:\n(.*?)\n \*/(.*)#s", '$1', $data ); @@ -543,6 +637,10 @@ ); } + /** + * @param $collection MessageCollection + * @return string + */ public function writeReal( MessageCollection $collection ) { $header = $this->header( $collection->code, $collection->getAuthors() ); @@ -578,6 +676,10 @@ return $header . $body . $this->footer(); } + /** + * @param $authors array + * @return string + */ protected function authorsList( $authors ) { if ( count( $authors ) === 0 ) { return ''; @@ -594,6 +696,10 @@ return substr( " * Translators:\n$authorsList", 0, -1 ); } + /** + * @param $string string + * @return string + */ protected static function unescapeJsString( $string ) { // See ECMA 262 section 7.8.4 for string literal format $pairs = array( @@ -631,10 +737,20 @@ * @ingroup FFS */ class OpenLayersFFS extends JavaScriptFFS { + + /** + * @param $key string + * @return string + */ protected function transformKey( $key ) { return "'$key'"; } + /** + * @param $code string + * @param $authors array + * @return string + */ protected function header( $code, $authors ) { $names = Language::getLanguageNames(); $name = $names[ $code ]; @@ -665,6 +781,9 @@ /** @endcond */ } + /** + * @return string + */ protected function footer() { return "});\n"; } @@ -675,10 +794,21 @@ * @ingroup FFS */ class ShapadoJsFFS extends JavaScriptFFS { + + /** + * @param $key string + * + * @return string + */ protected function transformKey( $key ) { return $key; } + /** + * @param $code string + * @param $authors array + * @return string + */ protected function header( $code, $authors ) { global $wgSitename; @@ -700,6 +830,9 @@ /** @endcond */ } + /** + * @return string + */ protected function footer() { return "};\n\n"; } @@ -714,6 +847,10 @@ */ class YamlFFS extends SimpleFFS { + /** + * @param $data + * @return array + */ public function readFromVariable( $data ) { // Authors first. $matches = array(); @@ -740,6 +877,10 @@ ); } + /** + * @param $collection MessageCollection + * @return string + */ protected function writeReal( MessageCollection $collection ) { $output = $this->doHeader( $collection ); $output .= $this->doAuthors( $collection ); @@ -775,6 +916,10 @@ return $output; } + /** + * @param $collection MessageCollection + * @return string + */ protected function doHeader( MessageCollection $collection ) { global $wgSitename; global $wgTranslateYamlLibrary; @@ -792,6 +937,10 @@ return $output; } + /** + * @param $collection MessageCollection + * @return string + */ protected function doAuthors( MessageCollection $collection ) { $output = ''; $authors = $collection->getAuthors(); @@ -807,6 +956,10 @@ /** * Flattens multidimensional array by using the path to the value as key * with each individual key separated by a dot. + * + * @param $messages array + * + * @return array */ protected function flatten( $messages ) { $flat = true; @@ -816,7 +969,8 @@ continue; } - $flat = false; break; + $flat = false; + break; } if ( $flat ) { @@ -852,6 +1006,10 @@ /** * Performs the reverse operation of flatten. Each dot in the key starts a * new subarray in the final array. + * + * @param $messages array + * + * @return array */ protected function unflatten( $messages ) { $array = array(); @@ -902,13 +1060,21 @@ return $array; } + /** + * @param $value + * @return bool + */ public function flattenPlural( $value ) { return false; } /** * Override this. Return false to skip processing this value. Otherwise - * return array with keys and values. + * + * @param $key string + * @param $value string + * + * @return array with keys and values. */ public function unflattenPlural( $key, $value ) { return array( $key => $value ); @@ -933,6 +1099,10 @@ /** * Flattens ruby plural arrays into special plural syntax. + * + * @param $messages array + * + * @return bool|string */ public function flattenPlural( $messages ) { @@ -966,6 +1136,11 @@ /** * Converts the special plural syntax to array or ruby style plurals + * + * @param $key string + * @param $message string + * + * @return bool|array */ public function unflattenPlural( $key, $message ) { // Quick escape. @@ -1053,6 +1228,9 @@ return $alts; } + /** + * @return string + */ protected function placeholder() { static $i = 0; @@ -1068,6 +1246,10 @@ private $fw = null; static $data = null; + /** + * @param $code + * @return array + */ public function read( $code ) { // TODO: Improve this code to not use static variables. if ( !isset( self::$data[$this->group->getId()] ) ) { @@ -1091,6 +1273,9 @@ return array( 'MESSAGES' => self::$data[$this->group->getId()][$code] ); } + /** + * @param $collection MessageCollection + */ public function write( MessageCollection $collection ) { if ( $this->fw === null ) { $sourceLanguage = $this->group->getSourceLanguage(); @@ -1124,6 +1309,10 @@ fwrite( $this->fw, "\t},\n" ); } + /** + * @param $collection MessageCollection + * @return string + */ public function writeIntoVariable( MessageCollection $collection ) { return <<<PHP # -*- coding: utf-8 -*- @@ -1134,6 +1323,10 @@ PHP; } + /** + * @param $collection MessageCollection + * @return string + */ protected function writeBlock( MessageCollection $collection ) { $block = ''; $messages = array(); @@ -1160,6 +1353,10 @@ return $block; } + /** + * @param $collection MessageCollection + * @return string + */ protected function doAuthors( MessageCollection $collection ) { $output = ''; Modified: trunk/extensions/Translate/TranslateEditAddons.php =================================================================== --- trunk/extensions/Translate/TranslateEditAddons.php 2011-10-01 23:25:19 UTC (rev 98644) +++ trunk/extensions/Translate/TranslateEditAddons.php 2011-10-01 23:27:42 UTC (rev 98645) @@ -22,6 +22,8 @@ * Hooks: SkinTemplateNavigation, SkinTemplateTabs * @param $skin Skin * @param $tabs Array + * + * @return bool */ static function addNavigationTabs( $skin, &$tabs ) { global $wgRequest; Modified: trunk/extensions/Translate/specials/SpecialMagic.php =================================================================== --- trunk/extensions/Translate/specials/SpecialMagic.php 2011-10-01 23:25:19 UTC (rev 98644) +++ trunk/extensions/Translate/specials/SpecialMagic.php 2011-10-01 23:27:42 UTC (rev 98645) @@ -42,6 +42,8 @@ /** * @see SpecialPage::getDescription + * + * @return string */ function getDescription() { return wfMsg( 'translate-magic-pagename' ); Modified: trunk/extensions/Translate/tag/RenderJob.php =================================================================== --- trunk/extensions/Translate/tag/RenderJob.php 2011-10-01 23:25:19 UTC (rev 98644) +++ trunk/extensions/Translate/tag/RenderJob.php 2011-10-01 23:27:42 UTC (rev 98645) @@ -14,6 +14,11 @@ * @ingroup PageTranslation JobQueue */ class RenderJob extends Job { + + /** + * @param $target Title + * @return RenderJob + */ public static function newJob( Title $target ) { global $wgTranslateFuzzyBotName; @@ -87,6 +92,9 @@ return $this->params['summary']; } + /** + * @param $user User + */ public function setUser( $user ) { if ( $user instanceof User ) { $this->params['user'] = $user->getName(); @@ -97,6 +105,8 @@ /** * Get a user object for doing edits. + * + * @return User */ public function getUser() { return User::newFromName( $this->params['user'], false ); Modified: trunk/extensions/Translate/utils/Font.php =================================================================== --- trunk/extensions/Translate/utils/Font.php 2011-10-01 23:25:19 UTC (rev 98644) +++ trunk/extensions/Translate/utils/Font.php 2011-10-01 23:27:42 UTC (rev 98645) @@ -19,6 +19,8 @@ /** * Searches for suitable font in the system. * @param $code \string Language code. + * + * @return bool|string */ public static function find( $code ) { if ( ini_get( 'open_basedir' ) ) { Modified: trunk/extensions/Translate/utils/RevTag.php =================================================================== --- trunk/extensions/Translate/utils/RevTag.php 2011-10-01 23:25:19 UTC (rev 98644) +++ trunk/extensions/Translate/utils/RevTag.php 2011-10-01 23:27:42 UTC (rev 98645) @@ -16,6 +16,8 @@ /** * Determines the schema version. + * + * @return int */ public static function checkSchema() { if ( self::$schema !== false ) { @@ -33,7 +35,7 @@ /** * Returns value suitable for rt_type field. * @param $tag string tag name - * return int|string + * @return int|string */ public static function getType( $tag ) { if ( self::checkSchema() === 2 ) { Modified: trunk/extensions/Translate/utils/TranslateYaml.php =================================================================== --- trunk/extensions/Translate/utils/TranslateYaml.php 2011-10-01 23:25:19 UTC (rev 98644) +++ trunk/extensions/Translate/utils/TranslateYaml.php 2011-10-01 23:27:42 UTC (rev 98645) @@ -41,6 +41,9 @@ /** * Merges a document template (base) to actual definition (specific) + * @param $base + * @param $specific + * @return array */ public static function mergeTemplate( $base, $specific ) { foreach ( $specific as $key => $value ) { Modified: trunk/extensions/Translate/utils/TranslationHelpers.php =================================================================== --- trunk/extensions/Translate/utils/TranslationHelpers.php 2011-10-01 23:25:19 UTC (rev 98644) +++ trunk/extensions/Translate/utils/TranslationHelpers.php 2011-10-01 23:27:42 UTC (rev 98645) @@ -1145,7 +1145,8 @@ protected static $serviceFailurePeriod = 900; /** - * Checks whether the given service has exceeded failure count */ + * Checks whether the given service has exceeded failure count + */ public static function checkTranslationServiceFailure( $service ) { global $wgMemc; @@ -1197,6 +1198,9 @@ } } + /** + * @param $out OutputPage + */ public static function addModules( OutputPage $out ) { $out->addModules( 'ext.translate.quickedit' ); Modified: trunk/extensions/Translate/utils/TranslationMemoryUpdater.php =================================================================== --- trunk/extensions/Translate/utils/TranslationMemoryUpdater.php 2011-10-01 23:25:19 UTC (rev 98644) +++ trunk/extensions/Translate/utils/TranslationMemoryUpdater.php 2011-10-01 23:27:42 UTC (rev 98645) @@ -15,6 +15,13 @@ /** * Shovels the new translation into translation memory. * Hook: Translate:newTranslation + * + * @param $handle MessageHandle + * @param $revision + * @param $text string + * @param $user User + * + * @return bool */ public static function update( MessageHandle $handle, $revision, $text, User $user ) { global $wgContLang; _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs