Completed
Pull Request — master (#110)
by Roman
11:00
created
src/Kdyby/Translation/Phrase.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@
 block discarded – undo
77 77
 	public function translate(Translator $translator, $count = NULL, array $parameters = array(), $domain = NULL, $locale = NULL)
78 78
 	{
79 79
 		if (!is_string($this->message)) {
80
-			throw new InvalidStateException("Message is not a string, type " . gettype($this->message) . ' given.');
80
+			throw new InvalidStateException("Message is not a string, type ".gettype($this->message).' given.');
81 81
 		}
82 82
 
83 83
 		$count = $count !== NULL ? $count : $this->count;
Please login to merge, or discard this patch.
src/Kdyby/Translation/TranslationLoader.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -95,8 +95,8 @@
 block discarded – undo
95 95
 	{
96 96
 		foreach ($this->getLoaders() as $format => $loader) {
97 97
 			// load any existing translation files
98
-			$extension = $catalogue->getLocale() . '.' . $format;
99
-			foreach (Finder::findFiles('*.' . $extension)->from($directory) as $file) {
98
+			$extension = $catalogue->getLocale().'.'.$format;
99
+			foreach (Finder::findFiles('*.'.$extension)->from($directory) as $file) {
100 100
 				/** @var \SplFileInfo $file */
101 101
 				$domain = substr($file->getFileName(), 0, -1 * strlen($extension) - 1);
102 102
 				$this->loadResource($format, $file->getPathname(), $domain, $catalogue);
Please login to merge, or discard this patch.
src/Kdyby/Translation/PrefixedTranslator.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	public function translate($message, $count = NULL, $parameters = array(), $domain = NULL, $locale = NULL)
63 63
 	{
64 64
 		$translationString = ($message instanceof Phrase ? $message->message : $message);
65
-		$prefix = $this->prefix . '.';
65
+		$prefix = $this->prefix.'.';
66 66
 
67 67
 		if (Strings::startsWith($message, '//')) {
68 68
 			$prefix = NULL;
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 		}
71 71
 
72 72
 		if ($message instanceof Phrase) {
73
-			return $this->translator->translate(new Phrase($prefix . $translationString, $message->count, $message->parameters, $message->domain, $message->locale));
73
+			return $this->translator->translate(new Phrase($prefix.$translationString, $message->count, $message->parameters, $message->domain, $message->locale));
74 74
 		}
75 75
 
76 76
 		if (is_array($count)) {
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 			$count = NULL;
81 81
 		}
82 82
 
83
-		return $this->translator->translate($prefix . $translationString, $count, (array) $parameters, $domain, $locale);
83
+		return $this->translator->translate($prefix.$translationString, $count, (array) $parameters, $domain, $locale);
84 84
 	}
85 85
 
86 86
 
Please login to merge, or discard this patch.
src/Kdyby/Translation/Extractors/LatteExtractor.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 			}
69 69
 
70 70
 			if ($token->name === '/_') {
71
-				$catalogue->set(($this->prefix ? $this->prefix . '.' : '') . $buffer, $buffer);
71
+				$catalogue->set(($this->prefix ? $this->prefix.'.' : '').$buffer, $buffer);
72 72
 				$buffer = NULL;
73 73
 
74 74
 			} elseif ($token->name === '_' && empty($token->value)) {
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 					$message = substr(trim($message), 1, -1);
84 84
 				}
85 85
 
86
-				$catalogue->set(($this->prefix ? $this->prefix . '.' : '') . $message, $message);
86
+				$catalogue->set(($this->prefix ? $this->prefix.'.' : '').$message, $message);
87 87
 			}
88 88
 		}
89 89
 	}
Please login to merge, or discard this patch.
src/Kdyby/Translation/LocaleResolver/SessionResolver.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 	{
77 77
 		if (!$this->session->isStarted() && $this->httpResponse->isSent()) {
78 78
 			trigger_error(
79
-				"The advice of session locale resolver is required but the session has not been started and headers had been already sent. " .
79
+				"The advice of session locale resolver is required but the session has not been started and headers had been already sent. ".
80 80
 				"Either start your sessions earlier or disabled the SessionResolver.",
81 81
 				E_USER_WARNING
82 82
 			);
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 			return NULL;
88 88
 		}
89 89
 
90
-		$short = array_map(function ($locale) {
90
+		$short = array_map(function($locale) {
91 91
 			return substr($locale, 0, 2);
92 92
 		}, $translator->getAvailableLocales());
93 93
 
Please login to merge, or discard this patch.
src/Kdyby/Translation/LocaleResolver/AcceptHeaderResolver.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -65,10 +65,10 @@
 block discarded – undo
65 65
 			return NULL;
66 66
 		}
67 67
 
68
-		$s = strtolower($header);  // case insensitive
69
-		$s = strtr($s, '_', '-');  // cs_CZ means cs-CZ
70
-		rsort($langs);             // first more specific
71
-		preg_match_all('#(' . implode('|', $langs) . ')(?:-[^\s,;=]+)?\s*(?:;\s*q=([0-9.]+))?#', $s, $matches);
68
+		$s = strtolower($header); // case insensitive
69
+		$s = strtr($s, '_', '-'); // cs_CZ means cs-CZ
70
+		rsort($langs); // first more specific
71
+		preg_match_all('#('.implode('|', $langs).')(?:-[^\s,;=]+)?\s*(?:;\s*q=([0-9.]+))?#', $s, $matches);
72 72
 
73 73
 		if (!$matches[0]) {
74 74
 			return NULL;
Please login to merge, or discard this patch.
src/Kdyby/Translation/Caching/PhpFileStorage.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -54,10 +54,10 @@
 block discarded – undo
54 54
 	{
55 55
 		return parent::getCacheFile(substr_replace(
56 56
 			$key,
57
-			trim(strtr($this->hint, '\\/@', '.._'), '.') . '-',
57
+			trim(strtr($this->hint, '\\/@', '.._'), '.').'-',
58 58
 			strpos($key, Nette\Caching\Cache::NAMESPACE_SEPARATOR) + 1,
59 59
 			0
60
-		)) . '.php';
60
+		)).'.php';
61 61
 	}
62 62
 
63 63
 }
Please login to merge, or discard this patch.
src/Kdyby/Translation/Diagnostics/Panel.php 1 patch
Spacing   +23 added lines, -24 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 	public function getTab()
92 92
 	{
93 93
 		return '<span title="Translation"><img width="16px" height="16px" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB90DExAuL9uIsPUAAAQ2SURBVFjD7Ze9bxxVFMV/583skjgOIXEaKCNFAgmQ+ExS8qEUCEHH30BBScG/QM1fEmgoAAkoAigSKKFASElHESEFbGcdez7uoXhvZteW7ewmQjRMsTs7s/Pufeece+4d+P/4jw8ddvHq1avv2b5mm02Lr9Y7/gpQBCFDD5YhgsAoRLhHMtHnRYNAAb3yt92//9y3v3x+MFY6LIGIuGYbKedngzAGsPK5Kb8BGRAu9xiuL+zQ6NphsQ5NYB7YhA1jQCObyOHG/3sMlpM0hmGNcmXh7w9PYL5wfsphbCMPaOR7BipEJahV0FHZvZ2D+1i2qY+gYERCZTGZzLdFkLNIht/v72AHGM5Pa85MqowUc4p81PaPo2CgIa9RxOZ8jowDZm0WXo2oBdttN8ihIABC5dPLI7BIQQA5prEGIeYdbnVtSSpD3WCaCCqpMB8jXSshEBFEROZ9TCTvepC/be63HWA2ppNRoJttP1flvkp5BArmNBQl5zSIMJtNRxJEwHqVOF1XGLHVdSQp+0CpAi1UytJVYHteBQ7cm7AgIKnAH7CWhBDrVRqfud91UERLFNPyihQMwaOUIAI5I9D0PU2Xz9frCjs4WVVUMhJstR2SwaUWgvx7VQqyG2b4IoIoO9xsWipllJ6sK1JB7Exd4whmbUcYlCVcRKrVq0DSqCIVRlPZ4SCqO7MHC0Ey1Epiu+k5XafMvbRaFXCgdBxBOIgw202/TyNBtmuHibJRYba6LjuAsgjjCA3UxwWPCEwanRCJ7bYd/eHspFootdwhdvqeJsyegyaCSVK271US2E9BNp8otbTd9STlB89NJvRFmJREJ4K7e0El2Op6NiY1x7GQlpoawihgq+lIZF2s1xWdu9GAcO6Yp6rcE4OcwGDGR7nhUglYRjL32pbOQdMH61VCzgiFc8eUs+2cTIkuoI2MmH20D9TLzEzuTafgwtp0dNXO5FlhsOvSh23zzBPTBfDm4ny0BBBWAInWpSmVmSDzqrEko0TpBwct9W+xGgKL41hWoMeJB/LQsa/JlOYkVDrmAHlpwnF0M6of2gdIC7vUvDUNk1HMbwVRbmo+jA3tOlaYByTYbRJdiG1E3UFFg2IvLxqm67qR1yg71kLflDXvwhHhsxtbSycw2xWffXiPP+/NmFTiGyX21t9m99RbWDCZ1Fy5dAlJeXyz6aOfz48Mzli6aPTp8rMXz/585UVeun7z4WW418Kll0/w9Pk1/t5JTHdh2otpElMl1PX8eP06fdus9ObhQ2g4VBrVxpvvdl/Ovmgacev2Dnf+2GXnxi6zGw/KMJrNJUXPS6fXmCaNw+d8GNV8KHXgp87xyg83tVQCALPvLlvCVUK/3tnh9t3mkw8+/u3Tx3kNu/H6C7z6063lnLBU4dd98NHzF9Z47eKpE4/7Hngw+LHHzveX3zmAyBv/xsvpP+li/lm3bxkuAAAAAElFTkSuQmCC" />'
94
-			. $this->translator->getLocale() . ($this->untranslated ? ' <b>(' . count(array_unique($this->untranslated, SORT_REGULAR)) . ' errors)</b>' : '')
94
+			. $this->translator->getLocale().($this->untranslated ? ' <b>('.count(array_unique($this->untranslated, SORT_REGULAR)).' errors)</b>' : '')
95 95
 			. '</span>';
96 96
 	}
97 97
 
@@ -124,16 +124,16 @@  discard block
 block discarded – undo
124 124
 
125 125
 				/** @var Request[] $snapshot */
126 126
 				$params = $snapshot['request']->getParameters();
127
-				$s .= '<tr><th width="10px">&nbsp;</th>' .
128
-					'<th>' . $h($snapshot['request']->getPresenterName() . (isset($params['action']) ? ':' . $params['action'] : '')) . '</th>' .
129
-					'<th>' . $h($snapshot['locale']) . '</th></tr>';
127
+				$s .= '<tr><th width="10px">&nbsp;</th>'.
128
+					'<th>'.$h($snapshot['request']->getPresenterName().(isset($params['action']) ? ':'.$params['action'] : '')).'</th>'.
129
+					'<th>'.$h($snapshot['locale']).'</th></tr>';
130 130
 
131 131
 				$l = 1;
132 132
 				foreach ($snapshot['resolvers'] as $name => $resolvedLocale) {
133
-					$s .= '<tr><td>' . ($l++) . '.</td><td>' . $h($name) . '</td><td>' . $h($resolvedLocale) . '</td></tr>';
133
+					$s .= '<tr><td>'.($l++).'.</td><td>'.$h($name).'</td><td>'.$h($resolvedLocale).'</td></tr>';
134 134
 				}
135 135
 
136
-				$panel[] = '<table style="width:100%">' . $s . '</table>';
136
+				$panel[] = '<table style="width:100%">'.$s.'</table>';
137 137
 			}
138 138
 		}
139 139
 
@@ -151,14 +151,13 @@  discard block
 block discarded – undo
151 151
 			}
152 152
 
153 153
 			$panel[] = '<h2>Ignored resources</h2>';
154
-			$panel[] = '<p>Whitelist config: ' . implode(', ', array_map($h, $this->localeWhitelist)) . '</p>';
154
+			$panel[] = '<p>Whitelist config: '.implode(', ', array_map($h, $this->localeWhitelist)).'</p>';
155 155
 			$panel[] = $this->renderResources($this->ignoredResources);
156 156
 		}
157 157
 
158
-		return empty($panel) ? '' :
159
-			'<h1>Missing translations: ' .  count(array_unique($this->untranslated, SORT_REGULAR)) .
160
-			', Resources: ' . count(Nette\Utils\Arrays::flatten($this->resources)) . '</h1>' .
161
-			'<div class="nette-inner tracy-inner kdyby-TranslationPanel" style="min-width:500px">' . implode($panel) . '</div>' .
158
+		return empty($panel) ? '' : '<h1>Missing translations: '.count(array_unique($this->untranslated, SORT_REGULAR)).
159
+			', Resources: '.count(Nette\Utils\Arrays::flatten($this->resources)).'</h1>'.
160
+			'<div class="nette-inner tracy-inner kdyby-TranslationPanel" style="min-width:500px">'.implode($panel).'</div>'.
162 161
 			'<style>
163 162
 				#nette-debug .kdyby-TranslationPanel h2,
164 163
 				#tracy-debug .kdyby-TranslationPanel h2 {font-size: 23px;}
@@ -178,19 +177,19 @@  discard block
 block discarded – undo
178 177
 			$s .= '<tr><td>';
179 178
 
180 179
 			if ($message instanceof \Exception || $message instanceof \Throwable) {
181
-				$s .= '<span style="color:red">' . $h($message->getMessage()) . '</span>';
180
+				$s .= '<span style="color:red">'.$h($message->getMessage()).'</span>';
182 181
 
183 182
 			} elseif ($message instanceof Nette\Utils\Html) {
184
-				$s .= '<span style="color:red">Nette\Utils\Html(' . $h((string) $message) . ')</span>';
183
+				$s .= '<span style="color:red">Nette\Utils\Html('.$h((string) $message).')</span>';
185 184
 
186 185
 			} else {
187 186
 				$s .= $h($message);
188 187
 			}
189 188
 
190
-			$s .= '</td><td>' . $h($untranslated['domain']) . '</td></tr>';
189
+			$s .= '</td><td>'.$h($untranslated['domain']).'</td></tr>';
191 190
 		}
192 191
 
193
-		return '<table style="width:100%"><tr><th>Untranslated message</th><th>Translation domain</th></tr>' . $s . '</table>';
192
+		return '<table style="width:100%"><tr><th>Untranslated message</th><th>Translation domain</th></tr>'.$s.'</table>';
194 193
 	}
195 194
 
196 195
 
@@ -204,25 +203,25 @@  discard block
 block discarded – undo
204 203
 		foreach ($resourcesMap as $locale => $resources) {
205 204
 			foreach ($resources as $resourcePath => $domain) {
206 205
 				$s .= '<tr>';
207
-				$s .= '<td>' . $h($locale) . '</td>';
208
-				$s .= '<td>' . $h($domain) . '</td>';
206
+				$s .= '<td>'.$h($locale).'</td>';
207
+				$s .= '<td>'.$h($domain).'</td>';
209 208
 
210
-				$relativePath = str_replace(rtrim($this->rootDir, '/') . '/', '', $resourcePath);
209
+				$relativePath = str_replace(rtrim($this->rootDir, '/').'/', '', $resourcePath);
211 210
 				if (Nette\Utils\Strings::startsWith($relativePath, 'vendor/')) {
212 211
 					$parts = explode('/', $relativePath, 4);
213 212
 					$left = array_pop($parts);
214
-					$relativePath = $h(implode('/', $parts) . '/.../') . '<b>' . $h(basename($left)) . '</b>';
213
+					$relativePath = $h(implode('/', $parts).'/.../').'<b>'.$h(basename($left)).'</b>';
215 214
 
216 215
 				} else {
217
-					$relativePath = $h(dirname($relativePath)) . '/<b>' . $h(basename($relativePath)) . '</b>';
216
+					$relativePath = $h(dirname($relativePath)).'/<b>'.$h(basename($relativePath)).'</b>';
218 217
 				}
219 218
 
220
-				$s .= '<td>' . self::editorLink($resourcePath, 1, $relativePath) . '</td>';
219
+				$s .= '<td>'.self::editorLink($resourcePath, 1, $relativePath).'</td>';
221 220
 				$s .= '</tr>';
222 221
 			}
223 222
 		}
224 223
 
225
-		return '<table style="width:100%"><tr><th>Locale</th><th>Domain</th><th>Resource filename</th></tr>' . $s . '</table>';
224
+		return '<table style="width:100%"><tr><th>Locale</th><th>Domain</th><th>Resource filename</th></tr>'.$s.'</table>';
226 225
 	}
227 226
 
228 227
 
@@ -347,9 +346,9 @@  discard block
 block discarded – undo
347 346
 		if ($call = Helpers::findTrace($e->getPrevious()->getTrace(), $method)) {
348 347
 			return array(
349 348
 				'tab' => 'YAML dictionary',
350
-				'panel' => '<p><b>File:</b> ' . self::editorLink($call['args'][0], $previous->getParsedLine()) . '</p>'
349
+				'panel' => '<p><b>File:</b> '.self::editorLink($call['args'][0], $previous->getParsedLine()).'</p>'
351 350
 					. ($previous->getParsedLine() ? BlueScreen::highlightFile($call['args'][0], $previous->getParsedLine()) : '')
352
-					. '<p>' . $previous->getMessage() . ' </p>'
351
+					. '<p>'.$previous->getMessage().' </p>'
353 352
 			);
354 353
 		}
355 354
 	}
Please login to merge, or discard this patch.
src/Kdyby/Translation/Translator.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 
159 159
 		$tmp = array();
160 160
 		foreach ($parameters as $key => $val) {
161
-			$tmp['%' . trim($key, '%') . '%'] = $val;
161
+			$tmp['%'.trim($key, '%').'%'] = $val;
162 162
 		}
163 163
 		$parameters = $tmp;
164 164
 
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
 	 */
465 465
 	public static function buildWhitelistRegexp($whitelist)
466 466
 	{
467
-		return $whitelist ? '~^(' . implode('|', $whitelist) . ')~i' : NULL;
467
+		return $whitelist ? '~^('.implode('|', $whitelist).')~i' : NULL;
468 468
 	}
469 469
 
470 470
 
Please login to merge, or discard this patch.