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 ;
7575
7676foreach ($ 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}
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
143143function 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
148148function 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
162162function extractTranslationKeys ($ filePath ): array
@@ -199,12 +199,12 @@ function findTransUnitMismatches(array $baseTranslationKeys, array $translatedKe
199199function 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
205205function 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 }
0 commit comments