@@ -58,8 +58,8 @@ discard block |
||
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 |
||
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 |
||
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); |
@@ -68,14 +68,14 @@ discard block |
||
68 | 68 | * |
69 | 69 | * @var array |
70 | 70 | */ |
71 | - protected $poResult = []; |
|
71 | + protected $poResult = [ ]; |
|
72 | 72 | |
73 | 73 | /** |
74 | 74 | * The template paths |
75 | 75 | * |
76 | 76 | * @var array |
77 | 77 | */ |
78 | - protected $templatePaths = []; |
|
78 | + protected $templatePaths = [ ]; |
|
79 | 79 | |
80 | 80 | /** |
81 | 81 | * The locale path |
@@ -98,9 +98,9 @@ discard block |
||
98 | 98 | */ |
99 | 99 | public function update(): void |
100 | 100 | { |
101 | - $resCmd = []; |
|
101 | + $resCmd = [ ]; |
|
102 | 102 | exec('which msgmerge 2>&1', $resCmd); |
103 | - if (empty($resCmd[0])) { |
|
103 | + if (empty($resCmd[ 0 ])) { |
|
104 | 104 | $this->out('ERROR: msgmerge not available. Please install gettext utilities.'); |
105 | 105 | |
106 | 106 | return; |
@@ -135,14 +135,14 @@ discard block |
||
135 | 135 | private function setupPaths(): void |
136 | 136 | { |
137 | 137 | $basePath = getcwd(); |
138 | - if (isset($this->params['app'])) { |
|
139 | - $f = new Folder($this->params['app']); |
|
138 | + if (isset($this->params[ 'app' ])) { |
|
139 | + $f = new Folder($this->params[ 'app' ]); |
|
140 | 140 | $basePath = $f->path; |
141 | - } elseif (isset($this->params['plugin'])) { |
|
142 | - $startPath = !empty($this->params['startPath']) ? $this->params['startPath'] : getcwd(); |
|
143 | - $f = new Folder(sprintf('%s/plugins/%s', $startPath, $this->params['plugin'])); |
|
141 | + } elseif (isset($this->params[ 'plugin' ])) { |
|
142 | + $startPath = !empty($this->params[ 'startPath' ]) ? $this->params[ 'startPath' ] : getcwd(); |
|
143 | + $f = new Folder(sprintf('%s/plugins/%s', $startPath, $this->params[ 'plugin' ])); |
|
144 | 144 | $basePath = $f->path; |
145 | - $this->poName = $this->params['plugin'] . '.po'; |
|
145 | + $this->poName = $this->params[ 'plugin' ] . '.po'; |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | $this->templatePaths = [ |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | { |
183 | 183 | $header = $this->header('po'); |
184 | 184 | $potFilename = sprintf('%s/master.pot', $this->localePath); |
185 | - $locales = array_keys((array)Configure::read('I18n.locales', [])); |
|
185 | + $locales = array_keys((array)Configure::read('I18n.locales', [ ])); |
|
186 | 186 | foreach ($locales as $loc) { |
187 | 187 | $potDir = $this->localePath . DS . $loc; |
188 | 188 | if (!file_exists($potDir)) { |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | 'Content-Type' => 'text/plain; charset=utf-8', |
237 | 237 | ], |
238 | 238 | ]; |
239 | - foreach ($contents[$type] as $k => $v) { |
|
239 | + foreach ($contents[ $type ] as $k => $v) { |
|
240 | 240 | $result .= sprintf('"%s: %s \n"', $k, $v) . "\n"; |
241 | 241 | } |
242 | 242 | |
@@ -258,9 +258,9 @@ discard block |
||
258 | 258 | $numItems++; |
259 | 259 | } |
260 | 260 | if (strpos($l, 'msgstr ""') === 0) { |
261 | - if (!isset($lines[$k + 1])) { |
|
261 | + if (!isset($lines[ $k + 1 ])) { |
|
262 | 262 | $numNotTranslated++; |
263 | - } elseif (strpos($lines[$k + 1], '"') !== 0) { |
|
263 | + } elseif (strpos($lines[ $k + 1 ], '"') !== 0) { |
|
264 | 264 | $numNotTranslated++; |
265 | 265 | } |
266 | 266 | } |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | */ |
299 | 299 | private function parseFile($file, $extension) |
300 | 300 | { |
301 | - if (!in_array($extension, ['php', 'twig'])) { |
|
301 | + if (!in_array($extension, [ 'php', 'twig' ])) { |
|
302 | 302 | return; |
303 | 303 | } |
304 | 304 | $content = file_get_contents($file); |
@@ -350,22 +350,22 @@ discard block |
||
350 | 350 | { |
351 | 351 | // phpcs:disable |
352 | 352 | $rgxp = '/' . |
353 | - "${start}\s*{$options['open_parenthesis']}\s*{$options['double_quote']}" . "([^{$options['double_quote']}]*)" . "{$options['double_quote']}" . |
|
353 | + "${start}\s*{$options[ 'open_parenthesis' ]}\s*{$options[ 'double_quote' ]}" . "([^{$options[ 'double_quote' ]}]*)" . "{$options[ 'double_quote' ]}" . |
|
354 | 354 | '|' . |
355 | - "${start}\s*{$options['open_parenthesis']}\s*{$options['quote']}" . "([^{$options['quote']}]*)" . "{$options['quote']}" . |
|
355 | + "${start}\s*{$options[ 'open_parenthesis' ]}\s*{$options[ 'quote' ]}" . "([^{$options[ 'quote' ]}]*)" . "{$options[ 'quote' ]}" . |
|
356 | 356 | '/'; |
357 | 357 | // phpcs:enable |
358 | - $matches = []; |
|
358 | + $matches = [ ]; |
|
359 | 359 | preg_match_all($rgxp, $content, $matches); |
360 | 360 | |
361 | - $limit = count($matches[0]); |
|
361 | + $limit = count($matches[ 0 ]); |
|
362 | 362 | for ($i = 0; $i < $limit; $i++) { |
363 | - $item = $this->fixString($matches[1][$i]); |
|
363 | + $item = $this->fixString($matches[ 1 ][ $i ]); |
|
364 | 364 | if (empty($item)) { |
365 | - $item = $this->fixString($matches[2][$i]); |
|
365 | + $item = $this->fixString($matches[ 2 ][ $i ]); |
|
366 | 366 | } |
367 | 367 | if (!in_array($item, $this->poResult)) { |
368 | - $this->poResult[] = $item; |
|
368 | + $this->poResult[ ] = $item; |
|
369 | 369 | } |
370 | 370 | } |
371 | 371 | } |
@@ -382,26 +382,26 @@ discard block |
||
382 | 382 | { |
383 | 383 | // phpcs:disable |
384 | 384 | $rgxp = |
385 | - '/' . "${start}\s*{$options['open_parenthesis']}\s*{$options['double_quote']}" . '([^{)}]*)' . "{$options['double_quote']}" . |
|
386 | - '|' . "${start}\s*{$options['open_parenthesis']}\s*{$options['quote']}" . '([^{)}]*)' . "{$options['quote']}" . |
|
385 | + '/' . "${start}\s*{$options[ 'open_parenthesis' ]}\s*{$options[ 'double_quote' ]}" . '([^{)}]*)' . "{$options[ 'double_quote' ]}" . |
|
386 | + '|' . "${start}\s*{$options[ 'open_parenthesis' ]}\s*{$options[ 'quote' ]}" . '([^{)}]*)' . "{$options[ 'quote' ]}" . |
|
387 | 387 | '/'; |
388 | 388 | // phpcs:enable |
389 | - $matches = []; |
|
389 | + $matches = [ ]; |
|
390 | 390 | preg_match_all($rgxp, $content, $matches); |
391 | 391 | |
392 | - $limit = count($matches[0]); |
|
392 | + $limit = count($matches[ 0 ]); |
|
393 | 393 | for ($i = 0; $i < $limit; $i++) { |
394 | - $str = $matches[2][$i]; |
|
395 | - if (substr_count($matches[2][0], ',') === 1) { |
|
394 | + $str = $matches[ 2 ][ $i ]; |
|
395 | + if (substr_count($matches[ 2 ][ 0 ], ',') === 1) { |
|
396 | 396 | $str = substr(trim(substr($str, strpos($str, ',') + 1)), 1); |
397 | - } elseif (substr_count($matches[2][0], ',') === 2) { |
|
397 | + } elseif (substr_count($matches[ 2 ][ 0 ], ',') === 2) { |
|
398 | 398 | $str = trim(substr($str, strpos($str, ',') + 1)); |
399 | 399 | $str = trim(substr($str, 0, strpos($str, ','))); |
400 | 400 | $str = substr($str, 1, -1); |
401 | 401 | } |
402 | 402 | $item = $this->fixString($str); |
403 | 403 | if (!in_array($item, $this->poResult)) { |
404 | - $this->poResult[] = $item; |
|
404 | + $this->poResult[ ] = $item; |
|
405 | 405 | } |
406 | 406 | } |
407 | 407 | } |
@@ -418,16 +418,16 @@ discard block |
||
418 | 418 | { |
419 | 419 | // phpcs:disable |
420 | 420 | $rgxp = |
421 | - '/' . "${start}\s*{$options['open_parenthesis']}\s*{$options['double_quote']}" . '([^{)}]*)' . "{$options['double_quote']}" . |
|
422 | - '|' . "${start}\s*{$options['open_parenthesis']}\s*{$options['quote']}" . '([^{)}]*)' . "{$options['quote']}" . |
|
421 | + '/' . "${start}\s*{$options[ 'open_parenthesis' ]}\s*{$options[ 'double_quote' ]}" . '([^{)}]*)' . "{$options[ 'double_quote' ]}" . |
|
422 | + '|' . "${start}\s*{$options[ 'open_parenthesis' ]}\s*{$options[ 'quote' ]}" . '([^{)}]*)' . "{$options[ 'quote' ]}" . |
|
423 | 423 | '/'; |
424 | 424 | // phpcs:enable |
425 | - $matches = []; |
|
425 | + $matches = [ ]; |
|
426 | 426 | preg_match_all($rgxp, $content, $matches); |
427 | 427 | |
428 | - $limit = count($matches[0]); |
|
428 | + $limit = count($matches[ 0 ]); |
|
429 | 429 | for ($i = 0; $i < $limit; $i++) { |
430 | - $str = $matches[2][$i]; |
|
430 | + $str = $matches[ 2 ][ $i ]; |
|
431 | 431 | $pos = $this->strposX($str, ',', 2); |
432 | 432 | $str = trim(substr($str, $pos + 1)); |
433 | 433 | if (strpos($str, ',') > 0) { |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | } |
438 | 438 | $item = $this->fixString($str); |
439 | 439 | if (!in_array($item, $this->poResult)) { |
440 | - $this->poResult[] = $item; |
|
440 | + $this->poResult[ ] = $item; |
|
441 | 441 | } |
442 | 442 | } |
443 | 443 | } |
@@ -475,8 +475,8 @@ discard block |
||
475 | 475 | if (!is_dir($file)) { |
476 | 476 | $f = new File($file); |
477 | 477 | $info = $f->info(); |
478 | - if (isset($info['extension'])) { |
|
479 | - $this->parseFile($file, $info['extension']); |
|
478 | + if (isset($info[ 'extension' ])) { |
|
479 | + $this->parseFile($file, $info[ 'extension' ]); |
|
480 | 480 | } |
481 | 481 | } |
482 | 482 | } |
@@ -500,9 +500,9 @@ discard block |
||
500 | 500 | } |
501 | 501 | // check template folder exists |
502 | 502 | $appDir = 'src/Template'; |
503 | - if (!empty($this->params['plugin'])) { |
|
504 | - $startPath = !empty($this->params['startPath']) ? $this->params['startPath'] : getcwd(); |
|
505 | - $appDir = sprintf('%s/plugins/%s/src/Template', $startPath, $this->params['plugin']); |
|
503 | + if (!empty($this->params[ 'plugin' ])) { |
|
504 | + $startPath = !empty($this->params[ 'startPath' ]) ? $this->params[ 'startPath' ] : getcwd(); |
|
505 | + $appDir = sprintf('%s/plugins/%s/src/Template', $startPath, $this->params[ 'plugin' ]); |
|
506 | 506 | } |
507 | 507 | if (!file_exists($appDir)) { |
508 | 508 | $this->out(sprintf('Skip javascript parsing - %s folder not found', $appDir)); |