Skip to content

Commit 20689d9

Browse files
Merge branch '6.4' into 7.4
* 6.4: CS fixes - native_function_invocation & static_lambda Backport some CS fixes from 7.4
2 parents 9dfb4af + aadeb75 commit 20689d9

3 files changed

Lines changed: 24 additions & 24 deletions

File tree

Command/XliffLintCommand.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ private function displayTxt(SymfonyStyle $io, array $filesInfo, bool $errorAsGit
178178
} elseif (!$info['valid']) {
179179
++$erroredFiles;
180180
$io->text('<error> ERROR </error>'.($info['file'] ? \sprintf(' in %s', $info['file']) : ''));
181-
$io->listing(array_map(function ($error) use ($info, $githubReporter) {
181+
$io->listing(array_map(static function ($error) use ($info, $githubReporter) {
182182
// general document errors have a '-1' line number
183183
$line = -1 === $error['line'] ? null : $error['line'];
184184

@@ -202,7 +202,7 @@ private function displayJson(SymfonyStyle $io, array $filesInfo): int
202202
{
203203
$errors = 0;
204204

205-
array_walk($filesInfo, function (&$v) use (&$errors) {
205+
array_walk($filesInfo, static function (&$v) use (&$errors) {
206206
$v['file'] = (string) $v['file'];
207207
if (!$v['valid']) {
208208
++$errors;
@@ -239,7 +239,7 @@ private function getFiles(string $fileOrDirectory): iterable
239239
*/
240240
private function getDirectoryIterator(string $directory): iterable
241241
{
242-
$default = fn ($directory) => new \RecursiveIteratorIterator(
242+
$default = static fn ($directory) => new \RecursiveIteratorIterator(
243243
new \RecursiveDirectoryIterator($directory, \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS),
244244
\RecursiveIteratorIterator::LEAVES_ONLY
245245
);
@@ -253,7 +253,7 @@ private function getDirectoryIterator(string $directory): iterable
253253

254254
private function isReadable(string $fileOrDirectory): bool
255255
{
256-
$default = fn ($fileOrDirectory) => is_readable($fileOrDirectory);
256+
$default = static fn ($fileOrDirectory) => is_readable($fileOrDirectory);
257257

258258
if (null !== $this->isReadableProvider) {
259259
return ($this->isReadableProvider)($fileOrDirectory, $default);

Resources/bin/translation-status.php

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
exit(1);
6161
}
6262

63-
foreach (array_slice($argv, 1) as $argumentOrOption) {
63+
foreach (\array_slice($argv, 1) as $argumentOrOption) {
6464
if ('--incomplete' === $argumentOrOption) {
6565
$config['include_completed_languages'] = false;
6666
continue;
@@ -75,7 +75,7 @@
7575

7676
foreach ($config['original_files'] as $originalFilePath) {
7777
if (!file_exists($originalFilePath)) {
78-
echo sprintf('The following file does not exist. Make sure that you execute this command at the root dir of the Symfony code repository.%s %s', \PHP_EOL, $originalFilePath);
78+
echo \sprintf('The following file does not exist. Make sure that you execute this command at the root dir of the Symfony code repository.%s %s', \PHP_EOL, $originalFilePath);
7979
exit(1);
8080
}
8181
}
@@ -87,8 +87,8 @@
8787
$translationFilePaths = findTranslationFiles($originalFilePath, $config['locale_to_analyze']);
8888
$translationStatus = calculateTranslationStatus($originalFilePath, $translationFilePaths);
8989

90-
$totalMissingTranslations += array_sum(array_map(fn ($translation) => count($translation['missingKeys']), array_values($translationStatus)));
91-
$totalTranslationMismatches += array_sum(array_map(fn ($translation) => count($translation['mismatches']), array_values($translationStatus)));
90+
$totalMissingTranslations += array_sum(array_map(static fn ($translation) => \count($translation['missingKeys']), array_values($translationStatus)));
91+
$totalTranslationMismatches += array_sum(array_map(static fn ($translation) => \count($translation['mismatches']), array_values($translationStatus)));
9292

9393
printTranslationStatus($originalFilePath, $translationStatus, $config['verbose_output'], $config['include_completed_languages']);
9494
}
@@ -99,7 +99,7 @@ function findTranslationFiles($originalFilePath, $localeToAnalyze): array
9999
{
100100
$translations = [];
101101

102-
$translationsDir = dirname($originalFilePath);
102+
$translationsDir = \dirname($originalFilePath);
103103
$originalFileName = basename($originalFilePath);
104104
$translationFileNamePattern = str_replace('.en.', '.*.', $originalFileName);
105105

@@ -129,8 +129,8 @@ function calculateTranslationStatus($originalFilePath, $translationFilePaths): a
129129
$mismatches = findTransUnitMismatches($allTranslationKeys, $translatedKeys);
130130

131131
$translationStatus[$locale] = [
132-
'total' => count($allTranslationKeys),
133-
'translated' => count($translatedKeys),
132+
'total' => \count($allTranslationKeys),
133+
'translated' => \count($translatedKeys),
134134
'missingKeys' => $missingKeys,
135135
'mismatches' => $mismatches,
136136
];
@@ -142,7 +142,7 @@ function calculateTranslationStatus($originalFilePath, $translationFilePaths): a
142142

143143
function isTranslationCompleted(array $translationStatus): bool
144144
{
145-
return $translationStatus['total'] === $translationStatus['translated'] && 0 === count($translationStatus['mismatches']);
145+
return $translationStatus['total'] === $translationStatus['translated'] && 0 === \count($translationStatus['mismatches']);
146146
}
147147

148148
function printTranslationStatus($originalFilePath, $translationStatus, $verboseOutput, $includeCompletedLanguages)
@@ -156,7 +156,7 @@ function extractLocaleFromFilePath($filePath)
156156
{
157157
$parts = explode('.', $filePath);
158158

159-
return $parts[count($parts) - 2];
159+
return $parts[\count($parts) - 2];
160160
}
161161

162162
function extractTranslationKeys($filePath): array
@@ -199,12 +199,12 @@ function findTransUnitMismatches(array $baseTranslationKeys, array $translatedKe
199199
function printTitle($title)
200200
{
201201
echo $title.\PHP_EOL;
202-
echo str_repeat('=', strlen($title)).\PHP_EOL.\PHP_EOL;
202+
echo str_repeat('=', \strlen($title)).\PHP_EOL.\PHP_EOL;
203203
}
204204

205205
function printTable($translations, $verboseOutput, bool $includeCompletedLanguages)
206206
{
207-
if (0 === count($translations)) {
207+
if (0 === \count($translations)) {
208208
echo 'No translations found';
209209

210210
return;
@@ -218,37 +218,37 @@ function printTable($translations, $verboseOutput, bool $includeCompletedLanguag
218218

219219
if ($translation['translated'] > $translation['total']) {
220220
textColorRed();
221-
} elseif (count($translation['mismatches']) > 0) {
221+
} elseif (\count($translation['mismatches']) > 0) {
222222
textColorRed();
223223
} elseif ($translation['is_completed']) {
224224
textColorGreen();
225225
}
226226

227-
echo sprintf(
227+
echo \sprintf(
228228
'| Locale: %-'.$longestLocaleNameLength.'s | Translated: %2d/%2d | Mismatches: %d |',
229229
$locale,
230230
$translation['translated'],
231231
$translation['total'],
232-
count($translation['mismatches'])
232+
\count($translation['mismatches'])
233233
).\PHP_EOL;
234234

235235
textColorNormal();
236236

237237
$shouldBeClosed = false;
238-
if (true === $verboseOutput && count($translation['missingKeys']) > 0) {
238+
if (true === $verboseOutput && \count($translation['missingKeys']) > 0) {
239239
echo '| Missing Translations:'.\PHP_EOL;
240240

241241
foreach ($translation['missingKeys'] as $id => $content) {
242-
echo sprintf('| (id=%s) %s', $id, $content).\PHP_EOL;
242+
echo \sprintf('| (id=%s) %s', $id, $content).\PHP_EOL;
243243
}
244244
$shouldBeClosed = true;
245245
}
246-
if (true === $verboseOutput && count($translation['mismatches']) > 0) {
246+
if (true === $verboseOutput && \count($translation['mismatches']) > 0) {
247247
echo '| Mismatches between trans-unit id and source:'.\PHP_EOL;
248248

249249
foreach ($translation['mismatches'] as $id => $content) {
250-
echo sprintf('| (id=%s) Expected: %s', $id, $content['expected']).\PHP_EOL;
251-
echo sprintf('| Found: %s', $content['found']).\PHP_EOL;
250+
echo \sprintf('| (id=%s) Expected: %s', $id, $content['expected']).\PHP_EOL;
251+
echo \sprintf('| Found: %s', $content['found']).\PHP_EOL;
252252
}
253253
$shouldBeClosed = true;
254254
}

Tests/Provider/TranslationProviderCollectionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function testKeys()
2525
public function testKeysWithGenerator()
2626
{
2727
$this->assertSame(['foo', 'baz'], (new TranslationProviderCollection(
28-
(function () {
28+
(static function () {
2929
yield 'foo' => new NullProvider();
3030

3131
yield 'baz' => new NullProvider();

0 commit comments

Comments
 (0)