Passed
Pull Request — master (#62)
by Edoardo
01:59
created
src/Command/GettextCommand.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -38,14 +38,14 @@  discard block
 block discarded – undo
38 38
      *
39 39
      * @var array
40 40
      */
41
-    protected $poResult = [];
41
+    protected $poResult = [ ];
42 42
 
43 43
     /**
44 44
      * The template paths
45 45
      *
46 46
      * @var array
47 47
      */
48
-    protected $templatePaths = [];
48
+    protected $templatePaths = [ ];
49 49
 
50 50
     /**
51 51
      * The locale path
@@ -125,9 +125,9 @@  discard block
 block discarded – undo
125 125
      */
126 126
     public function execute(Arguments $args, ConsoleIo $io)
127 127
     {
128
-        $resCmd = [];
128
+        $resCmd = [ ];
129 129
         exec('which msgmerge 2>&1', $resCmd);
130
-        if (empty($resCmd[0])) {
130
+        if (empty($resCmd[ 0 ])) {
131 131
             $io->abort('ERROR: msgmerge not available. Please install gettext utilities.');
132 132
         }
133 133
 
@@ -182,9 +182,9 @@  discard block
 block discarded – undo
182 182
         }
183 183
         $app = $args->getOption('app');
184 184
         $basePath = $app ?? getcwd();
185
-        $this->templatePaths = [$basePath . DS . 'src', $basePath . DS . 'config'];
185
+        $this->templatePaths = [ $basePath . DS . 'src', $basePath . DS . 'config' ];
186 186
         $this->templatePaths = array_merge($this->templatePaths, App::path(View::NAME_TEMPLATE));
187
-        $this->templatePaths = array_filter($this->templatePaths, function ($path) {
187
+        $this->templatePaths = array_filter($this->templatePaths, function($path) {
188 188
             return strpos($path, 'plugins') === false;
189 189
         });
190 190
         $this->localePath = (string)Hash::get($localesPaths, 0);
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
     private function writePoFiles(ConsoleIo $io): void
230 230
     {
231 231
         $header = $this->header('po');
232
-        $locales = array_keys((array)Configure::read('I18n.locales', []));
232
+        $locales = array_keys((array)Configure::read('I18n.locales', [ ]));
233 233
         foreach ($locales as $loc) {
234 234
             $potDir = $this->localePath . DS . $loc;
235 235
             if (!file_exists($potDir)) {
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
                 'Content-Type' => 'text/plain; charset=utf-8',
288 288
             ],
289 289
         ];
290
-        foreach ($contents[$type] as $k => $v) {
290
+        foreach ($contents[ $type ] as $k => $v) {
291 291
             $result .= sprintf('"%s: %s \n"', $k, $v) . "\n";
292 292
         }
293 293
 
@@ -310,9 +310,9 @@  discard block
 block discarded – undo
310 310
                 $numItems++;
311 311
             }
312 312
             if (strpos($l, 'msgstr ""') === 0) {
313
-                if (!isset($lines[$k + 1])) {
313
+                if (!isset($lines[ $k + 1 ])) {
314 314
                     $numNotTranslated++;
315
-                } elseif (strpos($lines[$k + 1], '"') !== 0) {
315
+                } elseif (strpos($lines[ $k + 1 ], '"') !== 0) {
316 316
                     $numNotTranslated++;
317 317
                 }
318 318
             }
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
      */
362 362
     private function parseFile($file, $extension)
363 363
     {
364
-        if (!in_array($extension, ['php', 'twig'])) {
364
+        if (!in_array($extension, [ 'php', 'twig' ])) {
365 365
             return;
366 366
         }
367 367
         $content = file_get_contents($file);
@@ -392,34 +392,34 @@  discard block
 block discarded – undo
392 392
 
393 393
         foreach ($functions as $fname => $singularPosition) {
394 394
             $capturePath = "'[^']*'";
395
-            $doubleQuoteCapture = str_replace("'", $options['double_quote'], $capturePath);
396
-            $quoteCapture = str_replace("'", $options['quote'], $capturePath);
395
+            $doubleQuoteCapture = str_replace("'", $options[ 'double_quote' ], $capturePath);
396
+            $quoteCapture = str_replace("'", $options[ 'quote' ], $capturePath);
397 397
 
398 398
             // phpcs:disable
399
-            $rgxp = '/' . $fname . '\s*' . $options['open_parenthesis'] . str_repeat('((?:' . $doubleQuoteCapture . ')|(?:' . $quoteCapture . '))\s*[,)]\s*', $singularPosition + 1) . '/';
399
+            $rgxp = '/' . $fname . '\s*' . $options[ 'open_parenthesis' ] . str_repeat('((?:' . $doubleQuoteCapture . ')|(?:' . $quoteCapture . '))\s*[,)]\s*', $singularPosition + 1) . '/';
400 400
             // phpcs:enable
401 401
 
402
-            $matches = [];
402
+            $matches = [ ];
403 403
             preg_match_all($rgxp, $content, $matches);
404 404
 
405
-            $limit = count($matches[0]);
405
+            $limit = count($matches[ 0 ]);
406 406
             for ($i = 0; $i < $limit; $i++) {
407 407
                 $domain = $this->defaultDomain;
408 408
                 $ctx = '';
409
-                $str = $this->unquoteString($matches[1][$i]);
409
+                $str = $this->unquoteString($matches[ 1 ][ $i ]);
410 410
 
411 411
                 if (strpos($fname, '__d') === 0) {
412
-                    $domain = $this->unquoteString($matches[1][$i]);
412
+                    $domain = $this->unquoteString($matches[ 1 ][ $i ]);
413 413
 
414 414
                     if (strpos($fname, '__dx') === 0) {
415
-                        $ctx = $this->unquoteString($matches[2][$i]);
416
-                        $str = $this->unquoteString($matches[3][$i]);
415
+                        $ctx = $this->unquoteString($matches[ 2 ][ $i ]);
416
+                        $str = $this->unquoteString($matches[ 3 ][ $i ]);
417 417
                     } else {
418
-                        $str = $this->unquoteString($matches[2][$i]);
418
+                        $str = $this->unquoteString($matches[ 2 ][ $i ]);
419 419
                     }
420 420
                 } elseif (strpos($fname, '__x') === 0) {
421
-                    $ctx = $this->unquoteString($matches[1][$i]);
422
-                    $str = $this->unquoteString($matches[2][$i]);
421
+                    $ctx = $this->unquoteString($matches[ 1 ][ $i ]);
422
+                    $str = $this->unquoteString($matches[ 2 ][ $i ]);
423 423
                 }
424 424
 
425 425
                 $str = $this->fixString($str);
@@ -428,15 +428,15 @@  discard block
 block discarded – undo
428 428
                 }
429 429
 
430 430
                 if (!array_key_exists($domain, $this->poResult)) {
431
-                    $this->poResult[$domain] = [];
431
+                    $this->poResult[ $domain ] = [ ];
432 432
                 }
433 433
 
434
-                if (!array_key_exists($str, $this->poResult[$domain])) {
435
-                    $this->poResult[$domain][$str] = [''];
434
+                if (!array_key_exists($str, $this->poResult[ $domain ])) {
435
+                    $this->poResult[ $domain ][ $str ] = [ '' ];
436 436
                 }
437 437
 
438
-                if (!in_array($ctx, $this->poResult[$domain][$str])) {
439
-                    $this->poResult[$domain][$str][] = $ctx;
438
+                if (!in_array($ctx, $this->poResult[ $domain ][ $str ])) {
439
+                    $this->poResult[ $domain ][ $str ][ ] = $ctx;
440 440
                 }
441 441
             }
442 442
         }
@@ -457,8 +457,8 @@  discard block
 block discarded – undo
457 457
                 if (!is_dir($file)) {
458 458
                     $f = new File($file);
459 459
                     $info = $f->info();
460
-                    if (isset($info['extension'])) {
461
-                        $this->parseFile($file, $info['extension']);
460
+                    if (isset($info[ 'extension' ])) {
461
+                        $this->parseFile($file, $info[ 'extension' ]);
462 462
                     }
463 463
                 }
464 464
             }
Please login to merge, or discard this patch.