summaryrefslogtreecommitdiff
path: root/includes/parser/DateFormatter.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2014-12-27 15:41:37 +0100
committerPierre Schmitz <pierre@archlinux.de>2014-12-31 11:43:28 +0100
commitc1f9b1f7b1b77776192048005dcc66dcf3df2bfb (patch)
tree2b38796e738dd74cb42ecd9bfd151803108386bc /includes/parser/DateFormatter.php
parentb88ab0086858470dd1f644e64cb4e4f62bb2be9b (diff)
Update to MediaWiki 1.24.1
Diffstat (limited to 'includes/parser/DateFormatter.php')
-rw-r--r--includes/parser/DateFormatter.php51
1 files changed, 28 insertions, 23 deletions
diff --git a/includes/parser/DateFormatter.php b/includes/parser/DateFormatter.php
index 0a69b045..82f0e9d4 100644
--- a/includes/parser/DateFormatter.php
+++ b/includes/parser/DateFormatter.php
@@ -27,11 +27,11 @@
* @ingroup Parser
*/
class DateFormatter {
- var $mSource, $mTarget;
- var $monthNames = '', $rxDM, $rxMD, $rxDMY, $rxYDM, $rxMDY, $rxYMD;
+ public $mSource, $mTarget;
+ public $monthNames = '', $rxDM, $rxMD, $rxDMY, $rxYDM, $rxMDY, $rxYMD;
- var $regexes, $pDays, $pMonths, $pYears;
- var $rules, $xMonths, $preferences;
+ public $regexes, $pDays, $pMonths, $pYears;
+ public $rules, $xMonths, $preferences;
protected $lang;
@@ -49,9 +49,9 @@ class DateFormatter {
const LAST = 8;
/**
- * @param $lang Language In which language to format the date
+ * @param Language $lang In which language to format the date
*/
- function __construct( Language $lang ) {
+ public function __construct( Language $lang ) {
$this->lang = $lang;
$this->monthNames = $this->getMonthRegex();
@@ -120,9 +120,9 @@ class DateFormatter {
/**
* Get a DateFormatter object
*
- * @param $lang Language|string|null In which language to format the date
+ * @param Language|string|null $lang In which language to format the date
* Defaults to the site content language
- * @return DateFormatter object
+ * @return DateFormatter
*/
public static function &getInstance( $lang = null ) {
global $wgMemc, $wgContLang;
@@ -142,10 +142,11 @@ class DateFormatter {
/**
* @param string $preference User preference
* @param string $text Text to reformat
- * @param array $options can contain 'linked' and/or 'match-whole'
- * @return mixed|String
+ * @param array $options Array can contain 'linked' and/or 'match-whole'
+ *
+ * @return string
*/
- function reformat( $preference, $text, $options = array( 'linked' ) ) {
+ public function reformat( $preference, $text, $options = array( 'linked' ) ) {
$linked = in_array( 'linked', $options );
$match_whole = in_array( 'match-whole', $options );
@@ -192,10 +193,10 @@ class DateFormatter {
}
/**
- * @param $matches
+ * @param array $matches
* @return string
*/
- function replace( $matches ) {
+ public function replace( $matches ) {
# Extract information from $matches
$linked = true;
if ( isset( $this->mLinked ) ) {
@@ -204,7 +205,8 @@ class DateFormatter {
$bits = array();
$key = $this->keys[$this->mSource];
- for ( $p = 0; $p < strlen( $key ); $p++ ) {
+ $keyLength = strlen( $key );
+ for ( $p = 0; $p < $keyLength; $p++ ) {
if ( $key[$p] != ' ' ) {
$bits[$key[$p]] = $matches[$p + 1];
}
@@ -214,11 +216,11 @@ class DateFormatter {
}
/**
- * @param $bits array
- * @param $link bool
+ * @param array $bits
+ * @param bool $link
* @return string
*/
- function formatDate( $bits, $link = true ) {
+ public function formatDate( $bits, $link = true ) {
$format = $this->targets[$this->mTarget];
if ( !$link ) {
@@ -253,7 +255,8 @@ class DateFormatter {
$bits['d'] = sprintf( '%02d', $bits['j'] );
}
- for ( $p = 0; $p < strlen( $format ); $p++ ) {
+ $formatLength = strlen( $format );
+ for ( $p = 0; $p < $formatLength; $p++ ) {
$char = $format[$p];
switch ( $char ) {
case 'd': # ISO day of month
@@ -292,6 +295,7 @@ class DateFormatter {
}
}
if ( $fail ) {
+ /** @todo FIXME: $matches doesn't exist here, what's expected? */
$text = $matches[0];
}
@@ -314,7 +318,7 @@ class DateFormatter {
* @todo document
* @return string
*/
- function getMonthRegex() {
+ public function getMonthRegex() {
$names = array();
for ( $i = 1; $i <= 12; $i++ ) {
$names[] = $this->lang->getMonthName( $i );
@@ -325,10 +329,10 @@ class DateFormatter {
/**
* Makes an ISO month, e.g. 02, from a month name
- * @param string $monthName month name
+ * @param string $monthName Month name
* @return string ISO month name
*/
- function makeIsoMonth( $monthName ) {
+ public function makeIsoMonth( $monthName ) {
$n = $this->xMonths[$this->lang->lc( $monthName )];
return sprintf( '%02d', $n );
}
@@ -338,7 +342,7 @@ class DateFormatter {
* @param string $year Year name
* @return string ISO year name
*/
- function makeIsoYear( $year ) {
+ public function makeIsoYear( $year ) {
# Assumes the year is in a nice format, as enforced by the regex
if ( substr( $year, -2 ) == 'BC' ) {
$num = intval( substr( $year, 0, -3 ) ) - 1;
@@ -353,9 +357,10 @@ class DateFormatter {
/**
* @todo document
+ * @param string $iso
* @return int|string
*/
- function makeNormalYear( $iso ) {
+ public function makeNormalYear( $iso ) {
if ( $iso[0] == '-' ) {
$text = ( intval( substr( $iso, 1 ) ) + 1 ) . ' BC';
} else {