@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | * |
| 90 | 90 | * If an empty array is provided, the method should consider this a request |
| 91 | 91 | * to empty the languages store. |
| 92 | - * @return MultilingualAwareInterface Chainable |
|
| 92 | + * @return ConfigurableTranslationTrait Chainable |
|
| 93 | 93 | */ |
| 94 | 94 | public function setLanguages(array $langs = []) |
| 95 | 95 | { |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | * |
| 104 | 104 | * @uses ConfigurableInterface::config() |
| 105 | 105 | * @param LanguageInterface|array|string $lang A language object or identifier. |
| 106 | - * @return MultilingualAwareInterface Chainable |
|
| 106 | + * @return ConfigurableTranslationTrait Chainable |
|
| 107 | 107 | */ |
| 108 | 108 | public function addLanguage($lang) |
| 109 | 109 | { |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | * |
| 118 | 118 | * @uses ConfigurableInterface::config() |
| 119 | 119 | * @param LanguageInterface|string $lang A language object or identifier. |
| 120 | - * @return MultilingualAwareInterface Chainable |
|
| 120 | + * @return ConfigurableTranslationTrait Chainable |
|
| 121 | 121 | */ |
| 122 | 122 | public function removeLanguage($lang) |
| 123 | 123 | { |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | * |
| 172 | 172 | * @uses ConfigurableInterface::config() |
| 173 | 173 | * @param LanguageInterface|string|null $lang A language object or identifier. |
| 174 | - * @return MultilingualAwareInterface Chainable |
|
| 174 | + * @return ConfigurableTranslationTrait Chainable |
|
| 175 | 175 | */ |
| 176 | 176 | public function setDefaultLanguage($lang = null) |
| 177 | 177 | { |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | * |
| 205 | 205 | * @uses ConfigurableInterface::config() |
| 206 | 206 | * @param LanguageInterface|string|null $lang A language object or identifier. |
| 207 | - * @return MultilingualAwareInterface Chainable |
|
| 207 | + * @return ConfigurableTranslationTrait Chainable |
|
| 208 | 208 | */ |
| 209 | 209 | public function setCurrentLanguage($lang = null) |
| 210 | 210 | { |
@@ -853,7 +853,7 @@ discard block |
||
| 853 | 853 | /** |
| 854 | 854 | * Retrieve the default included paths to scan for translatable text. |
| 855 | 855 | * |
| 856 | - * @return array |
|
| 856 | + * @return string[] |
|
| 857 | 857 | */ |
| 858 | 858 | public function defaultIncludedPaths() |
| 859 | 859 | { |
@@ -964,7 +964,7 @@ discard block |
||
| 964 | 964 | /** |
| 965 | 965 | * Retrieve the supported output formats for the translations file. |
| 966 | 966 | * |
| 967 | - * @return array |
|
| 967 | + * @return string[] |
|
| 968 | 968 | */ |
| 969 | 969 | public function outputFormats() |
| 970 | 970 | { |
@@ -1167,7 +1167,7 @@ discard block |
||
| 1167 | 1167 | /** |
| 1168 | 1168 | * Retrieve the language of the source code. |
| 1169 | 1169 | * |
| 1170 | - * @return array|null |
|
| 1170 | + * @return string|null |
|
| 1171 | 1171 | */ |
| 1172 | 1172 | public function sourceLanguage() |
| 1173 | 1173 | { |
@@ -674,7 +674,7 @@ |
||
| 674 | 674 | 'longPrefix' => 'max-depth', |
| 675 | 675 | 'castTo' => 'int', |
| 676 | 676 | 'description' => 'Descend at most the given number of levels of directories. '. |
| 677 | - 'A negative value means no limit.', |
|
| 677 | + 'A negative value means no limit.', |
|
| 678 | 678 | 'defaultValue' => static::DEFAULT_MAX_DEPTH, |
| 679 | 679 | 'prompt' => 'Scan Depth (of directories)', |
| 680 | 680 | 'acceptValue' => function ($response) { |
@@ -523,7 +523,7 @@ discard block |
||
| 523 | 523 | } else { |
| 524 | 524 | $messages[$id] = [ |
| 525 | 525 | 'translations' => [], |
| 526 | - 'context' => [ $context ], |
|
| 526 | + 'context' => [$context], |
|
| 527 | 527 | 'status' => 'new' |
| 528 | 528 | ]; |
| 529 | 529 | } |
@@ -600,7 +600,7 @@ discard block |
||
| 600 | 600 | sprintf( |
| 601 | 601 | 'Supported source types are: %1$s; received %2$s'. |
| 602 | 602 | 'Unsupported file type "%1$s". Must be one of %2$s', |
| 603 | - implode(', ', [ 'mustache', 'php' ]), |
|
| 603 | + implode(', ', ['mustache', 'php']), |
|
| 604 | 604 | (is_object($type) ? get_class($type) : gettype($type)) |
| 605 | 605 | ) |
| 606 | 606 | ); |
@@ -621,7 +621,7 @@ discard block |
||
| 621 | 621 | static $arguments; |
| 622 | 622 | |
| 623 | 623 | if ($arguments === null) { |
| 624 | - $validateLanguages = function ($response) { |
|
| 624 | + $validateLanguages = function($response) { |
|
| 625 | 625 | if (strlen($response) === 0) { |
| 626 | 626 | return true; |
| 627 | 627 | } |
@@ -637,7 +637,7 @@ discard block |
||
| 637 | 637 | }; |
| 638 | 638 | $validateLanguages = $validateLanguages->bindTo($this); |
| 639 | 639 | |
| 640 | - $validatePaths = function ($response) { |
|
| 640 | + $validatePaths = function($response) { |
|
| 641 | 641 | if (strlen($response) === 0) { |
| 642 | 642 | return true; |
| 643 | 643 | } |
@@ -653,7 +653,7 @@ discard block |
||
| 653 | 653 | }; |
| 654 | 654 | $validatePaths = $validatePaths->bindTo($this); |
| 655 | 655 | |
| 656 | - $validateCatalog = function ($response) { |
|
| 656 | + $validateCatalog = function($response) { |
|
| 657 | 657 | if (strlen($response) === 0) { |
| 658 | 658 | return true; |
| 659 | 659 | } |
@@ -677,7 +677,7 @@ discard block |
||
| 677 | 677 | 'A negative value means no limit.', |
| 678 | 678 | 'defaultValue' => static::DEFAULT_MAX_DEPTH, |
| 679 | 679 | 'prompt' => 'Scan Depth (of directories)', |
| 680 | - 'acceptValue' => function ($response) { |
|
| 680 | + 'acceptValue' => function($response) { |
|
| 681 | 681 | return (strlen($response) === 0) || is_numeric($response); |
| 682 | 682 | } |
| 683 | 683 | ], |
@@ -688,7 +688,7 @@ discard block |
||
| 688 | 688 | 'description' => 'Specify an alternate base path.', |
| 689 | 689 | 'defaultValue' => $this->basePath(), |
| 690 | 690 | 'prompt' => 'Base Path', |
| 691 | - 'acceptValue' => function ($response) { |
|
| 691 | + 'acceptValue' => function($response) { |
|
| 692 | 692 | return (strlen($response) === 0) || is_dir($response); |
| 693 | 693 | } |
| 694 | 694 | ], |
@@ -968,7 +968,7 @@ discard block |
||
| 968 | 968 | */ |
| 969 | 969 | public function outputFormats() |
| 970 | 970 | { |
| 971 | - return [ 'csv' ]; |
|
| 971 | + return ['csv']; |
|
| 972 | 972 | } |
| 973 | 973 | |
| 974 | 974 | /** |
@@ -1220,7 +1220,7 @@ discard block |
||
| 1220 | 1220 | $languages = []; |
| 1221 | 1221 | |
| 1222 | 1222 | $r = 0; |
| 1223 | - $blank = [ null ]; |
|
| 1223 | + $blank = [null]; |
|
| 1224 | 1224 | // @codingStandardsIgnoreStart |
| 1225 | 1225 | while (($row = fgetcsv($file)) !== false) { |
| 1226 | 1226 | // @codingStandardsIgnoreEnd |
@@ -1308,7 +1308,7 @@ discard block |
||
| 1308 | 1308 | fputcsv($file, $this->csvHeaderRow()); |
| 1309 | 1309 | |
| 1310 | 1310 | foreach ($messages as $id => $entry) { |
| 1311 | - $row = [ $id ]; |
|
| 1311 | + $row = [$id]; |
|
| 1312 | 1312 | foreach ($languages as $lang) { |
| 1313 | 1313 | if (isset($entry['translations'][$lang])) { |
| 1314 | 1314 | $row[] = $entry['translations'][$lang]; |
@@ -1387,7 +1387,7 @@ discard block |
||
| 1387 | 1387 | static $columns; |
| 1388 | 1388 | |
| 1389 | 1389 | if ($columns === null) { |
| 1390 | - $columns = [ 'source' ]; |
|
| 1390 | + $columns = ['source']; |
|
| 1391 | 1391 | $languages = $this->languages(); |
| 1392 | 1392 | foreach ($languages as $lang) { |
| 1393 | 1393 | $columns[] = $lang; |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * |
| 69 | 69 | * @var array |
| 70 | 70 | */ |
| 71 | - protected $supportedFormats = [ 'ini', 'csv', 'json', 'php', 'yaml', 'yml' ]; |
|
| 71 | + protected $supportedFormats = ['ini', 'csv', 'json', 'php', 'yaml', 'yml']; |
|
| 72 | 72 | |
| 73 | 73 | /** |
| 74 | 74 | * A list of available file formats. |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | $directory = new RecursiveDirectoryIterator($path); |
| 294 | 294 | $filter = new RecursiveCallbackFilterIterator( |
| 295 | 295 | $directory, |
| 296 | - function ($current, $key, $iterator) { |
|
| 296 | + function($current, $key, $iterator) { |
|
| 297 | 297 | $filename = $current->getFilename(); |
| 298 | 298 | if (preg_match('!^(\.\w+|\.$|\.\.$)!i', $filename)) { |
| 299 | 299 | return false; |
@@ -386,7 +386,7 @@ discard block |
||
| 386 | 386 | protected function createTranslationCatalog() |
| 387 | 387 | { |
| 388 | 388 | $catalogClass = $this->catalogClass(); |
| 389 | - $catalog = new $catalogClass; |
|
| 389 | + $catalog = new $catalogClass; |
|
| 390 | 390 | |
| 391 | 391 | if (!$catalog instanceof CatalogInterface) { |
| 392 | 392 | throw new RuntimeException( |
@@ -439,7 +439,7 @@ discard block |
||
| 439 | 439 | public function createTranslationResource() |
| 440 | 440 | { |
| 441 | 441 | $resourceClass = $this->resourceClass(); |
| 442 | - $resource = new $resourceClass; |
|
| 442 | + $resource = new $resourceClass; |
|
| 443 | 443 | |
| 444 | 444 | if (!$resource instanceof ResourceInterface) { |
| 445 | 445 | throw new RuntimeException( |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | $messages = []; |
| 123 | 123 | |
| 124 | 124 | $i = 0; |
| 125 | - $blank = [ null ]; |
|
| 125 | + $blank = [null]; |
|
| 126 | 126 | // @codingStandardsIgnoreStart |
| 127 | 127 | while (($data = fgetcsv($handle)) !== false) { |
| 128 | 128 | // @codingStandardsIgnoreEnd |
@@ -133,9 +133,9 @@ discard block |
||
| 133 | 133 | if ($i === 0) { |
| 134 | 134 | $i++; |
| 135 | 135 | |
| 136 | - $source = $data[0]; |
|
| 136 | + $source = $data[0]; |
|
| 137 | 137 | $count = count($data); |
| 138 | - $context = $data[( $count-1 )]; |
|
| 138 | + $context = $data[($count - 1)]; |
|
| 139 | 139 | |
| 140 | 140 | /** |
| 141 | 141 | * Remove "ident" and "context" columns. |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | /** |
| 195 | 195 | * Remove a translation value specified by an available language. |
| 196 | 196 | * |
| 197 | - * @param LanguageInterface|string $lang A language object or identifier. |
|
| 197 | + * @param string $lang A language object or identifier. |
|
| 198 | 198 | * @return self |
| 199 | 199 | * @throws InvalidArgumentException If language is invalid. |
| 200 | 200 | */ |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | * the translation in the default language is returned. |
| 226 | 226 | * If $lang isn't provided, the translation in the current language is returned. |
| 227 | 227 | * |
| 228 | - * @param LanguageInterface|string|null $lang Optional supported language to retrieve a translation in. |
|
| 228 | + * @param string $lang Optional supported language to retrieve a translation in. |
|
| 229 | 229 | * @return string |
| 230 | 230 | * @throws InvalidArgumentException If language is invalid. |
| 231 | 231 | * @todo When the language is invalid, should we fallback to the default language |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | * a subset of the object's available languages (if any). |
| 331 | 331 | * |
| 332 | 332 | * @param (LanguageInterface|string)[] $langs Optional language(s) filters. |
| 333 | - * @return (LanguageInterface|string)[] An array of available languages. |
|
| 333 | + * @return string[] An array of available languages. |
|
| 334 | 334 | */ |
| 335 | 335 | public function translations(array $langs = []) |
| 336 | 336 | { |
@@ -546,7 +546,7 @@ discard block |
||
| 546 | 546 | * |
| 547 | 547 | * @param mixed $lang A language object or identifier. |
| 548 | 548 | * @throws InvalidArgumentException If language is invalid. |
| 549 | - * @return string|mixed A language identifier. |
|
| 549 | + * @return string A language identifier. |
|
| 550 | 550 | */ |
| 551 | 551 | protected function parseLanguageIdent($lang) |
| 552 | 552 | { |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | $lang = $this->parseLanguageIdent($lang); |
| 301 | 301 | $val = $this->val($lang); |
| 302 | 302 | if (empty($val)) { |
| 303 | - $available = array_diff_key($this->val, array_flip([ $lang, $this->defaultLanguage() ])); |
|
| 303 | + $available = array_diff_key($this->val, array_flip([$lang, $this->defaultLanguage()])); |
|
| 304 | 304 | foreach ($available as $code => $l10n) { |
| 305 | 305 | if (!empty($l10n)) { |
| 306 | 306 | return $l10n; |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | public function translations(array $langs = []) |
| 336 | 336 | { |
| 337 | 337 | if (count($langs)) { |
| 338 | - array_walk($langs, function (&$val, $key) { |
|
| 338 | + array_walk($langs, function(&$val, $key) { |
|
| 339 | 339 | $val = self::resolveLanguageIdent($val); |
| 340 | 340 | }); |
| 341 | 341 | |
@@ -597,7 +597,7 @@ discard block |
||
| 597 | 597 | if (is_array($var)) { |
| 598 | 598 | return !!array_filter( |
| 599 | 599 | $var, |
| 600 | - function ($v, $k) { |
|
| 600 | + function($v, $k) { |
|
| 601 | 601 | if (is_string($k) && is_string($v)) { |
| 602 | 602 | if (strlen($k) && mb_strlen($v)) { |
| 603 | 603 | return true; |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | * |
| 68 | 68 | * @used-by self::setLanguages() |
| 69 | 69 | * @used-by self::removeLanguage() |
| 70 | - * @return MultilingualAwareInterface Chainable |
|
| 70 | + * @return TranslatableTrait Chainable |
|
| 71 | 71 | */ |
| 72 | 72 | public function resolveSpecialLanguages() |
| 73 | 73 | { |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | * |
| 143 | 143 | * If an empty array is provided, the method should consider this a request |
| 144 | 144 | * to clear the languages store. |
| 145 | - * @return MultilingualAwareInterface Chainable |
|
| 145 | + * @return TranslatableTrait Chainable |
|
| 146 | 146 | */ |
| 147 | 147 | public function setLanguages(array $langs = []) |
| 148 | 148 | { |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | * Append a list of languages to the object. |
| 162 | 162 | * |
| 163 | 163 | * @param (LanguageInterface|string)[] $langs The languages to set. |
| 164 | - * @return MultilingualAwareInterface Chainable |
|
| 164 | + * @return TranslatableTrait Chainable |
|
| 165 | 165 | */ |
| 166 | 166 | public function addLanguages(array $langs) |
| 167 | 167 | { |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | * this method will replace the existing one. |
| 185 | 185 | * |
| 186 | 186 | * @param LanguageInterface|array|string $lang A language object or identifier. |
| 187 | - * @return MultilingualAwareInterface Chainable |
|
| 187 | + * @return TranslatableTrait Chainable |
|
| 188 | 188 | * |
| 189 | 189 | * @throws InvalidArgumentException If the language is invalid. |
| 190 | 190 | */ |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | * |
| 214 | 214 | * @uses self::resolve_specialLanguages() |
| 215 | 215 | * @param LanguageInterface|string $lang A language object or identifier. |
| 216 | - * @return MultilingualAwareInterface Chainable |
|
| 216 | + * @return TranslatableTrait Chainable |
|
| 217 | 217 | * |
| 218 | 218 | * @throws InvalidArgumentException If an array member isn't a string or instance of LanguageInterface. |
| 219 | 219 | */ |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | * |
| 305 | 305 | * @param LanguageInterface|string|null $lang A language object or identifier. |
| 306 | 306 | * @throws InvalidArgumentException If language is invalid. |
| 307 | - * @return MultilingualAwareInterface Chainable |
|
| 307 | + * @return TranslatableTrait Chainable |
|
| 308 | 308 | */ |
| 309 | 309 | public function setDefaultLanguage($lang = null) |
| 310 | 310 | { |
@@ -356,7 +356,7 @@ discard block |
||
| 356 | 356 | * |
| 357 | 357 | * @param LanguageInterface|string|null $lang A language object or identifier. |
| 358 | 358 | * @throws InvalidArgumentException If language is invalid. |
| 359 | - * @return MultilingualAwareInterface Chainable |
|
| 359 | + * @return TranslatableTrait Chainable |
|
| 360 | 360 | */ |
| 361 | 361 | public function setCurrentLanguage($lang = null) |
| 362 | 362 | { |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | public function languages(array $langs = []) |
| 96 | 96 | { |
| 97 | 97 | if (count($langs)) { |
| 98 | - array_walk($langs, function (&$val, $key) { |
|
| 98 | + array_walk($langs, function(&$val, $key) { |
|
| 99 | 99 | $val = self::resolveLanguageIdent($val); |
| 100 | 100 | }); |
| 101 | 101 | |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | $available = array_keys($this->languages); |
| 119 | 119 | |
| 120 | 120 | if (count($langs)) { |
| 121 | - array_walk($langs, function (&$val, $key) { |
|
| 121 | + array_walk($langs, function(&$val, $key) { |
|
| 122 | 122 | $val = self::resolveLanguageIdent($val); |
| 123 | 123 | }); |
| 124 | 124 | |