8000 Import symfony/intl polyfills by nicolas-grekas · Pull Request #310 · symfony/polyfill · GitHub
[go: up one dir, main page]

Skip to content

Import symfony/intl polyfills #310

8000
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 194 commits into from
Nov 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
194 commits
Select commit Hold shift + click to select a range
dc4b2df
[Intl] Refactored Locale component into two new components Icu and Intl
webmozart Mar 1, 2013
c29763e
Fixed PHPDoc
pborreli Mar 15, 2013
067dcd9
[Intl] Removed method IntlTestCase::skipIfInsufficientIcuVersion()
webmozart Mar 15, 2013
1f37e34
[Intl] Made the $locale parameter optional in the bundle interfaces
webmozart Mar 15, 2013
296b493
[Intl] Bumped the stub version to 50.1.2
webmozart Mar 15, 2013
1bb1cff
[Intl] Only the StubNumberFormatterTest requires stub data
webmozart Mar 15, 2013
ec388a2
[Intl] Simplified tests
webmozart Mar 15, 2013
a93c0a3
[Intl] Removed ICU version comparisons from the tests
webmozart Mar 16, 2013
59e153b
[Intl] Moved stub data to Icu component 1.0.x
webmozart Apr 4, 2013
55f3177
[Intl] Improved inline documentation
webmozart Apr 11, 2013
eeda27a
[Intl] Removed "Stub" prefix from stub classes
webmozart Apr 11, 2013
28dafe4
Fixed typos
pborreli Apr 21, 2013
0858e36
[Intl] Fixed the class namespaces in the @covers annotations.
jakzal May 18, 2013
b043c6b
[Intl] Fixed tests failing on PHP 5.5
jakzal Jun 21, 2013
b2a1593
fixed CS
fabpot Jul 1, 2013
437f93d
[Intl] Updated stubs to reflect ICU 51.2
webmozart Aug 6, 2013
9d9bbbf
[Locale] Fixed: Locale::setDefault() throws no exception when "en" is…
webmozart Aug 24, 2013
b847ee4
Merge branch '2.2' into 2.3
fabpot Sep 22, 2013
a6c109e
[Intl] fixed datetime test as described in #9455
andremaha Nov 14, 2013
036ffbb
fixed CS
fabpot Dec 12, 2013
e4b16ca
fixed various typos
fabpot Dec 27, 2013
4e04129
fixed CS for lambdas
fabpot Dec 28, 2013
954e201
[Intl] Added round support for ROUND_CEILING, ROUND_FLOOR, ROUND_DOWN…
pamil Dec 30, 2013
37a3181
Skips test that need full lib-intl.
pamil Dec 30, 2013
fb72797
removed unneeded use statements
fabpot Jan 1, 2014
c215d64
update year on licenses
cordoval Jan 6, 2014
b1ed95c
Fix for a couple of undefined classes in docblocks
dave1010 Jan 10, 2014
8ec74c6
fixed various inconsistencies
fabpot Feb 11, 2014
06324eb
fixed float comparison in unit tests for HHVM
fabpot Mar 29, 2014
ac5932a
made types consistent with those defined in Hack
fabpot Apr 12, 2014
5cdb029
made phpdoc types consistent with those defined in Hack
fabpot Apr 12, 2014
065111b
fixed types in phpdocs
fabpot Apr 16, 2014
58d1fd7
made {@inheritdoc} annotations consistent across the board
fabpot Apr 15, 2014
b8401e4
fixed types in phpdocs
fabpot Apr 16, 2014
42bf5b5
unified return null usages
fabpot Apr 16, 2014
0e1b1a6
added XSD to PHPUnit configuration
craue Jul 6, 2014
d9a10cd
removed defaults from PHPUnit configuration
craue Jul 7, 2014
b461bbb
fixed CS
fabpot Sep 21, 2014
fa8fc8d
[Intl] Integrated ICU data into Intl component
webmozart Sep 15, 2014
4c8e8ec
Remove aligned '=>' and '='
polc Oct 22, 2014
d6b8c2e
Remove aligned '=>' and '='
polc Oct 30, 2014
e355302
compare version using PHP_VERSION_ID
xabbuh Nov 17, 2014
c01443a
Adjust error_reporting to allow deprecation messages for 3.0
Nov 29, 2014
48dfd7b
Docblock fixes
GrahamCampbell Nov 30, 2014
2a33a3d
PSR-2 fixes
GrahamCampbell Dec 2, 2014
89cd7de
Removed all $that variables
saro0h Dec 3, 2014
66bd3d2
[2.3] CS And DocBlock Fixes
GrahamCampbell Dec 21, 2014
12fa788
No global state for isolated tests and other fixes
nicolas-grekas Dec 29, 2014
1573349
Fix phpdoc and coding standards
stof Dec 29, 2014
d8d1a63
[3.0] Removed some old hacks
GrahamCampbell Nov 30, 2014
63fae58
Updated copyright to 2015
saro0h Jan 1, 2015
c140102
Fixes various phpdoc and coding standards.
Dec 21, 2014
f06b104
removed code for PHP < 5.3.9
fabpot Jan 8, 2015
9b65415
[PhpUnitBridge] new bridge for testing with PHPUnit
nicolas-grekas Jan 13, 2015
5217bf2
CS: general fixes
keradus Mar 24, 2015
62ea6df
CS: Pre incrementation/decrementation should be used if possible
gharlan Mar 30, 2015
bf03b6d
Fix typo
SpacePossum May 22, 2015
f78c162
Php Inspections (EA Extended): - resolved possible PHP Fatal in \…
kalessil May 29, 2015
776bd0f
Fix quoting style consistency.
ogizanagi Jun 28, 2015
6afdd8c
Fix the handling of null as locale in the stub intl classes
stof Jul 30, 2015
fb7be2d
Remove skipping of tests based on ICU data version whenever possible stof Jul 30, 2015
1b639af
Implement the support of timezone objects in the stub IntlDateFormatter
stof Aug 7, 2015
c854f10
Windows and Intl fixes
nicolas-grekas Aug 20, 2015
3b4e714
[ci] Run minimal versions on appveyor only
nicolas-grekas Aug 28, 2015
baded53
[Intl] Fix test
nicolas-grekas Sep 2, 2015
007e108
[3.0] Fix tests
nicolas-grekas Sep 1, 2015
cb7b3c6
fix class use and in phpdoc
ewgRa Sep 8, 2015
e539eff
fix leftover changes from previous merge
Tobion Sep 9, 2015
21c66df
[ci] Enable collecting and replaying skipped tests
nicolas-grekas Oct 9, 2015
2b58486
[PhpUnit] Auto-register SymfonyTestsListener
nicolas-grekas Oct 11, 2015
7f9d27c
Rely on iconv and symfony/polyfill-*
nicolas-grekas Oct 14, 2015
d368f58
removed all @covers annotations
fabpot Nov 1, 2015
fad59df
Fix tests when no Intl extension
ewgRa Oct 18, 2015
4b26ec2
Add missing exclusions from phpunit.xml.dist
nicolas-grekas Nov 18, 2015
f035f1d
CS: remove unneeded parentheses around control statements
keradus Dec 1, 2015
19b59df
Update copyright year
dosten Jan 2, 2016
4ce1be2
typo
enumag Jan 5, 2016
53c82f7
Static code analysis
Koc Jan 25, 2016
871a79c
[Intl] Update tests and the number formatter to match behaviour of th…
jakzal Mar 4, 2016
67eede9
[NumberFormatter] Fix invalid numeric literal on PHP 7
nicolas-grekas Mar 17, 2016
1481bfb
[Intl] Fix int32 min boundary check
nicolas-grekas Apr 1, 2016
7e50a90
Updated the link to the list of currency codes
javiereguiluz May 13, 2016
4eda808
removed dots at the end of @param and @return
fabpot Jun 28, 2016
86e143f
fixed CS
fabpot Jun 29, 2016
3478f5d
Minor fixes
zomberg Jul 28, 2016
7ee9cc4
[Intl] Update ICU data to 57.1
jakzal Jul 28, 2016
c7e121a
Fixes the calendar in constructor to handle null
wakqasahmed Aug 26, 2016
81e4cc9
Code enhancement and cleanup
yceruto Sep 2, 2016
0a46f1d
CS: apply rules
keradus Oct 30, 2016
71b3a53
[ci] Testing with UTC hides bugs
nicolas-grekas Nov 17, 2016
12651aa
fixed @return when returning this or static
fabpot Dec 26, 2016
d5cda28
updated LICENSE year
fabpot Jan 2, 2017
38cc63a
Update to PHPUnit namespaces
peterrehm Feb 8, 2017
3c9877c
Further refactorings to PHPUnit namespaces
peterrehm Feb 20, 2017
e34b429
[Intl] Make tests pass after the ICU data update
jakzal Feb 27, 2017
3db3dfc
Static code analysis with Php Inspections (EA Extended): dead code dr…
kalessil Mar 3, 2017
ad07241
fixed CS
fabpot Mar 4, 2017
da78590
Rename TimeZoneTransformer into TimezoneTransformer
lepiaf Mar 5, 2017
abf186b
fix risky tests
xabbuh Apr 11, 2017
4494ae1
fail when detecting risky tests
xabbuh Apr 12, 2017
0b1102b
Fix minor phpdoc mismatches with the code(detected by phan)
TysonAndre Apr 17, 2017
7b89495
[Intl][Form] Update tests, TimeZoneTransformer, and DateTimeToLocaliz…
jakzal May 3, 2017
fdb956c
removed unneeded annotation in tests
fabpot May 15, 2017
992c22b
Remove PHP < 7.1.3 code
ogizanagi May 21, 2017
eeb2b0b
removed HHVM support
fabpot May 18, 2017
a58bb15
Change number PHPDoc type to int|float
PurpleBooth Aug 25, 2017
2cad0b4
Add scalar typehints/return types on final/internal/private code
Aug 5, 2017
75efaee
[CS] Apply phpdoc_annotation_without_dot
keradus Sep 11, 2017
ae25750
[CS][2.7] yoda_style, no_unneeded_curly_braces, no_unneeded_final_met…
SpacePossum Sep 7, 2017
4341c29
removed useless PHPDoc
OskarStark Sep 28, 2017
2b1b60f
[DI] minor docblock fixes
nicolas-grekas Oct 22, 2017
b8a9f08
Remove useless docblocks
nicolas-grekas Oct 28, 2017
3625ef7
Replace more docblocks by type-hints
nicolas-grekas Oct 28, 2017
d5f4d52
[Intl] Update ICU data to 60.1
jakzal Nov 10, 2017
c2c9b1e
[Intl] Correct Typehint
votemike Dec 1, 2017
0b6f0dd
[Intl] Update ICU data to 60.2
jakzal Dec 17, 2017
e713da7
Update LICENSE year... forever
dunglas Dec 31, 2017
f6d820e
fixed years in copyright
fabpot Jan 3, 2018
08e697a
[Intl] Add polyfill for Locale::canonicalize()
nicolas-grekas Feb 12, 2018
99cb114
Mark ExceptionInterfaces throwable
ostrolucky Mar 28, 2018
f83d541
declare type for arguments of anonymous functions for v2.7
DQNEO Apr 5, 2018
88682a6
fix rounding from string
syastrebov Apr 20, 2018
d3b3730
Revert "feature #26702 Mark ExceptionInterfaces throwable (ostrolucky)"
nicolas-grekas May 30, 2018
0d838aa
Enable the fixer enforcing fully-qualified calls for compiler-optimiz…
stof Jul 5, 2018
2df8170
Alpha-ordering for "use" statements
nicolas-grekas Jul 26, 2018
59e6044
Mark ExceptionInterfaces throwable
ostrolucky Mar 28, 2018
7f946cd
Consistently throw exceptions on a single line
nicolas-grekas Sep 8, 2018
0c0247d
Remove all usages of call_user_func_array()
nicolas-grekas Sep 11, 2018
7e0a4e4
parse numbers terminated with decimal separator
xabbuh Sep 21, 2018
6f37b04
fixed CS
fabpot Oct 11, 2018
9dddc46
[Intl] Update the ICU data to 63.1
jakzal Oct 24, 2018
676c773
Revert "fixed CS"
keradus Oct 20, 2018
b68f728
SCA: simplify some ifs in favour of null coalescing operator
kalessil Oct 28, 2018
56b9eab
Bump phpunit XSD version to 5.2
greg0ire Nov 11, 2018
ca52e78
fix type for $value in DocBlock
rudidude86 Dec 1, 2018
c96b067
fix cs
nicolas-grekas Dec 1, 2018
9391b84
update year in license files
xabbuh Jan 1, 2019
e71abaf
[Intl] handle null date and time types
xabbuh Dec 31, 2018
012aa35
[Intl] make type-hinted arguments nullable
xabbuh Jan 4, 2019
5afb353
simplified PHPUnit exception expectations
fabpot Jan 16, 2019
ae911b3
switched array() to []
fabpot Jan 16, 2019
ad605ee
fixed short array CS in comments
fabpot Jan 16, 2019
89bfc5c
fixed CS
fabpot Jan 16, 2019
14a64c2
fix some minor typos
xabbuh Feb 2, 2019
a33652d
Apply php-cs-fixer rule for array_key_exists()
nicolas-grekas Feb 23, 2019
8000 6c90d3b
[Intl] Simplify API
ro0NL Oct 12, 2018
46843c6
Fix binary operation `+`, `-` or `*` on string
steef Jun 12, 2019
fc2c246
relax some date parser patterns
xabbuh Jul 23, 2019
69e560c
Make tests support phpunit 8
nicolas-grekas Jul 31, 2019
69439de
add parameter type declarations to private methods
xabbuh Jul 27, 2019
9f72402
Fix assertInternalType deprecation in phpunit 9
jderusse Aug 1, 2019
6e85a70
fix tests
nicolas-grekas Aug 1, 2019
0cd1269
Fix deprecated phpunit annotation
jderusse Aug 1, 2019
2d78218
Adopt `@PHPUnit55Migration:risky` rule of php-cs-fixer
nicolas-grekas Aug 2, 2019
87f095d
Remove use of ForwardCompatTrait
jderusse Aug 2, 2019
e904d7f
Use namespaced Phpunit classes
jderusse Aug 5, 2019
af7327e
Support DateTimeInterface in IntlDateFormatter::format
pierredup Aug 5, 2019
b91a282
Use assertEqualsWithDelta when required
jderusse Aug 5, 2019
798fd2a
Fix remaining tests
jderusse Aug 6, 2019
9f29e83
Turned return type annotations of private methods into php return types.
derrabus Aug 6, 2019
36a1354
[Intl] fix nullable phpdocs and useless method visibility of internal…
Tobion Aug 7, 2019
7bd23fd
Disable phpunit typehint patch on 4.3 branch
jderusse Aug 8, 2019
09c6a58
Improve some URLs
Arman-Hosseini Jul 29, 2019
ba1433c
cleanup remaining param and internal Intl FulLTransformer
Tobion Aug 8, 2019
dbcd68d
[Intl][5.0] Add parameters type-hints
Jul 12, 2019
85b40d1
[Intl] use strict comparisons
Tobion Aug 8, 2019
657042c
Fix inconsistent return points.
derrabus Aug 19, 2019
0ef59ad
Add return types to internal|final|private methods
nicolas-grekas Aug 20, 2019
f3d095b
[Intl] make polyfill classes abstract, fix edge case
nicolas-grekas Aug 21, 2019
421a03f
Add return types to tests and final|internal|private methods
nicolas-grekas Aug 21, 2019
0b34067
Add more return types after fixing a typo in my script
nicolas-grekas Aug 23, 2019
3044bf5
[Intl] fix return type declarations
nicolas-grekas Aug 24, 2019
0971c1b
Add more "object" return types
nicolas-grekas Aug 26, 2019
eb4cfde
fix merge
nicolas-grekas Aug 26, 2019
3717d59
Adding .gitattributes to remove Tests directory from "dist"
Nyholm Sep 5, 2019
fc076de
Add .gitignore to .gitattributes
reedy Oct 12, 2019
7592ecf
Update year in license files
rosier Jan 1, 2020
8206136
Fix CS
fabpot Feb 4, 2020
fa6d089
Updated ICU urls
oleg-andreyev Feb 10, 2020
1c48407
Add missing dots at the end of exception messages
fabpot Mar 15, 2020
10fbb86
Fix quotes in exception messages
fabpot Mar 16, 2020
c4e2d66
Fix more quotes in exception messages
fabpot Mar 16, 2020
bbe7c97
add missing gitattributes for phpunit-bridge
Tobion Mar 25, 2020
c10c582
[Intl] Fix call to ReflectionProperty::getValue() for static properties.
derrabus May 22, 2020
7060288
use expectWarning() when possible
xabbuh Aug 13, 2020
b32e82c
Fix CS
fabpot Aug 17, 2020
6275224
Enable "native_constant_invocation" CS rule
nicolas-grekas Sep 2, 2020
7e14958
[Intl] Skip test cases that produ 8000 ce a TypeError on php 8.
derrabus Sep 5, 2020
364e3e3
[Intl] promote warnings to value errors on PHP 8
xabbuh Sep 9, 2020
f958f16
Fix CS
fabpot Sep 11, 2020
b8b13af
fix rebase
nicolas-grekas Oct 31, 2020
11b6e56
Prepare for importing symfony/intl polyfills
nicolas-grekas Oct 31, 2020
e701bd3
Add 'src/Intl/Icu/' from commit 'b8b13afaf7997918a396c5404493e30d2539…
nicolas-grekas Oct 31, 2020
4123f38
Finish importing symfony/intl polyfills
nicolas-grekas Oct 31, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
}
],
"require": {
"php": ">=7.1",
"symfony/intl": "~2.3|~3.0|~4.0|~5.0"
"php": ">=7.1"
},
"require-dev": {
"symfony/intl": "^4.4|^5.0",
"symfony/phpunit-bridge": "^5"
},
"replace": {
Expand Down Expand Up @@ -59,6 +59,7 @@
"src/Mbstring/bootstrap.php"
],
"classmap": [
"src/Intl/Icu/Resources/stubs",
"src/Intl/MessageFormatter/Resources/stubs",
"src/Intl/Normalizer/Resources/stubs",
"src/Php80/Resources/stubs",
Expand Down
295 changes: 295 additions & 0 deletions src/Intl/Icu/Collator.php
Original file line number Diff line number Diff line change
10000 @@ -0,0 +1,295 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Polyfill\Intl\Icu;

use Symfony\Polyfill\Intl\Icu\Exception\MethodArgumentValueNotImplementedException;
use Symfony\Polyfill\Intl\Icu\Exception\MethodNotImplementedException;
use Symfony\Polyfill\Intl\Icu\Icu;
use Symfony\Polyfill\Intl\Icu\Locale;

/**
* Replacement for PHP's native {@link \Collator} class.
*
* The only methods currently supported in this class are:
*
* - {@link \__construct}
* - {@link create}
* - {@link asort}
* - {@link getErrorCode}
* - {@link getErrorMessage}
* - {@link getLocale}
*
* @author Igor Wiedler <igor@wiedler.ch>
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @internal
*/
abstract class Collator
{
/* Attribute constants */
const FRENCH_COLLATION = 0;
const ALTERNATE_HANDLING = 1;
const CASE_FIRST = 2;
const CASE_LEVEL = 3;
const NORMALIZATION_MODE = 4;
const STRENGTH = 5;
const HIRAGANA_QUATERNARY_MODE = 6;
const NUMERIC_COLLATION = 7;

/* Attribute constants values */
const DEFAULT_VALUE = -1;

const PRIMARY = 0;
const SECONDARY = 1;
const TERTIARY = 2;
const DEFAULT_STRENGTH = 2;
const QUATERNARY = 3;
const IDENTICAL = 15;

const OFF = 16;
const ON = 17;

const SHIFTED = 20;
const NON_IGNORABLE = 21;

const LOWER_FIRST = 24;
const UPPER_FIRST = 25;

/* Sorting options */
const SORT_REGULAR = 0;
const SORT_NUMERIC = 2;
const SORT_STRING = 1;

/**
* @param string|null $locale The locale code. The only currently supported locale is "en" (or null using the default locale, i.e. "en")
*
* @throws MethodArgumentValueNotImplementedException When $locale different than "en" or null is passed
*/
public function __construct(?string $locale)
{
if ('en' !== $locale && null !== $locale) {
throw new MethodArgumentValueNotImplementedException(__METHOD__, 'locale', $locale, 'Only the locale "en" is supported');
}
}

/**
* Static constructor.
*
* @param string|null $locale The locale code. The only currently supported locale is "en" (or null using the default locale, i.e. "en")
*
* @return static
*
* @throws MethodArgumentValueNotImplementedException When $locale different than "en" or null is passed
*/
public static function create(?string $locale)
{
return new static($locale);
}

/**
* Sort array maintaining index association.
*
* @param array &$array Input array
* @param int $sortFlag Flags for sorting, can be one of the following:
* Collator::SORT_REGULAR - compare items normally (don't change types)
* Collator::SORT_NUMERIC - compare items numerically
* Collator::SORT_STRING - compare items as strings
*
* @return bool True on success or false on failure
*/
public function asort(array &$array, int $sortFlag = self::SORT_REGULAR)
{
$intlToPlainFlagMap = [
self::SORT_REGULAR => \SORT_REGULAR,
self::SORT_NUMERIC => \SORT_NUMERIC,
self::SORT_STRING => \SORT_STRING,
];

$plainSortFlag = isset($intlToPlainFlagMap[$sortFlag]) ? $intlToPlainFlagMap[$sortFlag] : self::SORT_REGULAR;

return asort($array, $plainSortFlag);
}

/**
* Not supported. Compare two Unicode strings.
*
* @param string $str1 The first string to compare
* @param string $str2 The second string to compare
*
* @return bool|int Return the comparison result or false on failure:
* 1 if $str1 is greater than $str2
* 0 if $str1 is equal than $str2
* -1 if $str1 is less than $str2
*
* @see https://php.net/collator.compare
*
* @throws MethodNotImplementedException
*/
public function compare(string $str1, string $str2)
{
throw new MethodNotImplementedException(__METHOD__);
}

/**
* Not supported. Get a value of an integer collator attribute.
*
* @param int $attr An attribute specifier, one of the attribute constants
*
* @return bool|int The attribute value on success or false on error
*
* @see https://php.net/collator.getattribute
*
* @throws MethodNotImplementedException
*/
public function getAttribute(int $attr)
{
throw new MethodNotImplementedException(__METHOD__);
}

/**
* Returns collator's last error code. Always returns the U_ZERO_ERROR class constant value.
*
* @return int The error code from last collator call
*/
public function getErrorCode()
{
return Icu::U_ZERO_ERROR;
}

/**
* Returns collator's last error message. Always returns the U_ZERO_ERROR_MESSAGE class constant value.
*
* @return string The error message from last collator call
*/
public function getErrorMessage()
{
return 'U_ZERO_ERROR';
}

/**
* Returns the collator's locale.
*
* @param int $type Not supported. The locale name type to return (Locale::VALID_LOCALE or Locale::ACTUAL_LOCALE)
*
* @return string The locale used to create the collator. Currently always
* returns "en".
*/
public function getLocale(int $type = Locale::ACTUAL_LOCALE)
{
return 'en';
}

/**
* Not supported. Get sorting key for a string.
*
* @param string $string The string to produce the key from
*
* @return string The collation key for $string
*
* @see https://php.net/collator.getsortkey
*
* @throws MethodNotImplementedException
*/
public function getSortKey(string $string)
{
throw new MethodNotImplementedException(__METHOD__);
}

/**
* Not supported. Get current collator's strength.
*
* @return bool|int The current collator's strength or false on failure
*
* @see https://php.net/collator.getstrength
*
* @throws MethodNotImplementedException
*/
public function getStrength()
{
throw new MethodNotImplementedException(__METHOD__);
}

/**
* Not supported. Set a collator's attribute.
*
* @param int $attr An attribute specifier, one of the attribute constants
* @param int $val The attribute value, one of the attribute value constants
*
* @return bool True on success or false on failure
*
* @see https://php.net/collator.setattribute
*
* @throws MethodNotImplementedException
*/
public function setAttribute(int $attr, int $val)
{
throw new MethodNotImplementedException(__METHOD__);
}

/**
* Not supported. Set the collator's strength.
*
* @param int $strength Strength to set, possible values:
* Collator::PRIMARY
* Collator::SECONDARY
* Collator::TERTIARY
* Collator::QUATERNARY
* Collator::IDENTICAL
* Collator::DEFAULT
*
* @return bool True on success or false on failure
*
* @see https://php.net/collator.setstrength
*
* @throws MethodNotImplementedException
*/
public function setStrength(int $strength)
{
throw new MethodNotImplementedException(__METHOD__);
}

/**
* Not supported. Sort array using specified collator and sort keys.
*
* @param array &$arr Array of strings to sort
*
* @return bool True on success or false on failure
*
* @see https://php.net/collator.sortwithsortkeys
*
* @throws MethodNotImplementedException
*/
public function sortWithSortKeys(array &$arr)
{
throw new MethodNotImplementedException(__METHOD__);
}

/**
* Not supported. Sort array using specified collator.
*
* @param array &$arr Array of string to sort
* @param int $sortFlag Optional sorting type, one of the following:
* Collator::SORT_REGULAR
* Collator::SORT_NUMERIC
* Collator::SORT_STRING
*
* @return bool True on success or false on failure
*
* @see https://php.net/collator.sort
*
* @throws MethodNotImplementedException
*/
public function sort(array &$arr, int $sortFlag = self::SORT_REGULAR)
{
throw new MethodNotImplementedException(__METHOD__);
}
}
43 changes: 43 additions & 0 deletions src/Intl/Icu/Currencies.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Polyfill\Intl\Icu;

/**
* @author Nicolas Grekas <p@tchwork.com>
*
* @internal
*/
class Currencies
{
private static $data;

public static function getSymbol(string $currency): ?string
{
$data = self::$data ?? self::$data = require __DIR__.'/Resources/currencies.php';

return $data[$currency][0] ?? $data[strtoupper($currency)][0] ?? null;
}

public static function getFractionDigits(string $currency): int
{
$data = self::$data ?? self::$data = require __DIR__.'/Resources/currencies.php';

return $data[$currency][1] ?? $data[strtoupper($currency)][1] ?? $data['DEFAULT'][1];
}

public static function getRoundingIncrement(string $currency): int
{
$data = self::$data ?? self::$data = require __DIR__.'/Resources/currencies.php';

return $data[$currency][2] ?? $data[strtoupper($currency)][2] ?? $data['DEFAULT 4822 9;][2];
}
}
Loading
0