@@ -61,14 +61,14 @@ discard block |
||
| 61 | 61 | * |
| 62 | 62 | * @var array |
| 63 | 63 | */ |
| 64 | - protected $poResult = []; |
|
| 64 | + protected $poResult = [ ]; |
|
| 65 | 65 | |
| 66 | 66 | /** |
| 67 | 67 | * The template paths |
| 68 | 68 | * |
| 69 | 69 | * @var array |
| 70 | 70 | */ |
| 71 | - protected $templatePaths = []; |
|
| 71 | + protected $templatePaths = [ ]; |
|
| 72 | 72 | |
| 73 | 73 | /** |
| 74 | 74 | * The locale path |
@@ -91,9 +91,9 @@ discard block |
||
| 91 | 91 | */ |
| 92 | 92 | public function update() : void |
| 93 | 93 | { |
| 94 | - $resCmd = []; |
|
| 94 | + $resCmd = [ ]; |
|
| 95 | 95 | exec('which msgmerge 2>&1', $resCmd); |
| 96 | - if (empty($resCmd[0])) { |
|
| 96 | + if (empty($resCmd[ 0 ])) { |
|
| 97 | 97 | $this->out('ERROR: msgmerge not available. Please install gettext utilities.'); |
| 98 | 98 | |
| 99 | 99 | return; |
@@ -129,13 +129,13 @@ discard block |
||
| 129 | 129 | private function setupPaths() : void |
| 130 | 130 | { |
| 131 | 131 | $basePath = getcwd(); |
| 132 | - if (isset($this->params['app'])) { |
|
| 133 | - $f = new Folder($this->params['app']); |
|
| 132 | + if (isset($this->params[ 'app' ])) { |
|
| 133 | + $f = new Folder($this->params[ 'app' ]); |
|
| 134 | 134 | $basePath = $f->path; |
| 135 | - } elseif (isset($this->params['plugin'])) { |
|
| 136 | - $f = new Folder(sprintf('%s/plugins/%s', getcwd(), $this->params['plugin'])); |
|
| 135 | + } elseif (isset($this->params[ 'plugin' ])) { |
|
| 136 | + $f = new Folder(sprintf('%s/plugins/%s', getcwd(), $this->params[ 'plugin' ])); |
|
| 137 | 137 | $basePath = $f->path; |
| 138 | - $this->poName = $this->params['plugin'] . ".po"; |
|
| 138 | + $this->poName = $this->params[ 'plugin' ] . ".po"; |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | $this->templatePaths = [ |
@@ -176,8 +176,8 @@ discard block |
||
| 176 | 176 | $potFilename = sprintf('%s/master.pot', $this->localePath); |
| 177 | 177 | $folder = new Folder($this->localePath); |
| 178 | 178 | $ls = $folder->read(); |
| 179 | - foreach ($ls[0] as $loc) { |
|
| 180 | - if ($loc[0] != '.') { // only "regular" dirs... |
|
| 179 | + foreach ($ls[ 0 ] as $loc) { |
|
| 180 | + if ($loc[ 0 ] != '.') { // only "regular" dirs... |
|
| 181 | 181 | $this->out(sprintf('Language: %s', $loc)); |
| 182 | 182 | $poFile = sprintf('%s/%s/%s', $this->localePath, $loc, $this->poName); |
| 183 | 183 | if (!file_exists($poFile)) { |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | 'Content-Type' => 'text/plain; charset=utf-8', |
| 227 | 227 | ], |
| 228 | 228 | ]; |
| 229 | - foreach ($contents[$type] as $k => $v) { |
|
| 229 | + foreach ($contents[ $type ] as $k => $v) { |
|
| 230 | 230 | $result .= sprintf('"%s: %s \n"', $k, $v) . "\n"; |
| 231 | 231 | } |
| 232 | 232 | |
@@ -248,9 +248,9 @@ discard block |
||
| 248 | 248 | $numItems++; |
| 249 | 249 | } |
| 250 | 250 | if (strpos($l, 'msgstr ""') === 0) { |
| 251 | - if (!isset($lines[$k + 1])) { |
|
| 251 | + if (!isset($lines[ $k + 1 ])) { |
|
| 252 | 252 | $numNotTranslated++; |
| 253 | - } elseif (strpos($lines[$k + 1], '"') !== 0) { |
|
| 253 | + } elseif (strpos($lines[ $k + 1 ], '"') !== 0) { |
|
| 254 | 254 | $numNotTranslated++; |
| 255 | 255 | } |
| 256 | 256 | } |
@@ -312,17 +312,17 @@ discard block |
||
| 312 | 312 | // looks for __("text to translate",true) |
| 313 | 313 | // or __('text to translate',true), result in matches[1] or in matches[2] |
| 314 | 314 | $rgxp = "/__\s*{$p}\s*{$q2}" . "([^{$q2}]*)" . "{$q2}" . "|" . "__\s*{$p}\s*{$q1}" . "([^{$q1}]*)" . "{$q1}/"; |
| 315 | - $matches = []; |
|
| 315 | + $matches = [ ]; |
|
| 316 | 316 | preg_match_all($rgxp, $content, $matches); |
| 317 | 317 | |
| 318 | - $limit = count($matches[0]); |
|
| 318 | + $limit = count($matches[ 0 ]); |
|
| 319 | 319 | for ($i = 0; $i < $limit; $i++) { |
| 320 | - $item = $this->fixString($matches[1][$i]); |
|
| 320 | + $item = $this->fixString($matches[ 1 ][ $i ]); |
|
| 321 | 321 | if (empty($item)) { |
| 322 | - $item = $this->fixString($matches[2][$i]); |
|
| 322 | + $item = $this->fixString($matches[ 2 ][ $i ]); |
|
| 323 | 323 | } |
| 324 | 324 | if (!in_array($item, $this->poResult)) { |
| 325 | - $this->poResult[] = $item; |
|
| 325 | + $this->poResult[ ] = $item; |
|
| 326 | 326 | } |
| 327 | 327 | } |
| 328 | 328 | } |
@@ -342,8 +342,8 @@ discard block |
||
| 342 | 342 | if (!is_dir($file)) { |
| 343 | 343 | $f = new File($file); |
| 344 | 344 | $info = $f->info(); |
| 345 | - if (isset($info['extension'])) { |
|
| 346 | - $this->parseFile($file, $info['extension']); |
|
| 345 | + if (isset($info[ 'extension' ])) { |
|
| 346 | + $this->parseFile($file, $info[ 'extension' ]); |
|
| 347 | 347 | } |
| 348 | 348 | } |
| 349 | 349 | } |
@@ -124,14 +124,14 @@ discard block |
||
| 124 | 124 | * @param array $included The included translations data |
| 125 | 125 | * @return string|null |
| 126 | 126 | */ |
| 127 | - public function field(array $object, string $attribute, ?string $lang = null, bool $defaultNull = false, array &$included = []) : ?string |
|
| 127 | + public function field(array $object, string $attribute, ?string $lang = null, bool $defaultNull = false, array &$included = [ ]) : ?string |
|
| 128 | 128 | { |
| 129 | 129 | $defaultValue = null; |
| 130 | 130 | if (!$defaultNull) { |
| 131 | 131 | $defaultValue = Hash::get($object, sprintf('attributes.%s', $attribute), Hash::get($object, sprintf('%s', $attribute))); |
| 132 | 132 | } |
| 133 | - if (empty($included) && !empty($this->getView()->viewVars['included'])) { |
|
| 134 | - $included = $this->getView()->viewVars['included']; |
|
| 133 | + if (empty($included) && !empty($this->getView()->viewVars[ 'included' ])) { |
|
| 134 | + $included = $this->getView()->viewVars[ 'included' ]; |
|
| 135 | 135 | } |
| 136 | 136 | if (empty($lang)) { |
| 137 | 137 | $lang = Configure::read('I18n.lang', ''); |
@@ -153,10 +153,10 @@ discard block |
||
| 153 | 153 | * @param array $included The included translations data) |
| 154 | 154 | * @return bool |
| 155 | 155 | */ |
| 156 | - public function exists(array $object, string $attribute, ?string $lang = null, array &$included = []) : bool |
|
| 156 | + public function exists(array $object, string $attribute, ?string $lang = null, array &$included = [ ]) : bool |
|
| 157 | 157 | { |
| 158 | - if (empty($included) && !empty($this->getView()->viewVars['included'])) { |
|
| 159 | - $included = $this->getView()->viewVars['included']; |
|
| 158 | + if (empty($included) && !empty($this->getView()->viewVars[ 'included' ])) { |
|
| 159 | + $included = $this->getView()->viewVars[ 'included' ]; |
|
| 160 | 160 | } |
| 161 | 161 | if (empty($lang)) { |
| 162 | 162 | $lang = Configure::read('I18n.lang', ''); |
@@ -194,11 +194,11 @@ discard block |
||
| 194 | 194 | */ |
| 195 | 195 | private function getTranslatedField(array $object, string $attribute, string $lang, array &$included) : ?string |
| 196 | 196 | { |
| 197 | - if (empty($object['id'])) { |
|
| 197 | + if (empty($object[ 'id' ])) { |
|
| 198 | 198 | return null; |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | - $id = $object['id']; |
|
| 201 | + $id = $object[ 'id' ]; |
|
| 202 | 202 | |
| 203 | 203 | if ($this->translation === null) { |
| 204 | 204 | $translations = Hash::combine($included, '{n}.id', '{n}.attributes', '{n}.type'); |
@@ -45,8 +45,8 @@ discard block |
||
| 45 | 45 | * @var array |
| 46 | 46 | */ |
| 47 | 47 | protected $_defaultConfig = [ |
| 48 | - 'match' => [], |
|
| 49 | - 'startWith' => [], |
|
| 48 | + 'match' => [ ], |
|
| 49 | + 'startWith' => [ ], |
|
| 50 | 50 | 'switchLangUrl' => null, |
| 51 | 51 | 'cookie' => [ |
| 52 | 52 | 'name' => null, |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | * |
| 61 | 61 | * @param array $config Configuration. |
| 62 | 62 | */ |
| 63 | - public function __construct(array $config = []) |
|
| 63 | + public function __construct(array $config = [ ]) |
|
| 64 | 64 | { |
| 65 | 65 | $this->setConfig($config); |
| 66 | 66 | } |
@@ -159,11 +159,11 @@ discard block |
||
| 159 | 159 | */ |
| 160 | 160 | protected function setupLocale(?string $locale) : void |
| 161 | 161 | { |
| 162 | - $i18nConf = Configure::read('I18n', []); |
|
| 162 | + $i18nConf = Configure::read('I18n', [ ]); |
|
| 163 | 163 | $lang = Hash::get($i18nConf, sprintf('locales.%s', (string)$locale)); |
| 164 | 164 | if ($lang === null) { |
| 165 | 165 | $lang = Hash::get($i18nConf, 'default'); |
| 166 | - $locale = array_search($lang, (array)Hash::get($i18nConf, 'locales', [])); |
|
| 166 | + $locale = array_search($lang, (array)Hash::get($i18nConf, 'locales', [ ])); |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | Configure::write('I18n.lang', $lang); |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | |
| 213 | 213 | $locale = array_search($new, (array)Configure::read('I18n.locales')); |
| 214 | 214 | if ($locale === false) { |
| 215 | - throw new BadRequestException(__('Lang "{0}" not supported', [$new])); |
|
| 215 | + throw new BadRequestException(__('Lang "{0}" not supported', [ $new ])); |
|
| 216 | 216 | } |
| 217 | 217 | $response = $this->getResponseWithCookie($response, $locale); |
| 218 | 218 | |