Passed
Push — master ( ae5b91...c43fb3 )
by Alberto
01:55
created
src/Core/I18nTrait.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
      */
44 44
     public function getLocales(): array
45 45
     {
46
-        return (array)Configure::read('I18n.locales', []);
46
+        return (array)Configure::read('I18n.locales', [ ]);
47 47
     }
48 48
 
49 49
     /**
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
      */
56 56
     public function getLanguages(): array
57 57
     {
58
-        return (array)Configure::read('I18n.languages', []);
58
+        return (array)Configure::read('I18n.languages', [ ]);
59 59
     }
60 60
 
61 61
     /**
Please login to merge, or discard this patch.
src/Plugin.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@
 block discarded – undo
64 64
          */
65 65
         $middlewareQueue->insertBefore(
66 66
             RoutingMiddleware::class,
67
-            new I18nMiddleware((array)Configure::read('I18n', []))
67
+            new I18nMiddleware((array)Configure::read('I18n', [ ]))
68 68
         );
69 69
 
70 70
         return $middlewareQueue;
Please login to merge, or discard this patch.
src/Routing/Route/I18nRoute.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -29,12 +29,12 @@  discard block
 block discarded – undo
29 29
     /**
30 30
      * @inheritDoc
31 31
      */
32
-    public function __construct($template, $defaults = [], array $options = [])
32
+    public function __construct($template, $defaults = [ ], array $options = [ ])
33 33
     {
34 34
         parent::__construct($this->buildTemplate($template), $defaults, $options);
35 35
 
36
-        if (empty($options['lang'])) {
37
-            $this->setPatterns(['lang' => implode('|', array_keys($this->getLanguages()))]);
36
+        if (empty($options[ 'lang' ])) {
37
+            $this->setPatterns([ 'lang' => implode('|', array_keys($this->getLanguages())) ]);
38 38
         }
39 39
     }
40 40
 
@@ -62,10 +62,10 @@  discard block
 block discarded – undo
62 62
     /**
63 63
      * @inheritDoc
64 64
      */
65
-    public function match(array $url, array $context = []): ?string
65
+    public function match(array $url, array $context = [ ]): ?string
66 66
     {
67 67
         if (!array_key_exists('lang', $url)) {
68
-            $url['lang'] = $this->getLang();
68
+            $url[ 'lang' ] = $this->getLang();
69 69
         }
70 70
 
71 71
         return parent::match($url, $context) ?: null;
Please login to merge, or discard this patch.
src/View/Helper/I18nHelper.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
     /**
34 34
      * @inheritDoc
35 35
      */
36
-    public $helpers = ['Html', 'Url'];
36
+    public $helpers = [ 'Html', 'Url' ];
37 37
 
38 38
     /**
39 39
      * Translation data per object and lang (internal cache).
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
         string $attribute,
165 165
         ?string $lang = null,
166 166
         bool $defaultNull = false,
167
-        array $included = []
167
+        array $included = [ ]
168 168
     ): ?string {
169 169
         $defaultValue = null;
170 170
         if (!$defaultNull) {
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
      * @param array $included The included translations data)
198 198
      * @return bool
199 199
      */
200
-    public function exists(array $object, string $attribute, ?string $lang = null, array &$included = []): bool
200
+    public function exists(array $object, string $attribute, ?string $lang = null, array &$included = [ ]): bool
201 201
     {
202 202
         if (empty($included) && !empty($this->_View->get('included'))) {
203 203
             $included = $this->_View->get('included');
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
         // first look if embedded relationships are set
242 242
         if (Hash::check($object, 'relationships.translations.data.0.attributes')) {
243 243
             $translations = Hash::combine(
244
-                $object['relationships']['translations']['data'],
244
+                $object[ 'relationships' ][ 'translations' ][ 'data' ],
245 245
                 '{n}.attributes.lang',
246 246
                 '{n}.attributes.translated_fields'
247 247
             );
@@ -249,11 +249,11 @@  discard block
 block discarded – undo
249 249
             return Hash::get($translations, sprintf('%s.%s', $lang, $attribute));
250 250
         }
251 251
 
252
-        if (empty($object['id'])) {
252
+        if (empty($object[ 'id' ])) {
253 253
             return null;
254 254
         }
255 255
 
256
-        $id = $object['id'];
256
+        $id = $object[ 'id' ];
257 257
 
258 258
         if ($this->translation === null) {
259 259
             $translations = Hash::combine($included, '{n}.id', '{n}.attributes', '{n}.type');
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
      * @param array $options Array of options.
278 278
      * @return string Full I18n URL.
279 279
      */
280
-    public function buildUrl($path, $options = []): string
280
+    public function buildUrl($path, $options = [ ]): string
281 281
     {
282 282
         if (is_string($path) && !$this->isI18nPath($path)) {
283 283
             $path = sprintf('/%s%s', $this->getLang(), $path);
Please login to merge, or discard this patch.
src/Middleware/I18nMiddleware.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -58,8 +58,8 @@  discard block
 block discarded – undo
58 58
      * @var array
59 59
      */
60 60
     protected $_defaultConfig = [
61
-        'match' => [],
62
-        'startWith' => [],
61
+        'match' => [ ],
62
+        'startWith' => [ ],
63 63
         'switchLangUrl' => null,
64 64
         'cookie' => [
65 65
             'name' => null,
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
      *
75 75
      * @param array $config Configuration.
76 76
      */
77
-    public function __construct(array $config = [])
77
+    public function __construct(array $config = [ ])
78 78
     {
79 79
         $this->setConfig($config);
80 80
     }
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 
243 243
         $locale = array_search($new, $this->getLocales());
244 244
         if ($locale === false) {
245
-            throw new BadRequestException(__('Lang "{0}" not supported', [$new]));
245
+            throw new BadRequestException(__('Lang "{0}" not supported', [ $new ]));
246 246
         }
247 247
 
248 248
         $this->updateSession($request, $locale);
Please login to merge, or discard this patch.
src/Command/GettextCommand.php 1 patch
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -37,14 +37,14 @@  discard block
 block discarded – undo
37 37
      *
38 38
      * @var array
39 39
      */
40
-    protected $poResult = [];
40
+    protected $poResult = [ ];
41 41
 
42 42
     /**
43 43
      * The template paths
44 44
      *
45 45
      * @var array
46 46
      */
47
-    protected $templatePaths = [];
47
+    protected $templatePaths = [ ];
48 48
 
49 49
     /**
50 50
      * The locale path
@@ -124,9 +124,9 @@  discard block
 block discarded – undo
124 124
      */
125 125
     public function execute(Arguments $args, ConsoleIo $io)
126 126
     {
127
-        $resCmd = [];
127
+        $resCmd = [ ];
128 128
         exec('which msgmerge 2>&1', $resCmd);
129
-        if (empty($resCmd[0])) {
129
+        if (empty($resCmd[ 0 ])) {
130 130
             $io->abort('ERROR: msgmerge not available. Please install gettext utilities.');
131 131
         }
132 132
 
@@ -181,9 +181,9 @@  discard block
 block discarded – undo
181 181
         }
182 182
         $app = $args->getOption('app');
183 183
         $basePath = $app ?? getcwd();
184
-        $this->templatePaths = [$basePath . DS . 'src', $basePath . DS . 'config'];
184
+        $this->templatePaths = [ $basePath . DS . 'src', $basePath . DS . 'config' ];
185 185
         $this->templatePaths = array_merge($this->templatePaths, App::path(View::NAME_TEMPLATE));
186
-        $this->templatePaths = array_filter($this->templatePaths, function ($path) {
186
+        $this->templatePaths = array_filter($this->templatePaths, function($path) {
187 187
             return strpos($path, 'plugins') === false;
188 188
         });
189 189
         $this->localePath = (string)Hash::get($localesPaths, 0);
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
     private function writePoFiles(ConsoleIo $io): void
222 222
     {
223 223
         $header = $this->header('po');
224
-        $locales = array_keys((array)Configure::read('I18n.locales', []));
224
+        $locales = array_keys((array)Configure::read('I18n.locales', [ ]));
225 225
         foreach ($locales as $loc) {
226 226
             $potDir = $this->localePath . DS . $loc;
227 227
             if (!file_exists($potDir)) {
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
                 'Content-Type' => 'text/plain; charset=utf-8',
280 280
             ],
281 281
         ];
282
-        foreach ($contents[$type] as $k => $v) {
282
+        foreach ($contents[ $type ] as $k => $v) {
283 283
             $result .= sprintf('"%s: %s \n"', $k, $v) . "\n";
284 284
         }
285 285
 
@@ -302,9 +302,9 @@  discard block
 block discarded – undo
302 302
                 $numItems++;
303 303
             }
304 304
             if (strpos($l, 'msgstr ""') === 0) {
305
-                if (!isset($lines[$k + 1])) {
305
+                if (!isset($lines[ $k + 1 ])) {
306 306
                     $numNotTranslated++;
307
-                } elseif (strpos($lines[$k + 1], '"') !== 0) {
307
+                } elseif (strpos($lines[ $k + 1 ], '"') !== 0) {
308 308
                     $numNotTranslated++;
309 309
                 }
310 310
             }
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
      */
343 343
     private function parseFile($file, $extension)
344 344
     {
345
-        if (!in_array($extension, ['php', 'twig'])) {
345
+        if (!in_array($extension, [ 'php', 'twig' ])) {
346 346
             return;
347 347
         }
348 348
         $content = file_get_contents($file);
@@ -394,29 +394,29 @@  discard block
 block discarded – undo
394 394
     {
395 395
         // phpcs:disable
396 396
         $rgxp = '/' .
397
-            "${start}\s*{$options['open_parenthesis']}\s*{$options['double_quote']}" . "([^{$options['double_quote']}]*)" . "{$options['double_quote']}" .
397
+            "${start}\s*{$options[ 'open_parenthesis' ]}\s*{$options[ 'double_quote' ]}" . "([^{$options[ 'double_quote' ]}]*)" . "{$options[ 'double_quote' ]}" .
398 398
             '|' .
399
-            "${start}\s*{$options['open_parenthesis']}\s*{$options['quote']}" . "([^{$options['quote']}]*)" . "{$options['quote']}" .
399
+            "${start}\s*{$options[ 'open_parenthesis' ]}\s*{$options[ 'quote' ]}" . "([^{$options[ 'quote' ]}]*)" . "{$options[ 'quote' ]}" .
400 400
             '/';
401 401
         // phpcs:enable
402
-        $matches = [];
402
+        $matches = [ ];
403 403
         preg_match_all($rgxp, $content, $matches);
404 404
 
405 405
         $domain = $this->defaultDomain;
406 406
 
407
-        $limit = count($matches[0]);
407
+        $limit = count($matches[ 0 ]);
408 408
         for ($i = 0; $i < $limit; $i++) {
409
-            $item = $this->fixString($matches[1][$i]);
409
+            $item = $this->fixString($matches[ 1 ][ $i ]);
410 410
             if (empty($item)) {
411
-                $item = $this->fixString($matches[2][$i]);
411
+                $item = $this->fixString($matches[ 2 ][ $i ]);
412 412
             }
413 413
 
414 414
             if (!array_key_exists($domain, $this->poResult)) {
415
-                $this->poResult[$domain] = [];
415
+                $this->poResult[ $domain ] = [ ];
416 416
             }
417 417
 
418
-            if (!in_array($item, $this->poResult[$domain])) {
419
-                $this->poResult[$domain][] = $item;
418
+            if (!in_array($item, $this->poResult[ $domain ])) {
419
+                $this->poResult[ $domain ][ ] = $item;
420 420
             }
421 421
         }
422 422
     }
@@ -432,22 +432,22 @@  discard block
 block discarded – undo
432 432
     private function parseContentSecondArg($start, $content, $options): void
433 433
     {
434 434
         $capturePath = "([^']*)',\s*'([^']*)";
435
-        $doubleQuoteCapture = str_replace("'", $options['double_quote'], $capturePath);
436
-        $quoteCapture = str_replace("'", $options['quote'], $capturePath);
435
+        $doubleQuoteCapture = str_replace("'", $options[ 'double_quote' ], $capturePath);
436
+        $quoteCapture = str_replace("'", $options[ 'quote' ], $capturePath);
437 437
 
438 438
         // phpcs:disable
439 439
         $rgxp =
440
-            '/' . "${start}\s*{$options['open_parenthesis']}\s*{$options['double_quote']}" . $doubleQuoteCapture . "{$options['double_quote']}" .
441
-            '|' . "${start}\s*{$options['open_parenthesis']}\s*{$options['quote']}" . $quoteCapture . "{$options['quote']}" .
440
+            '/' . "${start}\s*{$options[ 'open_parenthesis' ]}\s*{$options[ 'double_quote' ]}" . $doubleQuoteCapture . "{$options[ 'double_quote' ]}" .
441
+            '|' . "${start}\s*{$options[ 'open_parenthesis' ]}\s*{$options[ 'quote' ]}" . $quoteCapture . "{$options[ 'quote' ]}" .
442 442
             '/';
443 443
         // phpcs:enable
444
-        $matches = [];
444
+        $matches = [ ];
445 445
         preg_match_all($rgxp, $content, $matches);
446 446
 
447
-        $limit = count($matches[0]);
447
+        $limit = count($matches[ 0 ]);
448 448
         for ($i = 0; $i < $limit; $i++) {
449
-            $domain = $matches[3][$i];
450
-            $str = $matches[4][$i];
449
+            $domain = $matches[ 3 ][ $i ];
450
+            $str = $matches[ 4 ][ $i ];
451 451
 
452 452
             // context not handled for now
453 453
             if (strpos($start, '__x') === 0) {
@@ -457,11 +457,11 @@  discard block
 block discarded – undo
457 457
             $item = $this->fixString($str);
458 458
 
459 459
             if (!array_key_exists($domain, $this->poResult)) {
460
-                $this->poResult[$domain] = [];
460
+                $this->poResult[ $domain ] = [ ];
461 461
             }
462 462
 
463
-            if (!in_array($item, $this->poResult[$domain])) {
464
-                $this->poResult[$domain][] = $item;
463
+            if (!in_array($item, $this->poResult[ $domain ])) {
464
+                $this->poResult[ $domain ][ ] = $item;
465 465
             }
466 466
         }
467 467
     }
@@ -478,18 +478,18 @@  discard block
 block discarded – undo
478 478
     {
479 479
         // phpcs:disable
480 480
         $rgxp =
481
-            '/' . "${start}\s*{$options['open_parenthesis']}\s*{$options['double_quote']}" . '([^{)}]*)' . "{$options['double_quote']}" .
482
-            '|' . "${start}\s*{$options['open_parenthesis']}\s*{$options['quote']}" . '([^{)}]*)' . "{$options['quote']}" .
481
+            '/' . "${start}\s*{$options[ 'open_parenthesis' ]}\s*{$options[ 'double_quote' ]}" . '([^{)}]*)' . "{$options[ 'double_quote' ]}" .
482
+            '|' . "${start}\s*{$options[ 'open_parenthesis' ]}\s*{$options[ 'quote' ]}" . '([^{)}]*)' . "{$options[ 'quote' ]}" .
483 483
             '/';
484 484
         // phpcs:enable
485
-        $matches = [];
485
+        $matches = [ ];
486 486
         preg_match_all($rgxp, $content, $matches);
487 487
 
488 488
         $domain = $this->defaultDomain; // domain and context not handled yet
489 489
 
490
-        $limit = count($matches[0]);
490
+        $limit = count($matches[ 0 ]);
491 491
         for ($i = 0; $i < $limit; $i++) {
492
-            $str = $matches[2][$i];
492
+            $str = $matches[ 2 ][ $i ];
493 493
             $pos = $this->strposX($str, ',', 2);
494 494
             $str = trim(substr($str, $pos + 1));
495 495
             if (strpos($str, ',') > 0) {
@@ -500,11 +500,11 @@  discard block
 block discarded – undo
500 500
             $item = $this->fixString($str);
501 501
 
502 502
             if (!array_key_exists($domain, $this->poResult)) {
503
-                $this->poResult[$domain] = [];
503
+                $this->poResult[ $domain ] = [ ];
504 504
             }
505 505
 
506
-            if (!in_array($item, $this->poResult[$domain])) {
507
-                $this->poResult[$domain][] = $item;
506
+            if (!in_array($item, $this->poResult[ $domain ])) {
507
+                $this->poResult[ $domain ][ ] = $item;
508 508
             }
509 509
         }
510 510
     }
@@ -542,8 +542,8 @@  discard block
 block discarded – undo
542 542
                 if (!is_dir($file)) {
543 543
                     $f = new File($file);
544 544
                     $info = $f->info();
545
-                    if (isset($info['extension'])) {
546
-                        $this->parseFile($file, $info['extension']);
545
+                    if (isset($info[ 'extension' ])) {
546
+                        $this->parseFile($file, $info[ 'extension' ]);
547 547
                     }
548 548
                 }
549 549
             }
Please login to merge, or discard this patch.