@@ -69,14 +69,14 @@ discard block |
||
| 69 | 69 | * |
| 70 | 70 | * @var array |
| 71 | 71 | */ |
| 72 | - protected $poResult = []; |
|
| 72 | + protected $poResult = [ ]; |
|
| 73 | 73 | |
| 74 | 74 | /** |
| 75 | 75 | * The template paths |
| 76 | 76 | * |
| 77 | 77 | * @var array |
| 78 | 78 | */ |
| 79 | - protected $templatePaths = []; |
|
| 79 | + protected $templatePaths = [ ]; |
|
| 80 | 80 | |
| 81 | 81 | /** |
| 82 | 82 | * The locale path |
@@ -99,9 +99,9 @@ discard block |
||
| 99 | 99 | */ |
| 100 | 100 | public function update(): void |
| 101 | 101 | { |
| 102 | - $resCmd = []; |
|
| 102 | + $resCmd = [ ]; |
|
| 103 | 103 | exec('which msgmerge 2>&1', $resCmd); |
| 104 | - if (empty($resCmd[0])) { |
|
| 104 | + if (empty($resCmd[ 0 ])) { |
|
| 105 | 105 | $this->out('ERROR: msgmerge not available. Please install gettext utilities.'); |
| 106 | 106 | |
| 107 | 107 | return; |
@@ -136,26 +136,26 @@ discard block |
||
| 136 | 136 | private function setupPaths(): void |
| 137 | 137 | { |
| 138 | 138 | $appTemplates = (array)Configure::read('App.paths.templates'); |
| 139 | - if (isset($this->params['plugin'])) { |
|
| 140 | - $f = new Folder(sprintf('%s%s', (string)Configure::read('App.paths.plugins.0'), $this->params['plugin'])); |
|
| 139 | + if (isset($this->params[ 'plugin' ])) { |
|
| 140 | + $f = new Folder(sprintf('%s%s', (string)Configure::read('App.paths.plugins.0'), $this->params[ 'plugin' ])); |
|
| 141 | 141 | $basePath = $f->path; |
| 142 | - $this->poName = $this->params['plugin'] . '.po'; |
|
| 143 | - $this->templatePaths = [$basePath . '/src', $basePath . '/config']; |
|
| 142 | + $this->poName = $this->params[ 'plugin' ] . '.po'; |
|
| 143 | + $this->templatePaths = [ $basePath . '/src', $basePath . '/config' ]; |
|
| 144 | 144 | $appTemplatePath = (string)Hash::get($appTemplates, '1'); |
| 145 | 145 | if (strpos($appTemplatePath, $basePath . '/src') === false) { |
| 146 | - $this->templatePaths[] = $appTemplatePath; |
|
| 146 | + $this->templatePaths[ ] = $appTemplatePath; |
|
| 147 | 147 | } |
| 148 | 148 | $this->localePath = (string)Configure::read('App.paths.locales.1'); |
| 149 | 149 | |
| 150 | 150 | return; |
| 151 | 151 | } |
| 152 | - $app = $this->params['app'] ?? getcwd(); |
|
| 152 | + $app = $this->params[ 'app' ] ?? getcwd(); |
|
| 153 | 153 | $f = new Folder($app); |
| 154 | 154 | $basePath = $f->path; |
| 155 | - $this->templatePaths = [$basePath . '/src', $basePath . '/config']; |
|
| 155 | + $this->templatePaths = [ $basePath . '/src', $basePath . '/config' ]; |
|
| 156 | 156 | $appTemplatePath = (string)Hash::get($appTemplates, '0'); |
| 157 | 157 | if (strpos($appTemplatePath, $basePath . '/src') === false) { |
| 158 | - $this->templatePaths[] = $appTemplatePath; |
|
| 158 | + $this->templatePaths[ ] = $appTemplatePath; |
|
| 159 | 159 | } |
| 160 | 160 | $this->localePath = (string)Configure::read('App.paths.locales.0'); |
| 161 | 161 | } |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | { |
| 190 | 190 | $header = $this->header('po'); |
| 191 | 191 | $potFilename = sprintf('%s/master.pot', $this->localePath); |
| 192 | - $locales = array_keys((array)Configure::read('I18n.locales', [])); |
|
| 192 | + $locales = array_keys((array)Configure::read('I18n.locales', [ ])); |
|
| 193 | 193 | foreach ($locales as $loc) { |
| 194 | 194 | $potDir = $this->localePath . DS . $loc; |
| 195 | 195 | if (!file_exists($potDir)) { |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | 'Content-Type' => 'text/plain; charset=utf-8', |
| 244 | 244 | ], |
| 245 | 245 | ]; |
| 246 | - foreach ($contents[$type] as $k => $v) { |
|
| 246 | + foreach ($contents[ $type ] as $k => $v) { |
|
| 247 | 247 | $result .= sprintf('"%s: %s \n"', $k, $v) . "\n"; |
| 248 | 248 | } |
| 249 | 249 | |
@@ -265,9 +265,9 @@ discard block |
||
| 265 | 265 | $numItems++; |
| 266 | 266 | } |
| 267 | 267 | if (strpos($l, 'msgstr ""') === 0) { |
| 268 | - if (!isset($lines[$k + 1])) { |
|
| 268 | + if (!isset($lines[ $k + 1 ])) { |
|
| 269 | 269 | $numNotTranslated++; |
| 270 | - } elseif (strpos($lines[$k + 1], '"') !== 0) { |
|
| 270 | + } elseif (strpos($lines[ $k + 1 ], '"') !== 0) { |
|
| 271 | 271 | $numNotTranslated++; |
| 272 | 272 | } |
| 273 | 273 | } |
@@ -305,7 +305,7 @@ discard block |
||
| 305 | 305 | */ |
| 306 | 306 | private function parseFile($file, $extension) |
| 307 | 307 | { |
| 308 | - if (!in_array($extension, ['php', 'twig'])) { |
|
| 308 | + if (!in_array($extension, [ 'php', 'twig' ])) { |
|
| 309 | 309 | return; |
| 310 | 310 | } |
| 311 | 311 | $content = file_get_contents($file); |
@@ -357,22 +357,22 @@ discard block |
||
| 357 | 357 | { |
| 358 | 358 | // phpcs:disable |
| 359 | 359 | $rgxp = '/' . |
| 360 | - "${start}\s*{$options['open_parenthesis']}\s*{$options['double_quote']}" . "([^{$options['double_quote']}]*)" . "{$options['double_quote']}" . |
|
| 360 | + "${start}\s*{$options[ 'open_parenthesis' ]}\s*{$options[ 'double_quote' ]}" . "([^{$options[ 'double_quote' ]}]*)" . "{$options[ 'double_quote' ]}" . |
|
| 361 | 361 | '|' . |
| 362 | - "${start}\s*{$options['open_parenthesis']}\s*{$options['quote']}" . "([^{$options['quote']}]*)" . "{$options['quote']}" . |
|
| 362 | + "${start}\s*{$options[ 'open_parenthesis' ]}\s*{$options[ 'quote' ]}" . "([^{$options[ 'quote' ]}]*)" . "{$options[ 'quote' ]}" . |
|
| 363 | 363 | '/'; |
| 364 | 364 | // phpcs:enable |
| 365 | - $matches = []; |
|
| 365 | + $matches = [ ]; |
|
| 366 | 366 | preg_match_all($rgxp, $content, $matches); |
| 367 | 367 | |
| 368 | - $limit = count($matches[0]); |
|
| 368 | + $limit = count($matches[ 0 ]); |
|
| 369 | 369 | for ($i = 0; $i < $limit; $i++) { |
| 370 | - $item = $this->fixString($matches[1][$i]); |
|
| 370 | + $item = $this->fixString($matches[ 1 ][ $i ]); |
|
| 371 | 371 | if (empty($item)) { |
| 372 | - $item = $this->fixString($matches[2][$i]); |
|
| 372 | + $item = $this->fixString($matches[ 2 ][ $i ]); |
|
| 373 | 373 | } |
| 374 | 374 | if (!in_array($item, $this->poResult)) { |
| 375 | - $this->poResult[] = $item; |
|
| 375 | + $this->poResult[ ] = $item; |
|
| 376 | 376 | } |
| 377 | 377 | } |
| 378 | 378 | } |
@@ -389,26 +389,26 @@ discard block |
||
| 389 | 389 | { |
| 390 | 390 | // phpcs:disable |
| 391 | 391 | $rgxp = |
| 392 | - '/' . "${start}\s*{$options['open_parenthesis']}\s*{$options['double_quote']}" . '([^{)}]*)' . "{$options['double_quote']}" . |
|
| 393 | - '|' . "${start}\s*{$options['open_parenthesis']}\s*{$options['quote']}" . '([^{)}]*)' . "{$options['quote']}" . |
|
| 392 | + '/' . "${start}\s*{$options[ 'open_parenthesis' ]}\s*{$options[ 'double_quote' ]}" . '([^{)}]*)' . "{$options[ 'double_quote' ]}" . |
|
| 393 | + '|' . "${start}\s*{$options[ 'open_parenthesis' ]}\s*{$options[ 'quote' ]}" . '([^{)}]*)' . "{$options[ 'quote' ]}" . |
|
| 394 | 394 | '/'; |
| 395 | 395 | // phpcs:enable |
| 396 | - $matches = []; |
|
| 396 | + $matches = [ ]; |
|
| 397 | 397 | preg_match_all($rgxp, $content, $matches); |
| 398 | 398 | |
| 399 | - $limit = count($matches[0]); |
|
| 399 | + $limit = count($matches[ 0 ]); |
|
| 400 | 400 | for ($i = 0; $i < $limit; $i++) { |
| 401 | - $str = $matches[2][$i]; |
|
| 402 | - if (substr_count($matches[2][0], ',') === 1) { |
|
| 401 | + $str = $matches[ 2 ][ $i ]; |
|
| 402 | + if (substr_count($matches[ 2 ][ 0 ], ',') === 1) { |
|
| 403 | 403 | $str = substr(trim(substr($str, strpos($str, ',') + 1)), 1); |
| 404 | - } elseif (substr_count($matches[2][0], ',') === 2) { |
|
| 404 | + } elseif (substr_count($matches[ 2 ][ 0 ], ',') === 2) { |
|
| 405 | 405 | $str = trim(substr($str, strpos($str, ',') + 1)); |
| 406 | 406 | $str = trim(substr($str, 0, strpos($str, ','))); |
| 407 | 407 | $str = substr($str, 1, -1); |
| 408 | 408 | } |
| 409 | 409 | $item = $this->fixString($str); |
| 410 | 410 | if (!in_array($item, $this->poResult)) { |
| 411 | - $this->poResult[] = $item; |
|
| 411 | + $this->poResult[ ] = $item; |
|
| 412 | 412 | } |
| 413 | 413 | } |
| 414 | 414 | } |
@@ -425,16 +425,16 @@ discard block |
||
| 425 | 425 | { |
| 426 | 426 | // phpcs:disable |
| 427 | 427 | $rgxp = |
| 428 | - '/' . "${start}\s*{$options['open_parenthesis']}\s*{$options['double_quote']}" . '([^{)}]*)' . "{$options['double_quote']}" . |
|
| 429 | - '|' . "${start}\s*{$options['open_parenthesis']}\s*{$options['quote']}" . '([^{)}]*)' . "{$options['quote']}" . |
|
| 428 | + '/' . "${start}\s*{$options[ 'open_parenthesis' ]}\s*{$options[ 'double_quote' ]}" . '([^{)}]*)' . "{$options[ 'double_quote' ]}" . |
|
| 429 | + '|' . "${start}\s*{$options[ 'open_parenthesis' ]}\s*{$options[ 'quote' ]}" . '([^{)}]*)' . "{$options[ 'quote' ]}" . |
|
| 430 | 430 | '/'; |
| 431 | 431 | // phpcs:enable |
| 432 | - $matches = []; |
|
| 432 | + $matches = [ ]; |
|
| 433 | 433 | preg_match_all($rgxp, $content, $matches); |
| 434 | 434 | |
| 435 | - $limit = count($matches[0]); |
|
| 435 | + $limit = count($matches[ 0 ]); |
|
| 436 | 436 | for ($i = 0; $i < $limit; $i++) { |
| 437 | - $str = $matches[2][$i]; |
|
| 437 | + $str = $matches[ 2 ][ $i ]; |
|
| 438 | 438 | $pos = $this->strposX($str, ',', 2); |
| 439 | 439 | $str = trim(substr($str, $pos + 1)); |
| 440 | 440 | if (strpos($str, ',') > 0) { |
@@ -444,7 +444,7 @@ discard block |
||
| 444 | 444 | } |
| 445 | 445 | $item = $this->fixString($str); |
| 446 | 446 | if (!in_array($item, $this->poResult)) { |
| 447 | - $this->poResult[] = $item; |
|
| 447 | + $this->poResult[ ] = $item; |
|
| 448 | 448 | } |
| 449 | 449 | } |
| 450 | 450 | } |
@@ -482,8 +482,8 @@ discard block |
||
| 482 | 482 | if (!is_dir($file)) { |
| 483 | 483 | $f = new File($file); |
| 484 | 484 | $info = $f->info(); |
| 485 | - if (isset($info['extension'])) { |
|
| 486 | - $this->parseFile($file, $info['extension']); |
|
| 485 | + if (isset($info[ 'extension' ])) { |
|
| 486 | + $this->parseFile($file, $info[ 'extension' ]); |
|
| 487 | 487 | } |
| 488 | 488 | } |
| 489 | 489 | } |
@@ -507,9 +507,9 @@ discard block |
||
| 507 | 507 | } |
| 508 | 508 | // check template folder exists |
| 509 | 509 | $appDir = 'src/Template'; |
| 510 | - if (!empty($this->params['plugin'])) { |
|
| 511 | - $startPath = !empty($this->params['startPath']) ? $this->params['startPath'] : getcwd(); |
|
| 512 | - $appDir = sprintf('%s/plugins/%s/src/Template', $startPath, $this->params['plugin']); |
|
| 510 | + if (!empty($this->params[ 'plugin' ])) { |
|
| 511 | + $startPath = !empty($this->params[ 'startPath' ]) ? $this->params[ 'startPath' ] : getcwd(); |
|
| 512 | + $appDir = sprintf('%s/plugins/%s/src/Template', $startPath, $this->params[ 'plugin' ]); |
|
| 513 | 513 | } |
| 514 | 514 | if (!file_exists($appDir)) { |
| 515 | 515 | $this->out(sprintf('Skip javascript parsing - %s folder not found', $appDir)); |