X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fparser%2FCoreParserFunctions.php;h=7ce96bebafd041b72ce5d2d95902f5c859b3b385;hp=8ab5c31433c2145069de71512e0106600c3d4b1e;hb=4226fada45a83ad56e91ce7638d17d12fecec8ca;hpb=6edf7d44fad239b5e806b7bbbc0a0a1d6e044fa9 diff --git a/includes/parser/CoreParserFunctions.php b/includes/parser/CoreParserFunctions.php index 8ab5c31433..7ce96bebaf 100644 --- a/includes/parser/CoreParserFunctions.php +++ b/includes/parser/CoreParserFunctions.php @@ -90,13 +90,13 @@ class CoreParserFunctions { /** * @param Parser $parser - * @param string $part1 + * @param string $part1 Message key + * @param mixed ...$params To pass to wfMessage() * @return array */ - public static function intFunction( $parser, $part1 = '' /*, ... */ ) { + public static function intFunction( $parser, $part1 = '', ...$params ) { if ( strval( $part1 ) !== '' ) { - $args = array_slice( func_get_args(), 2 ); - $message = wfMessage( $part1, $args ) + $message = wfMessage( $part1, $params ) ->inLanguage( $parser->getOptions()->getUserLangObj() ); return [ $message->plain(), 'noparse' => false ]; } else { @@ -113,7 +113,7 @@ class CoreParserFunctions { */ public static function formatDate( $parser, $date, $defaultPref = null ) { $lang = $parser->getFunctionLang(); - $df = DateFormatter::getInstance( $lang ); + $df = MediaWikiServices::getInstance()->getDateFormatterFactory()->get( $lang ); $date = trim( $date ); @@ -313,11 +313,10 @@ class CoreParserFunctions { /** * @param Parser $parser * @param string $username + * @param string ...$forms What to output for each gender * @return string */ - public static function gender( $parser, $username ) { - $forms = array_slice( func_get_args(), 2 ); - + public static function gender( $parser, $username, ...$forms ) { // Some shortcuts to avoid loading user data unnecessarily if ( count( $forms ) === 0 ) { return ''; @@ -327,7 +326,6 @@ class CoreParserFunctions { $username = trim( $username ); - // default $gender = User::getDefaultOption( 'gender' ); // allow prefix and normalize (e.g. "*foo" -> "*foo" ). @@ -352,10 +350,10 @@ class CoreParserFunctions { /** * @param Parser $parser * @param string $text + * @param string ...$forms What to output for each number (singular, dual, plural, etc.) * @return string */ - public static function plural( $parser, $text = '' ) { - $forms = array_slice( func_get_args(), 2 ); + public static function plural( $parser, $text = '', ...$forms ) { $text = $parser->getFunctionLang()->parseFormattedNumber( $text ); settype( $text, ctype_digit( $text ) ? 'int' : 'float' ); return $parser->getFunctionLang()->convertPlural( $text, $forms );