@@ -58,53 +58,53 @@ discard block |
||
58 | 58 | $tokens = token_get_all($source); |
59 | 59 | |
60 | 60 | $translateTags = array_merge($this->gettextTags, $this->pgettextTags, $this->ngettextTags); |
61 | - $commentText=null; |
|
62 | - $commentLine=(-10); |
|
61 | + $commentText = null; |
|
62 | + $commentLine = (-10); |
|
63 | 63 | $tokenCount = count($tokens); |
64 | 64 | $i = 0; |
65 | - while ($i<$tokenCount) { |
|
65 | + while ($i < $tokenCount) { |
|
66 | 66 | $token = $tokens[$i]; |
67 | - if (is_array($token) && $token[0] == T_STRING && in_array($token[1], $translateTags)) { |
|
67 | + if (is_array($token) && $token[0]==T_STRING && in_array($token[1], $translateTags)) { |
|
68 | 68 | $entry = new PoEntry; |
69 | 69 | $gtt = array(); |
70 | 70 | list(, $text, $line) = $token; |
71 | - $entry->add(PoTokens::REFERENCE, $refname . ':' . $line); |
|
72 | - $gtt['line']=$line; |
|
73 | - $gtt['function']=$text; |
|
71 | + $entry->add(PoTokens::REFERENCE, $refname.':'.$line); |
|
72 | + $gtt['line'] = $line; |
|
73 | + $gtt['function'] = $text; |
|
74 | 74 | $gtt['args'] = array(); |
75 | 75 | $la = 1; |
76 | - while (is_array($tokens[$i + $la]) && $tokens[$i + $la][0] == T_WHITESPACE) { |
|
76 | + while (is_array($tokens[$i + $la]) && $tokens[$i + $la][0]==T_WHITESPACE) { |
|
77 | 77 | $la++; |
78 | 78 | } |
79 | - if ($tokens[$i + $la] == '(') { |
|
80 | - while ((')' != $token=$tokens[$i + $la]) && ($la < 10)) { |
|
79 | + if ($tokens[$i + $la]=='(') { |
|
80 | + while ((')'!=$token = $tokens[$i + $la]) && ($la < 10)) { |
|
81 | 81 | if (is_array($token) && ( |
82 | - $token[0] == T_CONSTANT_ENCAPSED_STRING |
|
83 | - || $token[0] == T_ENCAPSED_AND_WHITESPACE |
|
82 | + $token[0]==T_CONSTANT_ENCAPSED_STRING |
|
83 | + || $token[0]==T_ENCAPSED_AND_WHITESPACE |
|
84 | 84 | )) { |
85 | 85 | list(, $text, $line) = $token; |
86 | - $gtt['args'][]=$text; |
|
86 | + $gtt['args'][] = $text; |
|
87 | 87 | } |
88 | 88 | $la++; |
89 | 89 | } |
90 | 90 | if (count($gtt['args'])) { |
91 | 91 | if (in_array($gtt['function'], $this->gettextTags)) { |
92 | 92 | $entry->set(PoTokens::MESSAGE, $this->escapeForPo($gtt['args'][0])); |
93 | - } elseif (count($gtt['args'])>1 && in_array($gtt['function'], $this->pgettextTags)) { |
|
93 | + } elseif (count($gtt['args']) > 1 && in_array($gtt['function'], $this->pgettextTags)) { |
|
94 | 94 | $entry->set(PoTokens::CONTEXT, $this->escapeForPo($gtt['args'][0])); |
95 | 95 | $entry->set(PoTokens::MESSAGE, $this->escapeForPo($gtt['args'][1])); |
96 | - } elseif (count($gtt['args'])>1 && in_array($gtt['function'], $this->ngettextTags)) { |
|
96 | + } elseif (count($gtt['args']) > 1 && in_array($gtt['function'], $this->ngettextTags)) { |
|
97 | 97 | $entry->set(PoTokens::MESSAGE, $this->escapeForPo($gtt['args'][0])); |
98 | 98 | $entry->set(PoTokens::PLURAL, $this->escapeForPo($gtt['args'][1])); |
99 | 99 | } |
100 | 100 | $this->checkPhpFormatFlag($entry); |
101 | - if ($gtt['line']==($commentLine+1)) { |
|
101 | + if ($gtt['line']==($commentLine + 1)) { |
|
102 | 102 | $entry->set(PoTokens::EXTRACTED_COMMENTS, $this->stripComment($commentText)); |
103 | 103 | } |
104 | 104 | $this->poFile->mergeEntry($entry); |
105 | 105 | } |
106 | 106 | } |
107 | - } elseif (is_array($token) && $token[0] == T_COMMENT) { |
|
107 | + } elseif (is_array($token) && $token[0]==T_COMMENT) { |
|
108 | 108 | list(, $commentText, $commentLine) = $token; |
109 | 109 | } |
110 | 110 | $i++; |
@@ -122,6 +122,6 @@ discard block |
||
122 | 122 | */ |
123 | 123 | protected function stripComment($string) |
124 | 124 | { |
125 | - return trim(str_replace(array('//','/*','*/'), '', $string)); |
|
125 | + return trim(str_replace(array('//', '/*', '*/'), '', $string)); |
|
126 | 126 | } |
127 | 127 | } |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | */ |
48 | 48 | public function add($type, $value) |
49 | 49 | { |
50 | - if ($this->entry[$type] === null) { |
|
50 | + if ($this->entry[$type]===null) { |
|
51 | 51 | $this->entry[$type] = array(); |
52 | 52 | } |
53 | 53 | $this->entry[$type] = (array) $this->entry[$type]; |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | } |
69 | 69 | $value = stripcslashes($value); |
70 | 70 | |
71 | - if ($this->entry[$type] === null) { |
|
71 | + if ($this->entry[$type]===null) { |
|
72 | 72 | $this->entry[$type] = array(); |
73 | 73 | } |
74 | 74 | $this->entry[$type] = (array) $this->entry[$type]; |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | } |
94 | 94 | $value = stripcslashes($value); |
95 | 95 | |
96 | - if ($this->entry[$type] === null) { |
|
96 | + if ($this->entry[$type]===null) { |
|
97 | 97 | $this->entry[$type] = array(); |
98 | 98 | } |
99 | 99 | if (isset($this->entry[$type][$position]) && |
@@ -175,24 +175,24 @@ discard block |
||
175 | 175 | $output = $this->dumpEntryComments(); |
176 | 176 | |
177 | 177 | $key = PoTokens::CONTEXT; |
178 | - if (!($this->entry[$key] === null)) { |
|
179 | - $output .= $key . $this->formatQuotedString($this->entry[$key]); |
|
178 | + if (!($this->entry[$key]===null)) { |
|
179 | + $output .= $key.$this->formatQuotedString($this->entry[$key]); |
|
180 | 180 | } |
181 | 181 | $key = PoTokens::MESSAGE; |
182 | - if (!($this->entry[$key] === null)) { |
|
183 | - $output .= $key . $this->formatQuotedString($this->entry[$key]); |
|
182 | + if (!($this->entry[$key]===null)) { |
|
183 | + $output .= $key.$this->formatQuotedString($this->entry[$key]); |
|
184 | 184 | $key = PoTokens::PLURAL; |
185 | - if (!($this->entry[$key] === null)) { |
|
186 | - $output .= $key . $this->formatQuotedString($this->entry[$key]); |
|
185 | + if (!($this->entry[$key]===null)) { |
|
186 | + $output .= $key.$this->formatQuotedString($this->entry[$key]); |
|
187 | 187 | $key = PoTokens::TRANSLATED; |
188 | 188 | $plurals = $this->entry[$key]; |
189 | 189 | $plurals = is_array($plurals) ? $plurals : array('', ''); |
190 | 190 | foreach ($plurals as $i => $value) { |
191 | - $output .= "{$key}[{$i}]" . $this->formatQuotedString($value); |
|
191 | + $output .= "{$key}[{$i}]".$this->formatQuotedString($value); |
|
192 | 192 | } |
193 | 193 | } else { |
194 | 194 | $key = PoTokens::TRANSLATED; |
195 | - $output .= $key . $this->formatQuotedString($this->entry[$key]); |
|
195 | + $output .= $key.$this->formatQuotedString($this->entry[$key]); |
|
196 | 196 | } |
197 | 197 | } |
198 | 198 | |
@@ -222,10 +222,10 @@ discard block |
||
222 | 222 | $section = $this->entry[$type]; |
223 | 223 | if (is_array($section)) { |
224 | 224 | foreach ($section as $comment) { |
225 | - $output .= $type . ' ' . $comment . "\n"; |
|
225 | + $output .= $type.' '.$comment."\n"; |
|
226 | 226 | } |
227 | - } elseif (!($section === null)) { |
|
228 | - $output .= $type . ' ' . $section . "\n"; |
|
227 | + } elseif (!($section===null)) { |
|
228 | + $output .= $type.' '.$section."\n"; |
|
229 | 229 | } |
230 | 230 | } |
231 | 231 | |
@@ -247,15 +247,15 @@ discard block |
||
247 | 247 | if (is_array($value)) { |
248 | 248 | $string = ''; |
249 | 249 | foreach ($value as $partial) { |
250 | - $string .= $this->formatQuotedString($partial, true) . "\n"; |
|
250 | + $string .= $this->formatQuotedString($partial, true)."\n"; |
|
251 | 251 | } |
252 | - return $bare ? $string : ' ' . $string; |
|
252 | + return $bare ? $string : ' '.$string; |
|
253 | 253 | } else { |
254 | - $string = ($value === null) ? '' : $value; |
|
254 | + $string = ($value===null) ? '' : $value; |
|
255 | 255 | $string = stripcslashes($string); |
256 | 256 | $string = addcslashes($string, "\0..\37\""); |
257 | - $string = '"' . $string . '"'; |
|
258 | - return $bare ? $string : ' ' . $string . "\n"; |
|
257 | + $string = '"'.$string.'"'; |
|
258 | + return $bare ? $string : ' '.$string."\n"; |
|
259 | 259 | } |
260 | 260 | } |
261 | 261 | |
@@ -294,13 +294,13 @@ discard block |
||
294 | 294 | { |
295 | 295 | if (!$this->hasFlag($name)) { |
296 | 296 | $flagEntry = $this->entry[PoTokens::FLAG]; |
297 | - if ($flagEntry === null) { |
|
297 | + if ($flagEntry===null) { |
|
298 | 298 | $this->set(PoTokens::FLAG, $name); |
299 | 299 | } elseif (is_array($flagEntry)) { |
300 | 300 | $flagEntry[] = $name; |
301 | 301 | $this->set(PoTokens::FLAG, implode(',', $flagEntry)); |
302 | 302 | } else { |
303 | - $this->set(PoTokens::FLAG, $flagEntry . ',' . $name); |
|
303 | + $this->set(PoTokens::FLAG, $flagEntry.','.$name); |
|
304 | 304 | } |
305 | 305 | } |
306 | 306 | } |
@@ -222,7 +222,7 @@ |
||
222 | 222 | { |
223 | 223 | if (preg_match( |
224 | 224 | '#(?<!%)%(?:\d+\$)?[+-]?(?:[ 0]|\'.{1})?-?\d*(?:\.\d+)?[bcdeEufFgGosxX]#', |
225 | - $entry->get(PoTokens::MESSAGE) . $entry->get(PoTokens::PLURAL) |
|
225 | + $entry->get(PoTokens::MESSAGE).$entry->get(PoTokens::PLURAL) |
|
226 | 226 | )) { |
227 | 227 | $entry->addFlag('php-format'); |
228 | 228 | } |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | { |
40 | 40 | $this->structuredHeaders = array(); |
41 | 41 | $headers = $this->entry[PoTokens::TRANSLATED]; |
42 | - $headers = ($headers === null) ? array() : $headers; |
|
42 | + $headers = ($headers===null) ? array() : $headers; |
|
43 | 43 | $full = implode('', $headers); |
44 | 44 | $headers = explode("\n", $full); |
45 | 45 | // split on ':' |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | $headers = array(""); |
69 | 69 | |
70 | 70 | foreach ($this->structuredHeaders as $h) { |
71 | - $headers[] = $h['key'] . ': ' . $h['value'] . "\n"; |
|
71 | + $headers[] = $h['key'].': '.$h['value']."\n"; |
|
72 | 72 | } |
73 | 73 | $this->entry[PoTokens::TRANSLATED] = $headers; |
74 | 74 | return true; |
@@ -73,11 +73,11 @@ discard block |
||
73 | 73 | { |
74 | 74 | $key = ''; |
75 | 75 | if (!empty($msgctxt)) { |
76 | - $key .= $msgctxt . '|'; |
|
76 | + $key .= $msgctxt.'|'; |
|
77 | 77 | } |
78 | 78 | $key .= $msgid; |
79 | 79 | if (!empty($msgid_plural)) { |
80 | - $key .= '|' . $msgid_plural; |
|
80 | + $key .= '|'.$msgid_plural; |
|
81 | 81 | } |
82 | 82 | return $key; |
83 | 83 | } |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | |
261 | 261 | // try by the key first. |
262 | 262 | if (!empty($key) && isset($this->entries[$key])) { |
263 | - if ($entry === $this->entries[$key]) { |
|
263 | + if ($entry===$this->entries[$key]) { |
|
264 | 264 | unset($this->entries[$key]); |
265 | 265 | return true; |
266 | 266 | } |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | |
269 | 269 | // the entry can't be matched by key, so we have to loop :( |
270 | 270 | foreach ($this->entries as $key => $value) { |
271 | - if ($entry === $value) { |
|
271 | + if ($entry===$value) { |
|
272 | 272 | unset($this->entries[$key]); |
273 | 273 | return true; |
274 | 274 | } |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | |
277 | 277 | // no match found in main entries, try the unkeyedEntries |
278 | 278 | foreach ($this->unkeyedEntries as $key => $value) { |
279 | - if ($entry === $value) { |
|
279 | + if ($entry===$value) { |
|
280 | 280 | unset($this->unkeyedEntries[$key]); |
281 | 281 | return true; |
282 | 282 | } |
@@ -299,10 +299,10 @@ discard block |
||
299 | 299 | $source = $this->dumpString(); |
300 | 300 | $testName = file_exists($file) ? $file : dirname($file); |
301 | 301 | $status = is_writable($testName); |
302 | - if ($status === true) { |
|
302 | + if ($status===true) { |
|
303 | 303 | $status = file_put_contents($file, $source); |
304 | 304 | } |
305 | - if (false === $status) { |
|
305 | + if (false===$status) { |
|
306 | 306 | throw new FileNotWritableException($file); |
307 | 307 | } |
308 | 308 | } |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | */ |
315 | 315 | public function dumpString() |
316 | 316 | { |
317 | - if ($this->header === null) { |
|
317 | + if ($this->header===null) { |
|
318 | 318 | $this->header = new PoHeader; |
319 | 319 | $this->header->buildDefaultHeader(); |
320 | 320 | } |
@@ -400,22 +400,22 @@ discard block |
||
400 | 400 | $inHeader = false; |
401 | 401 | } |
402 | 402 | if (!$wsBreak) { |
403 | - if (!($entry === null)) { |
|
403 | + if (!($entry===null)) { |
|
404 | 404 | $this->addEntry($entry); |
405 | 405 | } |
406 | 406 | $entry = null; |
407 | - $wsBreak=true; |
|
407 | + $wsBreak = true; |
|
408 | 408 | } |
409 | 409 | } else { |
410 | - $wsBreak=false; |
|
411 | - $unrecognized[$line+1] = $s; |
|
410 | + $wsBreak = false; |
|
411 | + $unrecognized[$line + 1] = $s; |
|
412 | 412 | } |
413 | 413 | } else { |
414 | - if ($entry === null) { |
|
414 | + if ($entry===null) { |
|
415 | 415 | $entry = new PoEntry; |
416 | 416 | } |
417 | - $wsBreak=false; |
|
418 | - $currentKey = $matches[2]; // will be used to set last key |
|
417 | + $wsBreak = false; |
|
418 | + $currentKey = $matches[2]; // will be used to set last key |
|
419 | 419 | switch ($matches[2]) { |
420 | 420 | case PoTokens::TRANSLATOR_COMMENTS: |
421 | 421 | case PoTokens::EXTRACTED_COMMENTS: |
@@ -438,10 +438,10 @@ discard block |
||
438 | 438 | $entry->addQuotedAtPosition( |
439 | 439 | PoTokens::TRANSLATED, |
440 | 440 | $currentPlural, |
441 | - '"' . $matches[5] |
|
441 | + '"'.$matches[5] |
|
442 | 442 | ); |
443 | 443 | } else { |
444 | - $entry->addQuoted($currentKey, '"' . $matches[5]); |
|
444 | + $entry->addQuoted($currentKey, '"'.$matches[5]); |
|
445 | 445 | } |
446 | 446 | } elseif (substr($matches[2], 0, 7)==PoTokens::TRANSLATED_PLURAL) { |
447 | 447 | $currentKey = PoTokens::TRANSLATED_PLURAL; |
@@ -457,14 +457,14 @@ discard block |
||
457 | 457 | $value = empty($value) ? '' : $value; |
458 | 458 | $entry->add(PoTokens::TRANSLATOR_COMMENTS, $value); |
459 | 459 | } else { |
460 | - $unrecognized[$line+1] = $s; |
|
460 | + $unrecognized[$line + 1] = $s; |
|
461 | 461 | } |
462 | 462 | break; |
463 | 463 | } |
464 | 464 | $lastKey = $currentKey; |
465 | 465 | } |
466 | 466 | } |
467 | - if (!($entry === null)) { |
|
467 | + if (!($entry===null)) { |
|
468 | 468 | $this->addEntry($entry); |
469 | 469 | } |
470 | 470 |