@@ -9,13 +9,11 @@ |
||
9 | 9 | /** |
10 | 10 | * Class to get gettext strings from blade.php files returning arrays. |
11 | 11 | */ |
12 | -class Blade extends Extractor implements ExtractorInterface |
|
13 | -{ |
|
12 | +class Blade extends Extractor implements ExtractorInterface { |
|
14 | 13 | /** |
15 | 14 | * {@inheritdoc} |
16 | 15 | */ |
17 | - public static function fromString($string, Translations $translations, array $options = []) |
|
18 | - { |
|
16 | + public static function fromString($string, Translations $translations, array $options = []) { |
|
19 | 17 | if (empty($options['facade'])) { |
20 | 18 | $cachePath = empty($options['cachePath']) ? sys_get_temp_dir() : $options['cachePath']; |
21 | 19 | $bladeCompiler = new BladeCompiler(new Filesystem(), $cachePath); |
@@ -4,8 +4,7 @@ |
||
4 | 4 | |
5 | 5 | use Gettext\Translations; |
6 | 6 | |
7 | -interface ExtractorInterface |
|
8 | -{ |
|
7 | +interface ExtractorInterface { |
|
9 | 8 | /** |
10 | 9 | * Extract the translations from a file. |
11 | 10 | * |
@@ -9,8 +9,7 @@ discard block |
||
9 | 9 | /** |
10 | 10 | * Class to get gettext strings from csv. |
11 | 11 | */ |
12 | -class Csv extends Extractor implements ExtractorInterface |
|
13 | -{ |
|
12 | +class Csv extends Extractor implements ExtractorInterface { |
|
14 | 13 | use HeadersExtractorTrait; |
15 | 14 | use CsvTrait; |
16 | 15 | |
@@ -23,8 +22,7 @@ discard block |
||
23 | 22 | /** |
24 | 23 | * {@inheritdoc} |
25 | 24 | */ |
26 | - public static function fromString($string, Translations $translations, array $options = []) |
|
27 | - { |
|
25 | + public static function fromString($string, Translations $translations, array $options = []) { |
|
28 | 26 | $options += static::$options; |
29 | 27 | $handle = fopen('php://memory', 'w'); |
30 | 28 |
@@ -48,8 +48,7 @@ discard block |
||
48 | 48 | * {@inheritdoc} |
49 | 49 | * @throws Exception |
50 | 50 | */ |
51 | - public static function fromString($string, Translations $translations, array $options = []) |
|
52 | - { |
|
51 | + public static function fromString($string, Translations $translations, array $options = []) { |
|
53 | 52 | static::fromStringMultiple($string, [$translations], $options); |
54 | 53 | } |
55 | 54 | |
@@ -57,8 +56,7 @@ discard block |
||
57 | 56 | * @inheritDoc |
58 | 57 | * @throws Exception |
59 | 58 | */ |
60 | - public static function fromStringMultiple($string, array $translations, array $options = []) |
|
61 | - { |
|
59 | + public static function fromStringMultiple($string, array $translations, array $options = []) { |
|
62 | 60 | $options += static::$options; |
63 | 61 | |
64 | 62 | /** @var FunctionsScanner $functions */ |
@@ -74,8 +72,7 @@ discard block |
||
74 | 72 | /** |
75 | 73 | * @inheritDoc |
76 | 74 | */ |
77 | - public static function fromFileMultiple($file, array $translations, array $options = []) |
|
78 | - { |
|
75 | + public static function fromFileMultiple($file, array $translations, array $options = []) { |
|
79 | 76 | foreach (static::getFiles($file) as $file) { |
80 | 77 | $options['file'] = $file; |
81 | 78 | static::fromStringMultiple(static::readFile($file), $translations, $options); |
@@ -90,8 +87,7 @@ discard block |
||
90 | 87 | * |
91 | 88 | * @return string |
92 | 89 | */ |
93 | - public static function convertString($value) |
|
94 | - { |
|
90 | + public static function convertString($value) { |
|
95 | 91 | if (strpos($value, '\\') === false) { |
96 | 92 | return substr($value, 1, -1); |
97 | 93 | } |
@@ -141,8 +137,7 @@ discard block |
||
141 | 137 | * @return string|null |
142 | 138 | * @see http://php.net/manual/en/function.chr.php#118804 |
143 | 139 | */ |
144 | - protected static function unicodeChar($dec) |
|
145 | - { |
|
140 | + protected static function unicodeChar($dec) { |
|
146 | 141 | if ($dec < 0x80) { |
147 | 142 | return chr($dec); |
148 | 143 | } |
@@ -8,15 +8,13 @@ |
||
8 | 8 | /** |
9 | 9 | * Class to get gettext strings from plain json. |
10 | 10 | */ |
11 | -class JsonDictionary extends Extractor implements ExtractorInterface |
|
12 | -{ |
|
11 | +class JsonDictionary extends Extractor implements ExtractorInterface { |
|
13 | 12 | use DictionaryTrait; |
14 | 13 | |
15 | 14 | /** |
16 | 15 | * {@inheritdoc} |
17 | 16 | */ |
18 | - public static function fromString($string, Translations $translations, array $options = []) |
|
19 | - { |
|
17 | + public static function fromString($string, Translations $translations, array $options = []) { |
|
20 | 18 | $messages = json_decode($string, true); |
21 | 19 | |
22 | 20 | if (is_array($messages)) { |
@@ -9,8 +9,7 @@ discard block |
||
9 | 9 | /** |
10 | 10 | * Class to get gettext strings from .mo files. |
11 | 11 | */ |
12 | -class Mo extends Extractor implements ExtractorInterface |
|
13 | -{ |
|
12 | +class Mo extends Extractor implements ExtractorInterface { |
|
14 | 13 | const MAGIC1 = -1794895138; |
15 | 14 | const MAGIC2 = -569244523; |
16 | 15 | const MAGIC3 = 2500072158; |
@@ -20,13 +19,13 @@ discard block |
||
20 | 19 | /** |
21 | 20 | * {@inheritdoc} |
22 | 21 | */ |
23 | - public static function fromString($string, Translations $translations, array $options = []) |
|
24 | - { |
|
22 | + public static function fromString($string, Translations $translations, array $options = []) { |
|
25 | 23 | /** @var StringReader $stream */ |
26 | 24 | $stream = new static::$stringReaderClass($string); |
27 | 25 | $magic = static::readInt($stream, 'V'); |
28 | 26 | |
29 | - if (($magic === static::MAGIC1) || ($magic === static::MAGIC3)) { //to make sure it works for 64-bit platforms |
|
27 | + if (($magic === static::MAGIC1) || ($magic === static::MAGIC3)) { |
|
28 | +//to make sure it works for 64-bit platforms |
|
30 | 29 | $byteOrder = 'V'; //low endian |
31 | 30 | } elseif ($magic === (static::MAGIC2 & 0xFFFFFFFF)) { |
32 | 31 | $byteOrder = 'N'; //big endian |
@@ -108,8 +107,7 @@ discard block |
||
108 | 107 | * @param StringReader $stream |
109 | 108 | * @param string $byteOrder |
110 | 109 | */ |
111 | - protected static function readInt(StringReader $stream, $byteOrder) |
|
112 | - { |
|
110 | + protected static function readInt(StringReader $stream, $byteOrder) { |
|
113 | 111 | if (($read = $stream->read(4)) === false) { |
114 | 112 | return false; |
115 | 113 | } |
@@ -124,8 +122,7 @@ discard block |
||
124 | 122 | * @param string $byteOrder |
125 | 123 | * @param int $count |
126 | 124 | */ |
127 | - protected static function readIntArray(StringReader $stream, $byteOrder, $count) |
|
128 | - { |
|
125 | + protected static function readIntArray(StringReader $stream, $byteOrder, $count) { |
|
129 | 126 | return unpack($byteOrder.$count, $stream->read(4 * $count)); |
130 | 127 | } |
131 | 128 | } |
@@ -7,13 +7,11 @@ discard block |
||
7 | 7 | /** |
8 | 8 | * Class to get gettext strings from json files. |
9 | 9 | */ |
10 | -class Jed extends Extractor implements ExtractorInterface |
|
11 | -{ |
|
10 | +class Jed extends Extractor implements ExtractorInterface { |
|
12 | 11 | /** |
13 | 12 | * {@inheritdoc} |
14 | 13 | */ |
15 | - public static function fromString($string, Translations $translations, array $options = []) |
|
16 | - { |
|
14 | + public static function fromString($string, Translations $translations, array $options = []) { |
|
17 | 15 | static::extract(json_decode($string, true), $translations); |
18 | 16 | } |
19 | 17 | |
@@ -23,8 +21,7 @@ discard block |
||
23 | 21 | * @param array $content |
24 | 22 | * @param Translations $translations |
25 | 23 | */ |
26 | - public static function extract(array $content, Translations $translations) |
|
27 | - { |
|
24 | + public static function extract(array $content, Translations $translations) { |
|
28 | 25 | $messages = current($content); |
29 | 26 | $headers = isset($messages['']) ? $messages[''] : null; |
30 | 27 | unset($messages['']); |
@@ -9,8 +9,7 @@ discard block |
||
9 | 9 | /** |
10 | 10 | * Class to get gettext strings from php files returning arrays. |
11 | 11 | */ |
12 | -class Po extends Extractor implements ExtractorInterface |
|
13 | -{ |
|
12 | +class Po extends Extractor implements ExtractorInterface { |
|
14 | 13 | use HeadersExtractorTrait; |
15 | 14 | |
16 | 15 | /** |
@@ -18,8 +17,7 @@ discard block |
||
18 | 17 | * |
19 | 18 | * {@inheritdoc} |
20 | 19 | */ |
21 | - public static function fromString($string, Translations $translations, array $options = []) |
|
22 | - { |
|
20 | + public static function fromString($string, Translations $translations, array $options = []) { |
|
23 | 21 | $lines = explode("\n", $string); |
24 | 22 | $i = 0; |
25 | 23 | |
@@ -159,8 +157,7 @@ discard block |
||
159 | 157 | * |
160 | 158 | * @return string |
161 | 159 | */ |
162 | - protected static function fixMultiLines($line, array $lines, &$i) |
|
163 | - { |
|
160 | + protected static function fixMultiLines($line, array $lines, &$i) { |
|
164 | 161 | for ($j = $i, $t = count($lines); $j < $t; ++$j) { |
165 | 162 | if (substr($line, -1, 1) == '"' && isset($lines[$j + 1])) { |
166 | 163 | $nextLine = trim($lines[$j + 1]); |
@@ -187,8 +184,7 @@ discard block |
||
187 | 184 | * |
188 | 185 | * @return string |
189 | 186 | */ |
190 | - public static function convertString($value) |
|
191 | - { |
|
187 | + public static function convertString($value) { |
|
192 | 188 | if (!$value) { |
193 | 189 | return ''; |
194 | 190 | } |
@@ -47,8 +47,7 @@ discard block |
||
47 | 47 | * @inheritDoc |
48 | 48 | * @throws Exception |
49 | 49 | */ |
50 | - public static function fromFileMultiple($file, array $translations, array $options = []) |
|
51 | - { |
|
50 | + public static function fromFileMultiple($file, array $translations, array $options = []) { |
|
52 | 51 | foreach (static::getFiles($file) as $file) { |
53 | 52 | $options['file'] = $file; |
54 | 53 | static::fromStringMultiple(static::readFile($file), $translations, $options); |
@@ -59,8 +58,7 @@ discard block |
||
59 | 58 | * @inheritdoc |
60 | 59 | * @throws Exception |
61 | 60 | */ |
62 | - public static function fromString($string, Translations $translations, array $options = []) |
|
63 | - { |
|
61 | + public static function fromString($string, Translations $translations, array $options = []) { |
|
64 | 62 | static::fromStringMultiple($string, [$translations], $options); |
65 | 63 | } |
66 | 64 | |
@@ -68,8 +66,7 @@ discard block |
||
68 | 66 | * @inheritDoc |
69 | 67 | * @throws Exception |
70 | 68 | */ |
71 | - public static function fromStringMultiple($string, array $translations, array $options = []) |
|
72 | - { |
|
69 | + public static function fromStringMultiple($string, array $translations, array $options = []) { |
|
73 | 70 | $options += static::$options; |
74 | 71 | $options += [ |
75 | 72 | // HTML attribute prefixes we parse as JS which could contain translations (are JS expressions) |
@@ -147,8 +144,7 @@ discard block |
||
147 | 144 | * @param $string |
148 | 145 | * @return bool|string |
149 | 146 | */ |
150 | - protected static function extractScriptTag($string) |
|
151 | - { |
|
147 | + protected static function extractScriptTag($string) { |
|
152 | 148 | if (preg_match('#<\s*?script\b[^>]*>(.*?)</script\b[^>]*>#s', $string, $matches)) { |
153 | 149 | return $matches[1]; |
154 | 150 | } |
@@ -160,8 +156,7 @@ discard block |
||
160 | 156 | * @param string $html |
161 | 157 | * @return DOMDocument |
162 | 158 | */ |
163 | - protected static function convertHtmlToDom($html) |
|
164 | - { |
|
159 | + protected static function convertHtmlToDom($html) { |
|
165 | 160 | $dom = new DOMDocument; |
166 | 161 | |
167 | 162 | libxml_use_internal_errors(true); |
@@ -229,8 +224,7 @@ discard block |
||
229 | 224 | * @param DOMNode $dom |
230 | 225 | * @param Translations|Translations[] $translations |
231 | 226 | */ |
232 | - protected static function getTagTranslations(array $options, DOMNode $dom, $translations) |
|
233 | - { |
|
227 | + protected static function getTagTranslations(array $options, DOMNode $dom, $translations) { |
|
234 | 228 | // Since tag scanning does not support domains, we always use the first translation given |
235 | 229 | $translations = is_array($translations) ? reset($translations) : $translations; |
236 | 230 | |
@@ -293,8 +287,7 @@ discard block |
||
293 | 287 | * @param DOMNode $dom |
294 | 288 | * @return string JS code |
295 | 289 | */ |
296 | - protected static function getTemplateAttributeFakeJs(array $options, DOMNode $dom) |
|
297 | - { |
|
290 | + protected static function getTemplateAttributeFakeJs(array $options, DOMNode $dom) { |
|
298 | 291 | $expressionsByLine = static::getVueAttributeExpressions($options['attributePrefixes'], $dom); |
299 | 292 | |
300 | 293 | if (empty($expressionsByLine)) { |
@@ -364,8 +357,7 @@ discard block |
||
364 | 357 | * @param string[] $attributePrefixes |
365 | 358 | * @return bool |
366 | 359 | */ |
367 | - protected static function isAttributeMatching($attributeName, $attributePrefixes) |
|
368 | - { |
|
360 | + protected static function isAttributeMatching($attributeName, $attributePrefixes) { |
|
369 | 361 | foreach ($attributePrefixes as $prefix) { |
370 | 362 | if (strpos($attributeName, $prefix) === 0) { |
371 | 363 | return true; |
@@ -381,8 +373,7 @@ discard block |
||
381 | 373 | * @param DOMNode $dom |
382 | 374 | * @return string JS code |
383 | 375 | */ |
384 | - protected static function getTemplateFakeJs(DOMNode $dom) |
|
385 | - { |
|
376 | + protected static function getTemplateFakeJs(DOMNode $dom) { |
|
386 | 377 | $fakeJs = ''; |
387 | 378 | $lines = explode("\n", $dom->textContent); |
388 | 379 | |
@@ -402,8 +393,7 @@ discard block |
||
402 | 393 | * @param string $line |
403 | 394 | * @return string[] |
404 | 395 | */ |
405 | - protected static function parseOneTemplateLine($line) |
|
406 | - { |
|
396 | + protected static function parseOneTemplateLine($line) { |
|
407 | 397 | $line = trim($line); |
408 | 398 | |
409 | 399 | if (!$line) { |