@@ -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 | } |
@@ -46,8 +46,8 @@ discard block |
||
| 46 | 46 | * @var array |
| 47 | 47 | */ |
| 48 | 48 | protected $_defaultConfig = [ |
| 49 | - 'match' => [], |
|
| 50 | - 'startWith' => [], |
|
| 49 | + 'match' => [ ], |
|
| 50 | + 'startWith' => [ ], |
|
| 51 | 51 | 'switchLangUrl' => null, |
| 52 | 52 | 'cookie' => [ |
| 53 | 53 | 'name' => null, |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | * |
| 62 | 62 | * @param array $config Configuration. |
| 63 | 63 | */ |
| 64 | - public function __construct(array $config = []) |
|
| 64 | + public function __construct(array $config = [ ]) |
|
| 65 | 65 | { |
| 66 | 66 | $this->setConfig($config); |
| 67 | 67 | } |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | |
| 214 | 214 | $locale = array_search($new, $this->getLocales()); |
| 215 | 215 | if ($locale === false) { |
| 216 | - throw new BadRequestException(__('Lang "{0}" not supported', [$new])); |
|
| 216 | + throw new BadRequestException(__('Lang "{0}" not supported', [ $new ])); |
|
| 217 | 217 | } |
| 218 | 218 | $response = $this->getResponseWithCookie($response, $locale); |
| 219 | 219 | |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | public function getLocales() : array |
| 43 | 43 | { |
| 44 | - return (array)Configure::read('I18n.locales', []); |
|
| 44 | + return (array)Configure::read('I18n.locales', [ ]); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | public function getLanguages() : array |
| 55 | 55 | { |
| 56 | - return (array)Configure::read('I18n.languages', []); |
|
| 56 | + return (array)Configure::read('I18n.languages', [ ]); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | /** |
@@ -106,14 +106,14 @@ discard block |
||
| 106 | 106 | * @param array $included The included translations data |
| 107 | 107 | * @return string|null |
| 108 | 108 | */ |
| 109 | - public function field(array $object, string $attribute, ?string $lang = null, bool $defaultNull = false, array $included = []) : ?string |
|
| 109 | + public function field(array $object, string $attribute, ?string $lang = null, bool $defaultNull = false, array $included = [ ]) : ?string |
|
| 110 | 110 | { |
| 111 | 111 | $defaultValue = null; |
| 112 | 112 | if (!$defaultNull) { |
| 113 | 113 | $defaultValue = Hash::get($object, sprintf('attributes.%s', $attribute), Hash::get($object, sprintf('%s', $attribute))); |
| 114 | 114 | } |
| 115 | - if (empty($included) && !empty($this->getView()->viewVars['included'])) { |
|
| 116 | - $included = $this->getView()->viewVars['included']; |
|
| 115 | + if (empty($included) && !empty($this->getView()->viewVars[ 'included' ])) { |
|
| 116 | + $included = $this->getView()->viewVars[ 'included' ]; |
|
| 117 | 117 | } |
| 118 | 118 | if (empty($lang)) { |
| 119 | 119 | $lang = Configure::read('I18n.lang', ''); |
@@ -135,10 +135,10 @@ discard block |
||
| 135 | 135 | * @param array $included The included translations data) |
| 136 | 136 | * @return bool |
| 137 | 137 | */ |
| 138 | - public function exists(array $object, string $attribute, ?string $lang = null, array &$included = []) : bool |
|
| 138 | + public function exists(array $object, string $attribute, ?string $lang = null, array &$included = [ ]) : bool |
|
| 139 | 139 | { |
| 140 | - if (empty($included) && !empty($this->getView()->viewVars['included'])) { |
|
| 141 | - $included = $this->getView()->viewVars['included']; |
|
| 140 | + if (empty($included) && !empty($this->getView()->viewVars[ 'included' ])) { |
|
| 141 | + $included = $this->getView()->viewVars[ 'included' ]; |
|
| 142 | 142 | } |
| 143 | 143 | if (empty($lang)) { |
| 144 | 144 | $lang = Configure::read('I18n.lang', ''); |
@@ -176,11 +176,11 @@ discard block |
||
| 176 | 176 | */ |
| 177 | 177 | private function getTranslatedField(array $object, string $attribute, string $lang, array &$included) : ?string |
| 178 | 178 | { |
| 179 | - if (empty($object['id'])) { |
|
| 179 | + if (empty($object[ 'id' ])) { |
|
| 180 | 180 | return null; |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | - $id = $object['id']; |
|
| 183 | + $id = $object[ 'id' ]; |
|
| 184 | 184 | |
| 185 | 185 | if ($this->translation === null) { |
| 186 | 186 | $translations = Hash::combine($included, '{n}.id', '{n}.attributes', '{n}.type'); |
@@ -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 = []) |
|
| 65 | + public function match(array $url, array $context = [ ]) |
|
| 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); |