@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | |
| 88 | 88 | public function getProperty(string $name) : ?string |
| 89 | 89 | { |
| 90 | - if(isset($this->properties[$name])) { |
|
| 90 | + if (isset($this->properties[$name])) { |
|
| 91 | 91 | return $this->properties[$name]; |
| 92 | 92 | } |
| 93 | 93 | |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | Text::fromArray($array[self::SERIALIZED_TEXT]) |
| 142 | 142 | ); |
| 143 | 143 | |
| 144 | - foreach($array[self::SERIALIZED_PROPERTIES] as $name => $value) { |
|
| 144 | + foreach ($array[self::SERIALIZED_PROPERTIES] as $name => $value) { |
|
| 145 | 145 | $string->setProperty($name, $value); |
| 146 | 146 | } |
| 147 | 147 | |
@@ -54,7 +54,7 @@ |
||
| 54 | 54 | */ |
| 55 | 55 | public function getFloat() : float |
| 56 | 56 | { |
| 57 | - return floatval($this->number . '.' . $this->decimals); |
|
| 57 | + return floatval($this->number.'.'.$this->decimals); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /** |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | */ |
| 80 | 80 | public function addSources(array $sources) : void |
| 81 | 81 | { |
| 82 | - foreach($sources as $source) { |
|
| 82 | + foreach ($sources as $source) { |
|
| 83 | 83 | $this->addSource($source); |
| 84 | 84 | } |
| 85 | 85 | } |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | $this->strings[$localeName] = array(); |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - foreach($this->sources as $source) |
|
| 127 | + foreach ($this->sources as $source) |
|
| 128 | 128 | { |
| 129 | 129 | $file = $this->resolveStorageFile($locale, $source); |
| 130 | 130 | if (!file_exists($file)) { |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | |
| 134 | 134 | $data = parse_ini_file($file, false); |
| 135 | 135 | |
| 136 | - if($data === false) |
|
| 136 | + if ($data === false) |
|
| 137 | 137 | { |
| 138 | 138 | throw new Localization_Exception( |
| 139 | 139 | 'Malformatted localization file', |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | |
| 206 | 206 | $name = $locale->getName(); |
| 207 | 207 | |
| 208 | - if(isset($this->strings[$name])) { |
|
| 208 | + if (isset($this->strings[$name])) { |
|
| 209 | 209 | return $this->strings[$name]; |
| 210 | 210 | } |
| 211 | 211 | |
@@ -240,11 +240,11 @@ discard block |
||
| 240 | 240 | * @param Localization_Locale $locale |
| 241 | 241 | * @param boolean $editable |
| 242 | 242 | */ |
| 243 | - protected function renderStringsFile(string $type, Localization_Source $source, array $hashes, string $file, Localization_Locale $locale, bool $editable=true) : void |
|
| 243 | + protected function renderStringsFile(string $type, Localization_Source $source, array $hashes, string $file, Localization_Locale $locale, bool $editable = true) : void |
|
| 244 | 244 | { |
| 245 | 245 | $writer = new Localization_Writer($locale, $type, $file); |
| 246 | 246 | |
| 247 | - if($editable) |
|
| 247 | + if ($editable) |
|
| 248 | 248 | { |
| 249 | 249 | $writer->makeEditable(); |
| 250 | 250 | } |
@@ -253,14 +253,14 @@ discard block |
||
| 253 | 253 | |
| 254 | 254 | foreach ($hashes as $hash) |
| 255 | 255 | { |
| 256 | - if(!$hash->hasSourceID($sourceID)) { |
|
| 256 | + if (!$hash->hasSourceID($sourceID)) { |
|
| 257 | 257 | continue; |
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | $text = $this->getHashTranslation($hash->getHash(), $locale); |
| 261 | 261 | |
| 262 | 262 | // skip any empty strings |
| 263 | - if($text === null || trim($text) == '') { |
|
| 263 | + if ($text === null || trim($text) == '') { |
|
| 264 | 264 | continue; |
| 265 | 265 | } |
| 266 | 266 | |
@@ -338,7 +338,7 @@ discard block |
||
| 338 | 338 | { |
| 339 | 339 | // to avoid re-creating the hash for the same texts over and over, |
| 340 | 340 | // we keep track of the hashes we created, and re-use them. |
| 341 | - if(isset($this->reverseStrings[$text])) { |
|
| 341 | + if (isset($this->reverseStrings[$text])) { |
|
| 342 | 342 | $hash = $this->reverseStrings[$text]; |
| 343 | 343 | } else { |
| 344 | 344 | $hash = md5($text); |
@@ -403,15 +403,15 @@ discard block |
||
| 403 | 403 | * @param Localization_Locale|null $locale |
| 404 | 404 | * @return string|NULL |
| 405 | 405 | */ |
| 406 | - public function getHashTranslation(string $hash, ?Localization_Locale $locale=null) : ?string |
|
| 406 | + public function getHashTranslation(string $hash, ?Localization_Locale $locale = null) : ?string |
|
| 407 | 407 | { |
| 408 | - if(!$locale) { |
|
| 408 | + if (!$locale) { |
|
| 409 | 409 | $locale = $this->targetLocale; |
| 410 | 410 | } |
| 411 | 411 | |
| 412 | 412 | $localeName = $locale->getName(); |
| 413 | 413 | |
| 414 | - if(isset($this->strings[$localeName]) && isset($this->strings[$localeName][$hash])) { |
|
| 414 | + if (isset($this->strings[$localeName]) && isset($this->strings[$localeName][$hash])) { |
|
| 415 | 415 | return $this->strings[$localeName][$hash]; |
| 416 | 416 | } |
| 417 | 417 | |
@@ -429,10 +429,10 @@ discard block |
||
| 429 | 429 | { |
| 430 | 430 | $result = array(); |
| 431 | 431 | |
| 432 | - foreach($this->sources as $source) |
|
| 432 | + foreach ($this->sources as $source) |
|
| 433 | 433 | { |
| 434 | 434 | $localeFile = self::getClientStorageFile($locale, $source); |
| 435 | - if(!file_exists($localeFile)) { |
|
| 435 | + if (!file_exists($localeFile)) { |
|
| 436 | 436 | continue; |
| 437 | 437 | } |
| 438 | 438 | |
@@ -42,13 +42,13 @@ |
||
| 42 | 42 | * @param array|string $definition |
| 43 | 43 | * @param Localization_Parser_Token|null $parentToken |
| 44 | 44 | */ |
| 45 | - public function __construct($definition, ?Localization_Parser_Token $parentToken=null) |
|
| 45 | + public function __construct($definition, ?Localization_Parser_Token $parentToken = null) |
|
| 46 | 46 | { |
| 47 | 47 | $this->definition = $definition; |
| 48 | 48 | $this->parentToken = $parentToken; |
| 49 | 49 | |
| 50 | 50 | $names = $this->getFunctionNames(); |
| 51 | - foreach($names as $name) { |
|
| 51 | + foreach ($names as $name) { |
|
| 52 | 52 | $this->nameLookup[$name] = true; |
| 53 | 53 | } |
| 54 | 54 | |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | public function getPrevious() : ?Localization_Locale |
| 32 | 32 | { |
| 33 | 33 | $arg = $this->getArgument(1); |
| 34 | - if($arg instanceof Localization_Locale) { |
|
| 34 | + if ($arg instanceof Localization_Locale) { |
|
| 35 | 35 | return $arg; |
| 36 | 36 | } |
| 37 | 37 | |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | { |
| 49 | 49 | $arg = $this->getArgument(2); |
| 50 | 50 | |
| 51 | - if($arg instanceof Localization_Locale) { |
|
| 51 | + if ($arg instanceof Localization_Locale) { |
|
| 52 | 52 | return $arg; |
| 53 | 53 | } |
| 54 | 54 | |
@@ -72,14 +72,14 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | public function scan() : void |
| 74 | 74 | { |
| 75 | - if(isset($this->collection)) { |
|
| 75 | + if (isset($this->collection)) { |
|
| 76 | 76 | $this->collection = null; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | $this->timeStart = microtime(true); |
| 80 | 80 | |
| 81 | 81 | $sources = Localization::getSources(); |
| 82 | - foreach($sources as $source) |
|
| 82 | + foreach ($sources as $source) |
|
| 83 | 83 | { |
| 84 | 84 | $source->scan($this); |
| 85 | 85 | } |
@@ -91,11 +91,11 @@ discard block |
||
| 91 | 91 | |
| 92 | 92 | public function load() : void |
| 93 | 93 | { |
| 94 | - if(!$this->isScanAvailable()) { |
|
| 94 | + if (!$this->isScanAvailable()) { |
|
| 95 | 95 | return; |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - if($this->loaded) { |
|
| 98 | + if ($this->loaded) { |
|
| 99 | 99 | return; |
| 100 | 100 | } |
| 101 | 101 | |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | |
| 104 | 104 | $data = FileHelper::parseJSONFile($this->storageFile); |
| 105 | 105 | |
| 106 | - if($this->getCollection()->fromArray($data) === true) { |
|
| 106 | + if ($this->getCollection()->fromArray($data) === true) { |
|
| 107 | 107 | return; |
| 108 | 108 | } |
| 109 | 109 | |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | |
| 122 | 122 | public function getParser() : Localization_Parser |
| 123 | 123 | { |
| 124 | - if(!isset($this->parser)) { |
|
| 124 | + if (!isset($this->parser)) { |
|
| 125 | 125 | $this->parser = new Localization_Parser($this); |
| 126 | 126 | } |
| 127 | 127 | |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | |
| 131 | 131 | public function getCollection() : Localization_Scanner_StringsCollection |
| 132 | 132 | { |
| 133 | - if(!isset($this->collection)) { |
|
| 133 | + if (!isset($this->collection)) { |
|
| 134 | 134 | $this->collection = new Localization_Scanner_StringsCollection($this); |
| 135 | 135 | } |
| 136 | 136 | |
@@ -73,11 +73,11 @@ discard block |
||
| 73 | 73 | return self::$instances[$id]; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - $className = Localization_Currency::class.'_' . $id; |
|
| 76 | + $className = Localization_Currency::class.'_'.$id; |
|
| 77 | 77 | |
| 78 | 78 | $country = new $className($country); |
| 79 | 79 | |
| 80 | - if($country instanceof Localization_Currency) |
|
| 80 | + if ($country instanceof Localization_Currency) |
|
| 81 | 81 | { |
| 82 | 82 | return $country; |
| 83 | 83 | } |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | */ |
| 139 | 139 | public static function isCurrencyKnown(string $currencyName) : bool |
| 140 | 140 | { |
| 141 | - return file_exists(__DIR__ . '/Currency/' . $currencyName . '.php'); |
|
| 141 | + return file_exists(__DIR__.'/Currency/'.$currencyName.'.php'); |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | /** |
@@ -350,7 +350,7 @@ discard block |
||
| 350 | 350 | * @return string |
| 351 | 351 | * @throws Localization_Exception |
| 352 | 352 | */ |
| 353 | - public function makeReadable($number, int $decimalPositions = 2, bool $addSymbol=true) : string |
|
| 353 | + public function makeReadable($number, int $decimalPositions = 2, bool $addSymbol = true) : string |
|
| 354 | 354 | { |
| 355 | 355 | if ($number === null || $number === '') { |
| 356 | 356 | return ''; |
@@ -360,14 +360,14 @@ discard block |
||
| 360 | 360 | |
| 361 | 361 | $number = $this->formatNumber($parsed->getFloat(), $decimalPositions); |
| 362 | 362 | |
| 363 | - if(!$addSymbol) { |
|
| 363 | + if (!$addSymbol) { |
|
| 364 | 364 | return $number; |
| 365 | 365 | } |
| 366 | 366 | |
| 367 | 367 | if ($this->isSymbolOnFront()) { |
| 368 | - return $this->getSymbol() . ' ' . $number; |
|
| 368 | + return $this->getSymbol().' '.$number; |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | - return $number . ' ' . $this->getSymbol(); |
|
| 371 | + return $number.' '.$this->getSymbol(); |
|
| 372 | 372 | } |
| 373 | 373 | } |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | { |
| 63 | 63 | $hash = $string->getHash(); |
| 64 | 64 | |
| 65 | - if(!isset($this->hashes[$hash])) { |
|
| 65 | + if (!isset($this->hashes[$hash])) { |
|
| 66 | 66 | $this->hashes[$hash] = new Localization_Scanner_StringHash($this, $hash); |
| 67 | 67 | } |
| 68 | 68 | |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | */ |
| 94 | 94 | public function getHash(string $hash) : Localization_Scanner_StringHash |
| 95 | 95 | { |
| 96 | - if(isset($this->hashes[$hash])) { |
|
| 96 | + if (isset($this->hashes[$hash])) { |
|
| 97 | 97 | return $this->hashes[$hash]; |
| 98 | 98 | } |
| 99 | 99 | |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | 'warnings' => array() |
| 116 | 116 | ); |
| 117 | 117 | |
| 118 | - foreach($this->hashes as $hash) |
|
| 118 | + foreach ($this->hashes as $hash) |
|
| 119 | 119 | { |
| 120 | 120 | $data['hashes'] = array_merge($data['hashes'], $hash->toArray()); |
| 121 | 121 | } |
@@ -131,11 +131,11 @@ discard block |
||
| 131 | 131 | */ |
| 132 | 132 | public function fromArray(array $array) : bool |
| 133 | 133 | { |
| 134 | - if(!isset($array['formatVersion']) || $array['formatVersion'] != self::STORAGE_FORMAT_VERSION) { |
|
| 134 | + if (!isset($array['formatVersion']) || $array['formatVersion'] != self::STORAGE_FORMAT_VERSION) { |
|
| 135 | 135 | return false; |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | - foreach($array['hashes'] as $entry) |
|
| 138 | + foreach ($array['hashes'] as $entry) |
|
| 139 | 139 | { |
| 140 | 140 | $string = Localization_Scanner_StringInfo::fromArray($this, $entry); |
| 141 | 141 | $this->add($string); |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | { |
| 177 | 177 | $result = array(); |
| 178 | 178 | |
| 179 | - foreach($this->warnings as $def) { |
|
| 179 | + foreach ($this->warnings as $def) { |
|
| 180 | 180 | $result[] = new Localization_Scanner_StringsCollection_Warning($def); |
| 181 | 181 | } |
| 182 | 182 | |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | public function countFiles() : int |
| 192 | 192 | { |
| 193 | 193 | $amount = 0; |
| 194 | - foreach($this->hashes as $hash) { |
|
| 194 | + foreach ($this->hashes as $hash) { |
|
| 195 | 195 | $amount = $amount + $hash->countFiles(); |
| 196 | 196 | } |
| 197 | 197 | |
@@ -208,8 +208,8 @@ discard block |
||
| 208 | 208 | { |
| 209 | 209 | $hashes = array(); |
| 210 | 210 | |
| 211 | - foreach($this->hashes as $hash) { |
|
| 212 | - if($hash->hasSourceID($id)) { |
|
| 211 | + foreach ($this->hashes as $hash) { |
|
| 212 | + if ($hash->hasSourceID($id)) { |
|
| 213 | 213 | $hashes[] = $hash; |
| 214 | 214 | } |
| 215 | 215 | } |
@@ -227,8 +227,8 @@ discard block |
||
| 227 | 227 | { |
| 228 | 228 | $hashes = array(); |
| 229 | 229 | |
| 230 | - foreach($this->hashes as $hash) { |
|
| 231 | - if($hash->hasLanguageType($languageID)) { |
|
| 230 | + foreach ($this->hashes as $hash) { |
|
| 231 | + if ($hash->hasLanguageType($languageID)) { |
|
| 232 | 232 | $hashes[] = $hash; |
| 233 | 233 | } |
| 234 | 234 | } |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | protected function initCache() : void |
| 67 | 67 | { |
| 68 | 68 | // ignore it if it does not exist. |
| 69 | - if(!file_exists($this->cacheKeyFile)) { |
|
| 69 | + if (!file_exists($this->cacheKeyFile)) { |
|
| 70 | 70 | return; |
| 71 | 71 | } |
| 72 | 72 | |
@@ -78,22 +78,22 @@ discard block |
||
| 78 | 78 | * @throws Localization_Exception |
| 79 | 79 | * @throws FileHelper_Exception |
| 80 | 80 | */ |
| 81 | - public function writeFiles(bool $force=false) : void |
|
| 81 | + public function writeFiles(bool $force = false) : void |
|
| 82 | 82 | { |
| 83 | 83 | // reset the write states for all files |
| 84 | 84 | $fileIDs = array_keys($this->written); |
| 85 | - foreach($fileIDs as $fileID) { |
|
| 85 | + foreach ($fileIDs as $fileID) { |
|
| 86 | 86 | $this->written[$fileID] = false; |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | // no client libraries folder set: ignore. |
| 90 | - if(empty($this->targetFolder)) { |
|
| 90 | + if (empty($this->targetFolder)) { |
|
| 91 | 91 | return; |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | FileHelper::createFolder($this->targetFolder); |
| 95 | 95 | |
| 96 | - if(!is_writable($this->targetFolder)) |
|
| 96 | + if (!is_writable($this->targetFolder)) |
|
| 97 | 97 | { |
| 98 | 98 | throw new Localization_Exception( |
| 99 | 99 | sprintf( |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | ); |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - if($this->cacheKey !== Localization::getClientLibrariesCacheKey()) { |
|
| 111 | + if ($this->cacheKey !== Localization::getClientLibrariesCacheKey()) { |
|
| 112 | 112 | $force = true; |
| 113 | 113 | } |
| 114 | 114 | |
@@ -131,16 +131,16 @@ discard block |
||
| 131 | 131 | { |
| 132 | 132 | $files = array(); |
| 133 | 133 | |
| 134 | - foreach($this->libraries as $fileName) |
|
| 134 | + foreach ($this->libraries as $fileName) |
|
| 135 | 135 | { |
| 136 | 136 | $files[] = $this->getLibraryFilePath($fileName); |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | $locales = Localization::getAppLocales(); |
| 140 | 140 | |
| 141 | - foreach($locales as $locale) |
|
| 141 | + foreach ($locales as $locale) |
|
| 142 | 142 | { |
| 143 | - if($locale->isNative()) { |
|
| 143 | + if ($locale->isNative()) { |
|
| 144 | 144 | continue; |
| 145 | 145 | } |
| 146 | 146 | |
@@ -154,9 +154,9 @@ discard block |
||
| 154 | 154 | { |
| 155 | 155 | $locales = Localization::getAppLocales(); |
| 156 | 156 | |
| 157 | - foreach($locales as $locale) |
|
| 157 | + foreach ($locales as $locale) |
|
| 158 | 158 | { |
| 159 | - if($locale->isNative()) { |
|
| 159 | + if ($locale->isNative()) { |
|
| 160 | 160 | continue; |
| 161 | 161 | } |
| 162 | 162 | |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | { |
| 181 | 181 | $sourceFolder = realpath(__DIR__.'/../js'); |
| 182 | 182 | |
| 183 | - if($sourceFolder === false) |
|
| 183 | + if ($sourceFolder === false) |
|
| 184 | 184 | { |
| 185 | 185 | throw new Localization_Exception( |
| 186 | 186 | 'Unexpected folder structure encountered.', |
@@ -192,11 +192,11 @@ discard block |
||
| 192 | 192 | ); |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | - foreach($this->libraries as $fileName) |
|
| 195 | + foreach ($this->libraries as $fileName) |
|
| 196 | 196 | { |
| 197 | 197 | $targetFile = $this->getLibraryFilePath($fileName); |
| 198 | 198 | |
| 199 | - if(file_exists($targetFile) && !$this->force) { |
|
| 199 | + if (file_exists($targetFile) && !$this->force) { |
|
| 200 | 200 | continue; |
| 201 | 201 | } |
| 202 | 202 | |
@@ -241,16 +241,16 @@ discard block |
||
| 241 | 241 | { |
| 242 | 242 | $path = $this->getLocaleFilePath($locale); |
| 243 | 243 | |
| 244 | - if(file_exists($path) && !$this->force) { |
|
| 244 | + if (file_exists($path) && !$this->force) { |
|
| 245 | 245 | return; |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | $strings = $this->translator->getClientStrings($locale); |
| 249 | 249 | |
| 250 | 250 | $tokens = array(); |
| 251 | - foreach($strings as $hash => $text) |
|
| 251 | + foreach ($strings as $hash => $text) |
|
| 252 | 252 | { |
| 253 | - if(empty($text)) { |
|
| 253 | + if (empty($text)) { |
|
| 254 | 254 | continue; |
| 255 | 255 | } |
| 256 | 256 | |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | ); |
| 262 | 262 | } |
| 263 | 263 | |
| 264 | - if(empty($tokens)) |
|
| 264 | + if (empty($tokens)) |
|
| 265 | 265 | { |
| 266 | 266 | $content = '/* No strings found. */'; |
| 267 | 267 | } |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | */ |
| 287 | 287 | protected function writeCacheKey() : void |
| 288 | 288 | { |
| 289 | - if(file_exists($this->cacheKeyFile) && !$this->force) { |
|
| 289 | + if (file_exists($this->cacheKeyFile) && !$this->force) { |
|
| 290 | 290 | return; |
| 291 | 291 | } |
| 292 | 292 | |
@@ -311,7 +311,7 @@ discard block |
||
| 311 | 311 | */ |
| 312 | 312 | public function areFilesWritten(string $filesID) : bool |
| 313 | 313 | { |
| 314 | - if(isset($this->written[$filesID])) { |
|
| 314 | + if (isset($this->written[$filesID])) { |
|
| 315 | 315 | return $this->written[$filesID]; |
| 316 | 316 | } |
| 317 | 317 | |