@@ -43,7 +43,7 @@ discard block |
||
| 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 |
||
| 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 | /** |
@@ -64,7 +64,7 @@ |
||
| 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; |
@@ -55,8 +55,8 @@ discard block |
||
| 55 | 55 | * @var array |
| 56 | 56 | */ |
| 57 | 57 | protected $_defaultConfig = [ |
| 58 | - 'match' => [], |
|
| 59 | - 'startWith' => [], |
|
| 58 | + 'match' => [ ], |
|
| 59 | + 'startWith' => [ ], |
|
| 60 | 60 | 'switchLangUrl' => null, |
| 61 | 61 | 'cookie' => [ |
| 62 | 62 | 'name' => null, |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | * |
| 71 | 71 | * @param array $config Configuration. |
| 72 | 72 | */ |
| 73 | - public function __construct(array $config = []) |
|
| 73 | + public function __construct(array $config = [ ]) |
|
| 74 | 74 | { |
| 75 | 75 | $this->setConfig($config); |
| 76 | 76 | } |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | |
| 221 | 221 | $locale = array_search($new, $this->getLocales()); |
| 222 | 222 | if ($locale === false) { |
| 223 | - throw new BadRequestException(__('Lang "{0}" not supported', [$new])); |
|
| 223 | + throw new BadRequestException(__('Lang "{0}" not supported', [ $new ])); |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | $response = (new Response()) |
@@ -33,7 +33,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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'); |
@@ -238,11 +238,11 @@ discard block |
||
| 238 | 238 | */ |
| 239 | 239 | private function getTranslatedField(array $object, string $attribute, string $lang, array &$included): ?string |
| 240 | 240 | { |
| 241 | - if (empty($object['id'])) { |
|
| 241 | + if (empty($object[ 'id' ])) { |
|
| 242 | 242 | return null; |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | - $id = $object['id']; |
|
| 245 | + $id = $object[ 'id' ]; |
|
| 246 | 246 | |
| 247 | 247 | if ($this->translation === null) { |
| 248 | 248 | $translations = Hash::combine($included, '{n}.id', '{n}.attributes', '{n}.type'); |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | * @param array $options Array of options. |
| 267 | 267 | * @return string Full I18n URL. |
| 268 | 268 | */ |
| 269 | - public function buildUrl($path, $options = []): string |
|
| 269 | + public function buildUrl($path, $options = [ ]): string |
|
| 270 | 270 | { |
| 271 | 271 | if (is_string($path) && !$this->isI18nPath($path)) { |
| 272 | 272 | $path = sprintf('/%s%s', $this->getLang(), $path); |
@@ -65,14 +65,14 @@ discard block |
||
| 65 | 65 | * |
| 66 | 66 | * @var array |
| 67 | 67 | */ |
| 68 | - protected $poResult = []; |
|
| 68 | + protected $poResult = [ ]; |
|
| 69 | 69 | |
| 70 | 70 | /** |
| 71 | 71 | * The template paths |
| 72 | 72 | * |
| 73 | 73 | * @var array |
| 74 | 74 | */ |
| 75 | - protected $templatePaths = []; |
|
| 75 | + protected $templatePaths = [ ]; |
|
| 76 | 76 | |
| 77 | 77 | /** |
| 78 | 78 | * The locale path |
@@ -95,9 +95,9 @@ discard block |
||
| 95 | 95 | */ |
| 96 | 96 | public function update(): void |
| 97 | 97 | { |
| 98 | - $resCmd = []; |
|
| 98 | + $resCmd = [ ]; |
|
| 99 | 99 | exec('which msgmerge 2>&1', $resCmd); |
| 100 | - if (empty($resCmd[0])) { |
|
| 100 | + if (empty($resCmd[ 0 ])) { |
|
| 101 | 101 | $this->out('ERROR: msgmerge not available. Please install gettext utilities.'); |
| 102 | 102 | |
| 103 | 103 | return; |
@@ -132,14 +132,14 @@ discard block |
||
| 132 | 132 | private function setupPaths(): void |
| 133 | 133 | { |
| 134 | 134 | $basePath = getcwd(); |
| 135 | - if (isset($this->params['app'])) { |
|
| 136 | - $f = new Folder($this->params['app']); |
|
| 135 | + if (isset($this->params[ 'app' ])) { |
|
| 136 | + $f = new Folder($this->params[ 'app' ]); |
|
| 137 | 137 | $basePath = $f->path; |
| 138 | - } elseif (isset($this->params['plugin'])) { |
|
| 139 | - $startPath = $this->params['startPath'] ? $this->params['startPath'] : getcwd(); |
|
| 140 | - $f = new Folder(sprintf('%s/plugins/%s', $startPath, $this->params['plugin'])); |
|
| 138 | + } elseif (isset($this->params[ 'plugin' ])) { |
|
| 139 | + $startPath = $this->params[ 'startPath' ] ? $this->params[ 'startPath' ] : getcwd(); |
|
| 140 | + $f = new Folder(sprintf('%s/plugins/%s', $startPath, $this->params[ 'plugin' ])); |
|
| 141 | 141 | $basePath = $f->path; |
| 142 | - $this->poName = $this->params['plugin'] . '.po'; |
|
| 142 | + $this->poName = $this->params[ 'plugin' ] . '.po'; |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | $this->templatePaths = [ |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | { |
| 180 | 180 | $header = $this->header('po'); |
| 181 | 181 | $potFilename = sprintf('%s/master.pot', $this->localePath); |
| 182 | - $locales = array_keys((array)Configure::read('I18n.locales', [])); |
|
| 182 | + $locales = array_keys((array)Configure::read('I18n.locales', [ ])); |
|
| 183 | 183 | foreach ($locales as $loc) { |
| 184 | 184 | $potDir = $this->localePath . DS . $loc; |
| 185 | 185 | if (!file_exists($potDir)) { |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | 'Content-Type' => 'text/plain; charset=utf-8', |
| 234 | 234 | ], |
| 235 | 235 | ]; |
| 236 | - foreach ($contents[$type] as $k => $v) { |
|
| 236 | + foreach ($contents[ $type ] as $k => $v) { |
|
| 237 | 237 | $result .= sprintf('"%s: %s \n"', $k, $v) . "\n"; |
| 238 | 238 | } |
| 239 | 239 | |
@@ -255,9 +255,9 @@ discard block |
||
| 255 | 255 | $numItems++; |
| 256 | 256 | } |
| 257 | 257 | if (strpos($l, 'msgstr ""') === 0) { |
| 258 | - if (!isset($lines[$k + 1])) { |
|
| 258 | + if (!isset($lines[ $k + 1 ])) { |
|
| 259 | 259 | $numNotTranslated++; |
| 260 | - } elseif (strpos($lines[$k + 1], '"') !== 0) { |
|
| 260 | + } elseif (strpos($lines[ $k + 1 ], '"') !== 0) { |
|
| 261 | 261 | $numNotTranslated++; |
| 262 | 262 | } |
| 263 | 263 | } |
@@ -325,17 +325,17 @@ discard block |
||
| 325 | 325 | // or __('text to translate',true), result in matches[1] or in matches[2] |
| 326 | 326 | $rgxp = '/' . "__\s*{$p}\s*{$q2}" . "([^{$q2}]*)" . "{$q2}" . |
| 327 | 327 | '|' . "__\s*{$p}\s*{$q1}" . "([^{$q1}]*)" . "{$q1}" . '/'; |
| 328 | - $matches = []; |
|
| 328 | + $matches = [ ]; |
|
| 329 | 329 | preg_match_all($rgxp, $content, $matches); |
| 330 | 330 | |
| 331 | - $limit = count($matches[0]); |
|
| 331 | + $limit = count($matches[ 0 ]); |
|
| 332 | 332 | for ($i = 0; $i < $limit; $i++) { |
| 333 | - $item = $this->fixString($matches[1][$i]); |
|
| 333 | + $item = $this->fixString($matches[ 1 ][ $i ]); |
|
| 334 | 334 | if (empty($item)) { |
| 335 | - $item = $this->fixString($matches[2][$i]); |
|
| 335 | + $item = $this->fixString($matches[ 2 ][ $i ]); |
|
| 336 | 336 | } |
| 337 | 337 | if (!in_array($item, $this->poResult)) { |
| 338 | - $this->poResult[] = $item; |
|
| 338 | + $this->poResult[ ] = $item; |
|
| 339 | 339 | } |
| 340 | 340 | } |
| 341 | 341 | } |
@@ -355,8 +355,8 @@ discard block |
||
| 355 | 355 | if (!is_dir($file)) { |
| 356 | 356 | $f = new File($file); |
| 357 | 357 | $info = $f->info(); |
| 358 | - if (isset($info['extension'])) { |
|
| 359 | - $this->parseFile($file, $info['extension']); |
|
| 358 | + if (isset($info[ 'extension' ])) { |
|
| 359 | + $this->parseFile($file, $info[ 'extension' ]); |
|
| 360 | 360 | } |
| 361 | 361 | } |
| 362 | 362 | } |
@@ -29,12 +29,12 @@ discard block |
||
| 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 |
||
| 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; |