Add missing `@param`s to `src/wp-includes/pomo` files.

See #30224.


Built from https://develop.svn.wordpress.org/trunk@30663


git-svn-id: http://core.svn.wordpress.org/trunk@30653 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2014-11-30 21:41:22 +00:00
parent 616c5515ce
commit b35cbbfac7
5 changed files with 114 additions and 6 deletions

View File

@ -139,6 +139,9 @@ class MO extends Gettext_Translations {
} }
} }
/**
* @param POMO_FileReader $reader
*/
function import_from_reader($reader) { function import_from_reader($reader) {
$endian_string = MO::get_byteorder($reader->readint32()); $endian_string = MO::get_byteorder($reader->readint32());
if (false === $endian_string) { if (false === $endian_string) {

View File

@ -189,8 +189,8 @@ class PO extends Gettext_Translations {
* Builds a string from the entry for inclusion in PO file * Builds a string from the entry for inclusion in PO file
* *
* @static * @static
* @param object &$entry the entry to convert to po string * @param Translation_Entry &$entry the entry to convert to po string
* @return string|bool PO-style formatted string for the entry or * @return false|string PO-style formatted string for the entry or
* false if the entry is empty * false if the entry is empty
*/ */
function export_entry(&$entry) { function export_entry(&$entry) {
@ -215,6 +215,10 @@ class PO extends Gettext_Translations {
return implode("\n", $po); return implode("\n", $po);
} }
/**
* @param string $filename
* @return boolean
*/
function import_from_file($filename) { function import_from_file($filename) {
$f = fopen($filename, 'r'); $f = fopen($filename, 'r');
if (!$f) return false; if (!$f) return false;
@ -238,6 +242,11 @@ class PO extends Gettext_Translations {
return true; return true;
} }
/**
* @param resource $f
* @param int $lineno
* @return null|false|array
*/
function read_entry($f, $lineno = 0) { function read_entry($f, $lineno = 0) {
$entry = new Translation_Entry(); $entry = new Translation_Entry();
// where were we in the last step // where were we in the last step
@ -343,6 +352,13 @@ class PO extends Gettext_Translations {
return array('entry' => $entry, 'lineno' => $lineno); return array('entry' => $entry, 'lineno' => $lineno);
} }
/**
* @staticvar string $last_line
* @staticvar boolean $use_last_line
* @param resource $f
* @param string $action
* @return boolean
*/
function read_line($f, $action = 'read') { function read_line($f, $action = 'read') {
static $last_line = ''; static $last_line = '';
static $use_last_line = false; static $use_last_line = false;
@ -361,6 +377,10 @@ class PO extends Gettext_Translations {
return $line; return $line;
} }
/**
* @param Translation_Entry $entry
* @param string $po_comment_line
*/
function add_comment_to_entry(&$entry, $po_comment_line) { function add_comment_to_entry(&$entry, $po_comment_line) {
$first_two = substr($po_comment_line, 0, 2); $first_two = substr($po_comment_line, 0, 2);
$comment = trim(substr($po_comment_line, 2)); $comment = trim(substr($po_comment_line, 2));
@ -375,6 +395,10 @@ class PO extends Gettext_Translations {
} }
} }
/**
* @param string $s
* @return sring
*/
function trim_quotes($s) { function trim_quotes($s) {
if ( substr($s, 0, 1) == '"') $s = substr($s, 1); if ( substr($s, 0, 1) == '"') $s = substr($s, 1);
if ( substr($s, -1, 1) == '"') $s = substr($s, 0, -1); if ( substr($s, -1, 1) == '"') $s = substr($s, 0, -1);

View File

@ -58,7 +58,12 @@ class POMO_Reader {
return unpack($endian_letter.$count, $bytes); return unpack($endian_letter.$count, $bytes);
} }
/**
* @param string $string
* @param int $start
* @param int $length
* @return string
*/
function substr($string, $start, $length) { function substr($string, $start, $length) {
if ($this->is_overloaded) { if ($this->is_overloaded) {
return mb_substr($string, $start, $length, 'ascii'); return mb_substr($string, $start, $length, 'ascii');
@ -67,6 +72,10 @@ class POMO_Reader {
} }
} }
/**
* @param string $string
* @return int
*/
function strlen($string) { function strlen($string) {
if ($this->is_overloaded) { if ($this->is_overloaded) {
return mb_strlen($string, 'ascii'); return mb_strlen($string, 'ascii');
@ -75,6 +84,11 @@ class POMO_Reader {
} }
} }
/**
* @param string $string
* @param int $chunk_size
* @return array
*/
function str_split($string, $chunk_size) { function str_split($string, $chunk_size) {
if (!function_exists('str_split')) { if (!function_exists('str_split')) {
$length = $this->strlen($string); $length = $this->strlen($string);
@ -104,15 +118,26 @@ endif;
if ( !class_exists( 'POMO_FileReader' ) ): if ( !class_exists( 'POMO_FileReader' ) ):
class POMO_FileReader extends POMO_Reader { class POMO_FileReader extends POMO_Reader {
/**
* @param string $filename
*/
function POMO_FileReader($filename) { function POMO_FileReader($filename) {
parent::POMO_Reader(); parent::POMO_Reader();
$this->_f = fopen($filename, 'rb'); $this->_f = fopen($filename, 'rb');
} }
/**
* @param int $bytes
*/
function read($bytes) { function read($bytes) {
return fread($this->_f, $bytes); return fread($this->_f, $bytes);
} }
/**
* @param int $pos
* @return boolean
*/
function seekto($pos) { function seekto($pos) {
if ( -1 == fseek($this->_f, $pos, SEEK_SET)) { if ( -1 == fseek($this->_f, $pos, SEEK_SET)) {
return false; return false;
@ -157,7 +182,10 @@ class POMO_StringReader extends POMO_Reader {
$this->_pos = 0; $this->_pos = 0;
} }
/**
* @param string $bytes
* @return string
*/
function read($bytes) { function read($bytes) {
$data = $this->substr($this->_str, $this->_pos, $bytes); $data = $this->substr($this->_str, $this->_pos, $bytes);
$this->_pos += $bytes; $this->_pos += $bytes;
@ -165,6 +193,10 @@ class POMO_StringReader extends POMO_Reader {
return $data; return $data;
} }
/**
* @param int $pos
* @return int
*/
function seekto($pos) { function seekto($pos) {
$this->_pos = $pos; $this->_pos = $pos;
if ($this->strlen($this->_str) < $this->_pos) $this->_pos = $this->strlen($this->_str); if ($this->strlen($this->_str) < $this->_pos) $this->_pos = $this->strlen($this->_str);

View File

@ -17,7 +17,7 @@ class Translations {
/** /**
* Add entry to the PO structure * Add entry to the PO structure
* *
* @param object &$entry * @param array|Translation_Entry &$entry
* @return bool true on success, false if the entry doesn't have a key * @return bool true on success, false if the entry doesn't have a key
*/ */
function add_entry($entry) { function add_entry($entry) {
@ -30,6 +30,10 @@ class Translations {
return true; return true;
} }
/**
* @param array|Translation_Entry $entry
* @return bool
*/
function add_entry_or_merge($entry) { function add_entry_or_merge($entry) {
if (is_array($entry)) { if (is_array($entry)) {
$entry = new Translation_Entry($entry); $entry = new Translation_Entry($entry);
@ -57,21 +61,35 @@ class Translations {
$this->headers[$header] = $value; $this->headers[$header] = $value;
} }
/**
* @param array $headers
*/
function set_headers($headers) { function set_headers($headers) {
foreach($headers as $header => $value) { foreach($headers as $header => $value) {
$this->set_header($header, $value); $this->set_header($header, $value);
} }
} }
/**
* @param string $header
*/
function get_header($header) { function get_header($header) {
return isset($this->headers[$header])? $this->headers[$header] : false; return isset($this->headers[$header])? $this->headers[$header] : false;
} }
/**
* @param Translation_Entry $entry
*/
function translate_entry(&$entry) { function translate_entry(&$entry) {
$key = $entry->key(); $key = $entry->key();
return isset($this->entries[$key])? $this->entries[$key] : false; return isset($this->entries[$key])? $this->entries[$key] : false;
} }
/**
* @param string $singular
* @param string $context
* @return string
*/
function translate($singular, $context=null) { function translate($singular, $context=null) {
$entry = new Translation_Entry(array('singular' => $singular, 'context' => $context)); $entry = new Translation_Entry(array('singular' => $singular, 'context' => $context));
$translated = $this->translate_entry($entry); $translated = $this->translate_entry($entry);
@ -97,6 +115,12 @@ class Translations {
return 2; return 2;
} }
/**
* @param string $singular
* @param string $plural
* @param int $count
* @param string $context
*/
function translate_plural($singular, $plural, $count, $context = null) { function translate_plural($singular, $plural, $count, $context = null) {
$entry = new Translation_Entry(array('singular' => $singular, 'plural' => $plural, 'context' => $context)); $entry = new Translation_Entry(array('singular' => $singular, 'plural' => $plural, 'context' => $context));
$translated = $this->translate_entry($entry); $translated = $this->translate_entry($entry);
@ -139,6 +163,7 @@ class Gettext_Translations extends Translations {
* It lives in this class, because there are more than one descendand, which will use it and * It lives in this class, because there are more than one descendand, which will use it and
* they can't share it effectively. * they can't share it effectively.
* *
* @param int $count
*/ */
function gettext_select_plural_form($count) { function gettext_select_plural_form($count) {
if (!isset($this->_gettext_select_plural_form) || is_null($this->_gettext_select_plural_form)) { if (!isset($this->_gettext_select_plural_form) || is_null($this->_gettext_select_plural_form)) {
@ -149,6 +174,10 @@ class Gettext_Translations extends Translations {
return call_user_func($this->_gettext_select_plural_form, $count); return call_user_func($this->_gettext_select_plural_form, $count);
} }
/**
* @param string $header
* @return array
*/
function nplurals_and_expression_from_header($header) { function nplurals_and_expression_from_header($header) {
if (preg_match('/^\s*nplurals\s*=\s*(\d+)\s*;\s+plural\s*=\s*(.+)$/', $header, $matches)) { if (preg_match('/^\s*nplurals\s*=\s*(\d+)\s*;\s+plural\s*=\s*(.+)$/', $header, $matches)) {
$nplurals = (int)$matches[1]; $nplurals = (int)$matches[1];
@ -162,6 +191,8 @@ class Gettext_Translations extends Translations {
/** /**
* Makes a function, which will return the right translation index, according to the * Makes a function, which will return the right translation index, according to the
* plural forms header * plural forms header
* @param int $nplurals
* @param string $expression
*/ */
function make_plural_form_function($nplurals, $expression) { function make_plural_form_function($nplurals, $expression) {
$expression = str_replace('n', '$n', $expression); $expression = str_replace('n', '$n', $expression);
@ -203,6 +234,10 @@ class Gettext_Translations extends Translations {
return rtrim($res, ';'); return rtrim($res, ';');
} }
/**
* @param string $translation
* @return array
*/
function make_headers($translation) { function make_headers($translation) {
$headers = array(); $headers = array();
// sometimes \ns are used instead of real new lines // sometimes \ns are used instead of real new lines
@ -216,6 +251,10 @@ class Gettext_Translations extends Translations {
return $headers; return $headers;
} }
/**
* @param string $header
* @param string $value
*/
function set_header($header, $value) { function set_header($header, $value) {
parent::set_header($header, $value); parent::set_header($header, $value);
if ('Plural-Forms' == $header) { if ('Plural-Forms' == $header) {
@ -253,6 +292,10 @@ class NOOP_Translations {
return false; return false;
} }
/**
* @param string $singular
* @param string $context
*/
function translate($singular, $context=null) { function translate($singular, $context=null) {
return $singular; return $singular;
} }
@ -265,6 +308,12 @@ class NOOP_Translations {
return 2; return 2;
} }
/**
* @param string $singular
* @param string $plural
* @param int $count
* @param string $context
*/
function translate_plural($singular, $plural, $count, $context = null) { function translate_plural($singular, $plural, $count, $context = null) {
return 1 == $count? $singular : $plural; return 1 == $count? $singular : $plural;
} }

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.1-beta2-30662'; $wp_version = '4.1-beta2-30663';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.