Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 501c310

Browse files
minor #40790 [Intl] Switch from json to php resources (jderusse)
This PR was merged into the 5.3-dev branch. Discussion ---------- [Intl] Switch from json to php resources | Q | A | ------------- | --- | Branch? | 5.x | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | Fix #23545 | License | MIT | Doc PR | - take over #34214 Commits ------- 24bfc3b [Intl] Switch from json to php resources
2 parents f14b1bf + 24bfc3b commit 501c310

File tree

2,479 files changed

+345979
-345467
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,479 files changed

+345979
-345467
lines changed

.github/workflows/intl-data-tests.yml

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@ jobs:
2121
- name: Checkout
2222
uses: actions/checkout@v2
2323

24+
- name: Install system dependencies
25+
run: |
26+
echo "::group::apt-get update"
27+
sudo apt-get update
28+
echo "::endgroup::"
29+
30+
echo "::group::install tools & libraries"
31+
sudo apt-get install icu-devtools
32+
echo "::endgroup::"
33+
2434
- name: Define the ICU version
2535
run: |
2636
SYMFONY_ICU_VERSION=$(php -r 'require "src/Symfony/Component/Intl/Intl.php"; echo Symfony\Component\Intl\Intl::getIcuStubVersion();')
@@ -34,17 +44,35 @@ jobs:
3444
ini-values: "memory_limit=-1"
3545
php-version: "7.4"
3646

47+
- name: Configure composer
48+
run: |
49+
COMPOSER_HOME="$(composer config home)"
50+
composer self-update
51+
([ -d "$COMPOSER_HOME" ] || mkdir "$COMPOSER_HOME") && cp .github/composer-config.json "$COMPOSER_HOME/config.json"
52+
echo "COMPOSER_ROOT_VERSION=$(grep -m1 SYMFONY_VERSION .travis.yml | grep -o '[0-9.x]*').x-dev" >> $GITHUB_ENV
53+
54+
- name: Determine composer cache directory
55+
id: composer-cache
56+
run: echo "::set-output name=directory::$(composer config cache-dir)"
57+
58+
- name: Cache composer dependencies
59+
uses: actions/cache@v1
60+
with:
61+
path: ${{ steps.composer-cache.outputs.directory }}
62+
key: ${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }}
63+
restore-keys: ${{ matrix.php }}-composer-
64+
3765
- name: Install dependencies
3866
run: |
3967
echo "::group::composer update"
40-
composer update --no-progress --no-suggest --ansi
68+
composer update --no-progress --ansi
4169
echo "::endgroup::"
4270
echo "::group::install phpunit"
4371
./phpunit install
4472
echo "::endgroup::"
4573
4674
- name: Report the ICU version
47-
run: icu-config --version && php -i | grep 'ICU version'
75+
run: uconv -V && php -i | grep 'ICU version'
4876

4977
- name: Run intl-data tests
5078
run: ./phpunit --group intl-data -v

src/Symfony/Component/Intl/Data/Bundle/Reader/JsonBundleReader.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,8 @@ public function read(string $path, string $locale)
3535
throw new ResourceBundleNotFoundException(sprintf('The resource bundle "%s" does not exist.', $fileName));
3636
}
3737

38-
if (!file_exists($fileName)) {
39-
throw new ResourceBundleNotFoundException(sprintf('The resource bundle "%s" does not exist.', $fileName));
40-
}
41-
4238
if (!is_file($fileName)) {
43-
throw new RuntimeException(sprintf('The resource bundle "%s" is not a file.', $fileName));
39+
throw new ResourceBundleNotFoundException(sprintf('The resource bundle "%s" does not exist.', $fileName));
4440
}
4541

4642
$data = json_decode(file_get_contents($fileName), true);

src/Symfony/Component/Intl/Data/Bundle/Reader/PhpBundleReader.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,8 @@ public function read(string $path, string $locale)
3535
throw new ResourceBundleNotFoundException(sprintf('The resource bundle "%s" does not exist.', $fileName));
3636
}
3737

38-
if (!file_exists($fileName)) {
39-
throw new ResourceBundleNotFoundException(sprintf('The resource bundle "%s/%s.php" does not exist.', $path, $locale));
40-
}
41-
4238
if (!is_file($fileName)) {
43-
throw new RuntimeException(sprintf('The resource bundle "%s/%s.php" is not a file.', $path, $locale));
39+
throw new ResourceBundleNotFoundException(sprintf('The resource bundle "%s" does not exist.', $fileName));
4440
}
4541

4642
return include $fileName;

src/Symfony/Component/Intl/Data/Generator/CurrencyDataGenerator.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ protected function generateDataForMeta(BundleEntryReaderInterface $reader, strin
130130

131131
private function generateSymbolNamePairs(ArrayAccessibleResourceBundle $rootBundle): array
132132
{
133-
$symbolNamePairs = iterator_to_array($rootBundle['Currencies']);
133+
$symbolNamePairs = array_map(function ($pair) {
134+
return \array_slice(iterator_to_array($pair), 0, 2);
135+
}, iterator_to_array($rootBundle['Currencies']));
134136

135137
// Remove unwanted currencies
136138
$symbolNamePairs = array_diff_key($symbolNamePairs, self::DENYLIST);

src/Symfony/Component/Intl/Intl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public static function getIcuDataVersion(): string
125125
*/
126126
public static function getIcuStubVersion(): string
127127
{
128-
return '68.2';
128+
return '69.1';
129129
}
130130

131131
/**

src/Symfony/Component/Intl/ResourceBundle.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Symfony\Component\Intl\Data\Bundle\Reader\BufferedBundleReader;
1515
use Symfony\Component\Intl\Data\Bundle\Reader\BundleEntryReader;
1616
use Symfony\Component\Intl\Data\Bundle\Reader\BundleEntryReaderInterface;
17-
use Symfony\Component\Intl\Data\Bundle\Reader\JsonBundleReader;
17+
use Symfony\Component\Intl\Data\Bundle\Reader\PhpBundleReader;
1818

1919
/**
2020
* @author Roland Franssen <[email protected]>
@@ -47,7 +47,7 @@ final protected static function readEntry(array $indices, string $locale = null,
4747
{
4848
if (null === self::$entryReader) {
4949
self::$entryReader = new BundleEntryReader(new BufferedBundleReader(
50-
new JsonBundleReader(),
50+
new PhpBundleReader(),
5151
Intl::BUFFER_SIZE
5252
));
5353

src/Symfony/Component/Intl/Resources/bin/update-data.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
use Symfony\Component\Filesystem\Filesystem;
1313
use Symfony\Component\Intl\Data\Bundle\Compiler\GenrbCompiler;
14-
use Symfony\Component\Intl\Data\Bundle\Writer\JsonBundleWriter;
14+
use Symfony\Component\Intl\Data\Bundle\Writer\PhpBundleWriter;
1515
use Symfony\Component\Intl\Data\Generator\CurrencyDataGenerator;
1616
use Symfony\Component\Intl\Data\Generator\GeneratorConfig;
1717
use Symfony\Component\Intl\Data\Generator\LanguageDataGenerator;
@@ -166,9 +166,9 @@
166166

167167
$compiler = new GenrbCompiler($genrb, $genrbEnv);
168168
$config = new GeneratorConfig($sourceDir.'/data', $icuVersionInDownload);
169-
$jsonDir = dirname(__DIR__).'/data';
169+
$dataDir = dirname(__DIR__).'/data';
170170

171-
$config->addBundleWriter($jsonDir, new JsonBundleWriter());
171+
$config->addBundleWriter($dataDir, new PhpBundleWriter());
172172

173173
echo "Starting resource bundle compilation. This may take a while...\n";
174174

@@ -218,13 +218,13 @@
218218
219219
GIT_INFO;
220220

221-
$gitInfoFile = $jsonDir.'/git-info.txt';
221+
$gitInfoFile = $dataDir.'/git-info.txt';
222222

223223
file_put_contents($gitInfoFile, $gitInfo);
224224

225225
echo "Wrote $gitInfoFile.\n";
226226

227-
$versionFile = $jsonDir.'/version.txt';
227+
$versionFile = $dataDir.'/version.txt';
228228

229229
file_put_contents($versionFile, "$icuVersionInDownload\n");
230230

0 commit comments

Comments
 (0)