@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | { |
104 | 104 | $ext = FileHelper::getExtension($path); |
105 | 105 | |
106 | - if($this->isExtensionSupported($ext)) { |
|
106 | + if ($this->isExtensionSupported($ext)) { |
|
107 | 107 | return; |
108 | 108 | } |
109 | 109 | |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | { |
127 | 127 | $values = $this->getLanguageIDs(); |
128 | 128 | |
129 | - if(in_array($languageID, $values)) { |
|
129 | + if (in_array($languageID, $values)) { |
|
130 | 130 | return; |
131 | 131 | } |
132 | 132 | |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | { |
171 | 171 | $this->requireValidLanguageID($languageID); |
172 | 172 | |
173 | - if(!isset($this->languageParsers[$languageID])) |
|
173 | + if (!isset($this->languageParsers[$languageID])) |
|
174 | 174 | { |
175 | 175 | $this->languageParsers[$languageID] = $this->createLanguageInstance($languageID); |
176 | 176 | } |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | |
191 | 191 | $object = new $class($this); |
192 | 192 | |
193 | - if($object instanceof Localization_Parser_Language) |
|
193 | + if ($object instanceof Localization_Parser_Language) |
|
194 | 194 | { |
195 | 195 | return $object; |
196 | 196 | } |
@@ -29,7 +29,7 @@ |
||
29 | 29 | */ |
30 | 30 | private $hash; |
31 | 31 | |
32 | - public function __construct(string $text, int $line, string $explanation='') |
|
32 | + public function __construct(string $text, int $line, string $explanation = '') |
|
33 | 33 | { |
34 | 34 | $this->text = $text; |
35 | 35 | $this->line = $line; |
@@ -15,12 +15,12 @@ |
||
15 | 15 | protected function parseDefinition() : void |
16 | 16 | { |
17 | 17 | // some entries are strings, like parentheses, semicolons and the like. |
18 | - if(is_string($this->definition)) |
|
18 | + if (is_string($this->definition)) |
|
19 | 19 | { |
20 | 20 | $this->token = $this->definition; |
21 | 21 | $this->value = null; |
22 | 22 | |
23 | - if(isset($this->parentToken)) { |
|
23 | + if (isset($this->parentToken)) { |
|
24 | 24 | $this->line = $this->parentToken->getLine(); |
25 | 25 | } |
26 | 26 | } |
@@ -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 |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | { |
51 | 51 | $entries = array(); |
52 | 52 | |
53 | - foreach($this->strings as $string) { |
|
53 | + foreach ($this->strings as $string) { |
|
54 | 54 | $entries[] = $string->toArray(); |
55 | 55 | } |
56 | 56 | |
@@ -70,8 +70,8 @@ discard block |
||
70 | 70 | { |
71 | 71 | $amount = 0; |
72 | 72 | |
73 | - foreach($this->strings as $string) { |
|
74 | - if($string->isFile()) { |
|
73 | + foreach ($this->strings as $string) { |
|
74 | + if ($string->isFile()) { |
|
75 | 75 | $amount++; |
76 | 76 | } |
77 | 77 | } |
@@ -86,8 +86,8 @@ discard block |
||
86 | 86 | |
87 | 87 | public function hasLanguageType(string $type) : bool |
88 | 88 | { |
89 | - foreach($this->strings as $string) { |
|
90 | - if($string->getLanguageType() == $type) { |
|
89 | + foreach ($this->strings as $string) { |
|
90 | + if ($string->getLanguageType() == $type) { |
|
91 | 91 | return true; |
92 | 92 | } |
93 | 93 | } |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | |
98 | 98 | public function getText() : ?Text |
99 | 99 | { |
100 | - if(isset($this->strings[0])) { |
|
100 | + if (isset($this->strings[0])) { |
|
101 | 101 | return $this->strings[0]->getText(); |
102 | 102 | } |
103 | 103 | |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | $translator = Localization::getTranslator(); |
130 | 130 | $text = $translator->getHashTranslation($this->getHash()); |
131 | 131 | |
132 | - if($text !== null) { |
|
132 | + if ($text !== null) { |
|
133 | 133 | return $text; |
134 | 134 | } |
135 | 135 | |
@@ -144,14 +144,14 @@ discard block |
||
144 | 144 | { |
145 | 145 | $files = array(); |
146 | 146 | |
147 | - foreach($this->strings as $string) |
|
147 | + foreach ($this->strings as $string) |
|
148 | 148 | { |
149 | - if(!$string->isFile()) { |
|
149 | + if (!$string->isFile()) { |
|
150 | 150 | continue; |
151 | 151 | } |
152 | 152 | |
153 | 153 | $file = $string->getSourceFile(); |
154 | - if(!in_array($file, $files)) { |
|
154 | + if (!in_array($file, $files)) { |
|
155 | 155 | $files[] = $file; |
156 | 156 | } |
157 | 157 | } |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | $files = $this->getFiles(); |
171 | 171 | $result = array(); |
172 | 172 | |
173 | - foreach($files as $path) { |
|
173 | + foreach ($files as $path) { |
|
174 | 174 | $result[] = basename($path); |
175 | 175 | } |
176 | 176 |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | */ |
115 | 115 | public static function init() : void |
116 | 116 | { |
117 | - if(self::$initDone) { |
|
117 | + if (self::$initDone) { |
|
118 | 118 | return; |
119 | 119 | } |
120 | 120 | |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | */ |
159 | 159 | public static function getLocalesByNS(string $namespace) |
160 | 160 | { |
161 | - if(isset(self::$locales[$namespace])) { |
|
161 | + if (isset(self::$locales[$namespace])) { |
|
162 | 162 | return array_values(self::$locales[$namespace]); |
163 | 163 | } |
164 | 164 | |
@@ -203,11 +203,11 @@ discard block |
||
203 | 203 | */ |
204 | 204 | public static function addLocaleByNS(string $localeName, string $namespace) : Localization_Locale |
205 | 205 | { |
206 | - if(!isset(self::$locales[$namespace])) { |
|
206 | + if (!isset(self::$locales[$namespace])) { |
|
207 | 207 | self::$locales[$namespace] = array(); |
208 | 208 | } |
209 | 209 | |
210 | - if(!isset(self::$locales[$namespace][$localeName])) |
|
210 | + if (!isset(self::$locales[$namespace][$localeName])) |
|
211 | 211 | { |
212 | 212 | self::$locales[$namespace][$localeName] = self::createLocale($localeName); |
213 | 213 | |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | */ |
239 | 239 | public static function createCountry(string $id) |
240 | 240 | { |
241 | - $className = '\AppLocalize\Localization_Country_' . strtoupper($id); |
|
241 | + $className = '\AppLocalize\Localization_Country_'.strtoupper($id); |
|
242 | 242 | return new $className(); |
243 | 243 | } |
244 | 244 | |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | { |
326 | 326 | self::requireNamespace($namespace); |
327 | 327 | |
328 | - if(isset(self::$selected[$namespace])) { |
|
328 | + if (isset(self::$selected[$namespace])) { |
|
329 | 329 | return self::$selected[$namespace]; |
330 | 330 | } |
331 | 331 | |
@@ -364,9 +364,9 @@ discard block |
||
364 | 364 | $locale = self::addLocaleByNS($localeName, $namespace); |
365 | 365 | $previous = null; |
366 | 366 | |
367 | - if(isset(self::$selected[$namespace])) |
|
367 | + if (isset(self::$selected[$namespace])) |
|
368 | 368 | { |
369 | - if(self::$selected[$namespace]->getName() === $localeName) { |
|
369 | + if (self::$selected[$namespace]->getName() === $localeName) { |
|
370 | 370 | return $locale; |
371 | 371 | } |
372 | 372 | |
@@ -402,11 +402,11 @@ discard block |
||
402 | 402 | $class = Localization_Event::class.'_'.$name; |
403 | 403 | $event = new $class($argsList); |
404 | 404 | |
405 | - if(!isset(self::$listeners[$name])) { |
|
405 | + if (!isset(self::$listeners[$name])) { |
|
406 | 406 | return $event; |
407 | 407 | } |
408 | 408 | |
409 | - foreach(self::$listeners[$name] as $listener) |
|
409 | + foreach (self::$listeners[$name] as $listener) |
|
410 | 410 | { |
411 | 411 | $callArgs = $listener['args']; |
412 | 412 | array_unshift($callArgs, $event); |
@@ -428,15 +428,15 @@ discard block |
||
428 | 428 | * @throws Localization_Exception |
429 | 429 | * @see \AppLocalize\Localization::ERROR_UNKNOWN_EVENT_NAME |
430 | 430 | */ |
431 | - public static function addEventListener(string $eventName, $callback, array $args=array()) : int |
|
431 | + public static function addEventListener(string $eventName, $callback, array $args = array()) : int |
|
432 | 432 | { |
433 | - if(!isset(self::$listeners[$eventName])) { |
|
433 | + if (!isset(self::$listeners[$eventName])) { |
|
434 | 434 | self::$listeners[$eventName] = array(); |
435 | 435 | } |
436 | 436 | |
437 | 437 | $className = Localization_Event::class.'_'.$eventName; |
438 | 438 | |
439 | - if(!class_exists($className)) |
|
439 | + if (!class_exists($className)) |
|
440 | 440 | { |
441 | 441 | throw new Localization_Exception( |
442 | 442 | sprintf('Unknown localization event [%s].', $eventName), |
@@ -470,7 +470,7 @@ discard block |
||
470 | 470 | * @throws Localization_Exception |
471 | 471 | * @see Localization_Event_LocaleChanged |
472 | 472 | */ |
473 | - public static function onLocaleChanged($callback, array $args=array()) : int |
|
473 | + public static function onLocaleChanged($callback, array $args = array()) : int |
|
474 | 474 | { |
475 | 475 | return self::addEventListener(self::EVENT_LOCALE_CHANGED, $callback, $args); |
476 | 476 | } |
@@ -597,7 +597,7 @@ discard block |
||
597 | 597 | { |
598 | 598 | self::requireNamespace($namespace); |
599 | 599 | |
600 | - if(isset(self::$locales[$namespace]) && isset(self::$locales[$namespace][$localeName])) { |
|
600 | + if (isset(self::$locales[$namespace]) && isset(self::$locales[$namespace][$localeName])) { |
|
601 | 601 | return self::$locales[$namespace][$localeName]; |
602 | 602 | } |
603 | 603 | |
@@ -676,9 +676,9 @@ discard block |
||
676 | 676 | * @param Localization_Locale|null $locale |
677 | 677 | * @return Localization_Translator |
678 | 678 | */ |
679 | - public static function getTranslator(?Localization_Locale $locale=null) : Localization_Translator |
|
679 | + public static function getTranslator(?Localization_Locale $locale = null) : Localization_Translator |
|
680 | 680 | { |
681 | - if($locale !== null) |
|
681 | + if ($locale !== null) |
|
682 | 682 | { |
683 | 683 | $obj = new Localization_Translator(); |
684 | 684 | $obj->addSources(self::getSources()); |
@@ -686,7 +686,7 @@ discard block |
||
686 | 686 | return $obj; |
687 | 687 | } |
688 | 688 | |
689 | - if(!isset(self::$translator)) |
|
689 | + if (!isset(self::$translator)) |
|
690 | 690 | { |
691 | 691 | $obj = new Localization_Translator(); |
692 | 692 | $obj->addSources(self::getSources()); |
@@ -711,7 +711,7 @@ discard block |
||
711 | 711 | { |
712 | 712 | self::requireNamespace($namespace); |
713 | 713 | |
714 | - if(isset(self::$locales[$namespace])) { |
|
714 | + if (isset(self::$locales[$namespace])) { |
|
715 | 715 | return count(self::$locales[$namespace]); |
716 | 716 | } |
717 | 717 | |
@@ -724,7 +724,7 @@ discard block |
||
724 | 724 | */ |
725 | 725 | protected static function requireNamespace(string $namespace) : void |
726 | 726 | { |
727 | - if(isset(self::$locales[$namespace])) { |
|
727 | + if (isset(self::$locales[$namespace])) { |
|
728 | 728 | return; |
729 | 729 | } |
730 | 730 | |
@@ -747,7 +747,7 @@ discard block |
||
747 | 747 | * @param string $label |
748 | 748 | * @return HTML_QuickForm2_Element_Select |
749 | 749 | */ |
750 | - public static function injectContentLocalesSelector(string $elementName, HTML_QuickForm2_Container $container, string $label='') : HTML_QuickForm2_Element_Select |
|
750 | + public static function injectContentLocalesSelector(string $elementName, HTML_QuickForm2_Container $container, string $label = '') : HTML_QuickForm2_Element_Select |
|
751 | 751 | { |
752 | 752 | return self::injectLocalesSelectorNS($elementName, self::NAMESPACE_CONTENT, $container, $label); |
753 | 753 | } |
@@ -761,7 +761,7 @@ discard block |
||
761 | 761 | * @param string $label |
762 | 762 | * @return HTML_QuickForm2_Element_Select |
763 | 763 | */ |
764 | - public static function injectAppLocalesSelector(string $elementName, HTML_QuickForm2_Container $container, string $label='') : HTML_QuickForm2_Element_Select |
|
764 | + public static function injectAppLocalesSelector(string $elementName, HTML_QuickForm2_Container $container, string $label = '') : HTML_QuickForm2_Element_Select |
|
765 | 765 | { |
766 | 766 | return self::injectLocalesSelectorNS($elementName, self::NAMESPACE_APPLICATION, $container, $label); |
767 | 767 | } |
@@ -778,9 +778,9 @@ discard block |
||
778 | 778 | * @return HTML_QuickForm2_Element_Select |
779 | 779 | * @throws Localization_Exception |
780 | 780 | */ |
781 | - public static function injectLocalesSelectorNS(string $elementName, string $namespace, HTML_QuickForm2_Container $container, string $label='') : HTML_QuickForm2_Element_Select |
|
781 | + public static function injectLocalesSelectorNS(string $elementName, string $namespace, HTML_QuickForm2_Container $container, string $label = '') : HTML_QuickForm2_Element_Select |
|
782 | 782 | { |
783 | - if(empty($label)) { |
|
783 | + if (empty($label)) { |
|
784 | 784 | $label = t('Language'); |
785 | 785 | } |
786 | 786 | |
@@ -789,7 +789,7 @@ discard block |
||
789 | 789 | |
790 | 790 | $locales = self::getLocalesByNS($namespace); |
791 | 791 | |
792 | - foreach($locales as $locale) { |
|
792 | + foreach ($locales as $locale) { |
|
793 | 793 | $select->addOption($locale->getLabel(), $locale->getName()); |
794 | 794 | } |
795 | 795 | |
@@ -823,14 +823,14 @@ discard block |
||
823 | 823 | |
824 | 824 | public static function addExcludeFolder(string $folderName) : void |
825 | 825 | { |
826 | - if(!in_array($folderName, self::$excludeFolders)) { |
|
826 | + if (!in_array($folderName, self::$excludeFolders)) { |
|
827 | 827 | self::$excludeFolders[] = $folderName; |
828 | 828 | } |
829 | 829 | } |
830 | 830 | |
831 | 831 | public static function addExcludeFile(string $fileName) : void |
832 | 832 | { |
833 | - if(!in_array($fileName, self::$excludeFiles)) { |
|
833 | + if (!in_array($fileName, self::$excludeFiles)) { |
|
834 | 834 | self::$excludeFiles[] = $fileName; |
835 | 835 | } |
836 | 836 | } |
@@ -857,11 +857,11 @@ discard block |
||
857 | 857 | |
858 | 858 | $grouped = array(); |
859 | 859 | |
860 | - foreach($sources as $source) |
|
860 | + foreach ($sources as $source) |
|
861 | 861 | { |
862 | 862 | $group = $source->getGroup(); |
863 | 863 | |
864 | - if(!isset($grouped[$group])) { |
|
864 | + if (!isset($grouped[$group])) { |
|
865 | 865 | $grouped[$group] = array(); |
866 | 866 | } |
867 | 867 | |
@@ -879,8 +879,8 @@ discard block |
||
879 | 879 | public static function sourceExists(string $sourceID) : bool |
880 | 880 | { |
881 | 881 | $sources = self::getSources(); |
882 | - foreach($sources as $source) { |
|
883 | - if($source->getID() == $sourceID) { |
|
882 | + foreach ($sources as $source) { |
|
883 | + if ($source->getID() == $sourceID) { |
|
884 | 884 | return true; |
885 | 885 | } |
886 | 886 | } |
@@ -896,8 +896,8 @@ discard block |
||
896 | 896 | public static function sourceAliasExists(string $sourceAlias) : bool |
897 | 897 | { |
898 | 898 | $sources = self::getSources(); |
899 | - foreach($sources as $source) { |
|
900 | - if($source->getAlias() == $sourceAlias) { |
|
899 | + foreach ($sources as $source) { |
|
900 | + if ($source->getAlias() == $sourceAlias) { |
|
901 | 901 | return true; |
902 | 902 | } |
903 | 903 | } |
@@ -915,8 +915,8 @@ discard block |
||
915 | 915 | public static function getSourceByID(string $sourceID) : Localization_Source |
916 | 916 | { |
917 | 917 | $sources = self::getSources(); |
918 | - foreach($sources as $source) { |
|
919 | - if($source->getID() == $sourceID) { |
|
918 | + foreach ($sources as $source) { |
|
919 | + if ($source->getID() == $sourceID) { |
|
920 | 920 | return $source; |
921 | 921 | } |
922 | 922 | } |
@@ -941,8 +941,8 @@ discard block |
||
941 | 941 | public static function getSourceByAlias(string $sourceAlias) : Localization_Source |
942 | 942 | { |
943 | 943 | $sources = self::getSources(); |
944 | - foreach($sources as $source) { |
|
945 | - if($source->getAlias() == $sourceAlias) { |
|
944 | + foreach ($sources as $source) { |
|
945 | + if ($source->getAlias() == $sourceAlias) { |
|
946 | 946 | return $source; |
947 | 947 | } |
948 | 948 | } |
@@ -984,7 +984,7 @@ discard block |
||
984 | 984 | * @param string $storageFile Where to store the file analysis storage file. |
985 | 985 | * @param string $clientLibrariesFolder Where to put the client libraries and translation files. Will be created if it does not exist. Optional: if not set, client libraries will not be created. |
986 | 986 | */ |
987 | - public static function configure(string $storageFile, string $clientLibrariesFolder='') : void |
|
987 | + public static function configure(string $storageFile, string $clientLibrariesFolder = '') : void |
|
988 | 988 | { |
989 | 989 | self::$configured = true; |
990 | 990 | |
@@ -993,7 +993,7 @@ discard block |
||
993 | 993 | |
994 | 994 | // only write the client libraries to disk if the folder |
995 | 995 | // has been specified. |
996 | - if(!empty($clientLibrariesFolder)) |
|
996 | + if (!empty($clientLibrariesFolder)) |
|
997 | 997 | { |
998 | 998 | self::writeClientFiles(); |
999 | 999 | } |
@@ -1051,7 +1051,7 @@ discard block |
||
1051 | 1051 | * @throws Localization_Exception |
1052 | 1052 | * @see Localization_ClientGenerator |
1053 | 1053 | */ |
1054 | - public static function writeClientFiles(bool $force=false) : void |
|
1054 | + public static function writeClientFiles(bool $force = false) : void |
|
1055 | 1055 | { |
1056 | 1056 | self::createGenerator()->writeFiles($force); |
1057 | 1057 | } |
@@ -1084,7 +1084,7 @@ discard block |
||
1084 | 1084 | */ |
1085 | 1085 | protected static function requireConfiguration() : void |
1086 | 1086 | { |
1087 | - if(!self::$configured) |
|
1087 | + if (!self::$configured) |
|
1088 | 1088 | { |
1089 | 1089 | throw new Localization_Exception( |
1090 | 1090 | 'The localization configuration is incomplete.', |
@@ -1093,7 +1093,7 @@ discard block |
||
1093 | 1093 | ); |
1094 | 1094 | } |
1095 | 1095 | |
1096 | - if(empty(self::$storageFile)) |
|
1096 | + if (empty(self::$storageFile)) |
|
1097 | 1097 | { |
1098 | 1098 | throw new Localization_Exception( |
1099 | 1099 | 'No localization storage file set', |
@@ -1102,7 +1102,7 @@ discard block |
||
1102 | 1102 | ); |
1103 | 1103 | } |
1104 | 1104 | |
1105 | - if(empty(self::$sources)) |
|
1105 | + if (empty(self::$sources)) |
|
1106 | 1106 | { |
1107 | 1107 | throw new Localization_Exception( |
1108 | 1108 | 'No source folders have been defined.', |
@@ -1135,7 +1135,7 @@ discard block |
||
1135 | 1135 | { |
1136 | 1136 | $ids = array(); |
1137 | 1137 | |
1138 | - foreach(self::$sources as $source) { |
|
1138 | + foreach (self::$sources as $source) { |
|
1139 | 1139 | $ids[] = $source->getID(); |
1140 | 1140 | } |
1141 | 1141 | |
@@ -1150,7 +1150,7 @@ discard block |
||
1150 | 1150 | { |
1151 | 1151 | $aliases = array(); |
1152 | 1152 | |
1153 | - foreach(self::$sources as $source) { |
|
1153 | + foreach (self::$sources as $source) { |
|
1154 | 1154 | $aliases[] = $source->getAlias(); |
1155 | 1155 | } |
1156 | 1156 |
@@ -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 |