Remove deprecated Language::commafy and mw.language.commafy

Language::commafy and mw.language.commafy have been deprecated in
4bc5c761 included in MW 1.36.

Bug: T331708
Change-Id: I874c2c904fa4a7f04486113d1d92709c21d1f5bb
This commit is contained in:
Fomafix 2023-03-10 09:46:39 +00:00
parent 28f90833b9
commit 7f4e9bfa39
5 changed files with 2 additions and 105 deletions

View file

@ -327,6 +327,8 @@ because of Phabricator reports.
* .box-sizing() Less mixin, deprecated since 1.37, has been removed.
Use CSS box-sizing now.
* MimeAnalyzer::getIEMimeTypes() and IEContentAnalyzer were removed.
* Language::commafy and mw.language.commafy, deprecated since 1.36, has been
removed.
* …
=== Deprecations in 1.40 ===

View file

@ -3369,27 +3369,6 @@ class Language implements Bcp47Code {
return $number;
}
/**
* Adds commas to a given number. NumberFormatting class is used
* when available for correct implementation as per tr35
* specification of unicode.
*
* @since 1.19
* @deprecated in 1.36 use formatNum
* @param string|null $number Expected to be a numeric string without (thousand) group
* separators. Decimal separator, if present, must be a dot. Any non-string will be cast to
* string.
* @return string
*/
public function commafy( $number ) {
wfDeprecated( __METHOD__, '1.36' );
// Validate the input argument.
if ( $number === null || $number === '' ) {
return '';
}
return $this->formatNumInternal( $number, true, false );
}
/**
* @return string
*/

View file

@ -309,21 +309,4 @@
} );
/**
* Apply pattern to format value as a string.
*
* Using patterns from [Unicode TR35](https://www.unicode.org/reports/tr35/#Number_Format_Patterns).
*
* @method commafy
* @deprecated This function will be made private in a future release;
* it is poorly named, corresponds to a deprecated function in core, and
* its functionality should be rolled into convertNumber().
* @param {number} value
* @param {string} pattern Pattern string as described by Unicode TR35
* @param {number|null} [minimumGroupingDigits=null]
* @throws {Error} If unable to find a number expression in `pattern`.
* @return {string}
*/
mw.log.deprecate( mw.language, 'commafy', commafyInternal, 'Use mw.language.convertNumber instead', 'mw.language.commafy' );
}() );

View file

@ -1700,55 +1700,6 @@ class LanguageIntegrationTest extends LanguageClassesTestCase {
];
}
/**
* @covers Language::commafy()
* @dataProvider provideCommafyData
*/
public function testCommafy( $number, $numbersWithCommas ) {
$this->hideDeprecated( 'Language::commafy' );
$this->hideDeprecated( 'Language::formatNum with a non-numeric string' );
$this->assertEquals(
$numbersWithCommas,
$this->getLang()->commafy( $number ),
"commafy('$number')"
);
}
public static function provideCommafyData() {
return [
[ -1, '-1' ],
[ 10, '10' ],
[ 100, '100' ],
[ 1000, '1,000' ],
[ 10000, '10,000' ],
[ 100000, '100,000' ],
[ 1000000, '1,000,000' ],
[ -1.0001, '-1.0001' ],
[ 1.0001, '1.0001' ],
[ 10.0001, '10.0001' ],
[ 100.0001, '100.0001' ],
[ 1000.0001, '1,000.0001' ],
[ 10000.0001, '10,000.0001' ],
[ 100000.0001, '100,000.0001' ],
[ 1000000.0001, '1,000,000.0001' ],
[ '200000000000000000000', '200,000,000,000,000,000,000' ],
[ '-200000000000000000000', '-200,000,000,000,000,000,000' ],
[ '1.', '1.' ],
[ '-.1', '-.1' ],
[ '-0', '-0' ],
// Make sure non-numeric strings are not destroyed
// (But these will trigger deprecation warnings)
[ 'The number is 1234', 'The number is 1,234' ],
[ '1234 is the number', '1,234 is the number' ],
[ '.', '.' ],
[ ',', ',' ],
[ '-', '-' ],
[ 'abcdefg', 'abcdefg' ],
[ 'dontBeF00led.2', 'dontBeF00led.2' ],
];
}
/**
* @covers Language::listToText
*/

View file

@ -28,24 +28,6 @@
assert.strictEqual( mw.language.getData( 'en-US', 'testkey' ), 'testvalue', 'Case insensitive test for mw.language' );
} );
QUnit.test( 'mw.language.commafy test', function ( assert ) {
mw.language.setData( 'en', 'digitGroupingPattern', null );
mw.language.setData( 'en', 'digitTransformTable', null );
mw.language.setData( 'en', 'separatorTransformTable', null );
mw.config.set( 'wgUserLanguage', 'en' );
// Number grouping patterns are as per http://cldr.unicode.org/translation/number-patterns
assert.strictEqual( mw.language.commafy( 1234.567, '###0.#####' ), '1234.567', 'Pattern with no digit grouping separator defined' );
assert.strictEqual( mw.language.commafy( 123456789.567, '###0.#####' ), '123456789.567', 'Pattern with no digit grouping separator defined, bigger decimal part' );
assert.strictEqual( mw.language.commafy( 0.567, '###0.#####' ), '0.567', 'Decimal part 0' );
assert.strictEqual( mw.language.commafy( '.567', '###0.#####' ), '0.567', 'Decimal part missing. replace with zero' );
assert.strictEqual( mw.language.commafy( 1234, '##,#0.#####' ), '12,34', 'Pattern with no fractional part' );
assert.strictEqual( mw.language.commafy( -1234.567, '###0.#####' ), '-1234.567', 'Negative number' );
assert.strictEqual( mw.language.commafy( -1234.567, '#,###.00' ), '-1,234.56', 'Fractional part bigger than pattern.' );
assert.strictEqual( mw.language.commafy( 123456789.567, '###,##0.00' ), '123,456,789.56', 'Decimal part as group of 3' );
assert.strictEqual( mw.language.commafy( 123456789.567, '###,###,#0.00' ), '1,234,567,89.56', 'Decimal part as group of 3 and last one 2' );
} );
QUnit.test( 'mw.language.convertNumber', function ( assert ) {
mw.language.setData( 'en', 'digitGroupingPattern', null );
mw.language.setData( 'en', 'digitTransformTable', null );