Completed
Pull Request — master (#154)
by Michal
02:01
created
src/Phrase.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@
 block discarded – undo
83 83
 	public function translate(Translator $translator, $count = NULL, array $parameters = [], $domain = NULL, $locale = NULL)
84 84
 	{
85 85
 		if (!is_string($this->message)) {
86
-			throw new \Kdyby\Translation\InvalidStateException('Message is not a string, type ' . gettype($this->message) . ' given.');
86
+			throw new \Kdyby\Translation\InvalidStateException('Message is not a string, type '.gettype($this->message).' given.');
87 87
 		}
88 88
 
89 89
 		$count = ($count !== NULL) ? (int) $count : $this->count;
Please login to merge, or discard this patch.
src/DI/TranslationExtension.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 
130 130
 		$builder->addDefinition($this->prefix('helpers'))
131 131
 			->setClass(TemplateHelpers::class)
132
-			->setFactory($this->prefix('@default') . '::createTemplateHelpers');
132
+			->setFactory($this->prefix('@default').'::createTemplateHelpers');
133 133
 
134 134
 		$builder->addDefinition($this->prefix('fallbackResolver'))
135 135
 			->setClass(FallbackResolver::class);
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 		$builder->addDefinition($this->prefix('loader'))
154 154
 			->setClass(TranslationLoader::class);
155 155
 
156
-		$loaders = $this->loadFromFile(__DIR__ . '/config/loaders.neon');
156
+		$loaders = $this->loadFromFile(__DIR__.'/config/loaders.neon');
157 157
 		$this->loadLoaders($loaders, $config['loaders'] ?: array_keys($loaders));
158 158
 
159 159
 		if ($this->isRegisteredConsoleExtension()) {
@@ -216,8 +216,8 @@  discard block
 block discarded – undo
216 216
 	{
217 217
 		$builder = $this->getContainerBuilder();
218 218
 
219
-		foreach ($this->loadFromFile(__DIR__ . '/config/dumpers.neon') as $format => $class) {
220
-			$builder->addDefinition($this->prefix('dumper.' . $format))
219
+		foreach ($this->loadFromFile(__DIR__.'/config/dumpers.neon') as $format => $class) {
220
+			$builder->addDefinition($this->prefix('dumper.'.$format))
221 221
 				->setClass($class)
222 222
 				->addTag(self::TAG_DUMPER, $format);
223 223
 		}
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 			if (array_search($format, $allowed) === FALSE) {
232 232
 				continue;
233 233
 			}
234
-			$builder->addDefinition($this->prefix('loader.' . $format))
234
+			$builder->addDefinition($this->prefix('loader.'.$format))
235 235
 				->setClass($class)
236 236
 				->addTag(self::TAG_LOADER, $format);
237 237
 		}
@@ -241,8 +241,8 @@  discard block
 block discarded – undo
241 241
 	{
242 242
 		$builder = $this->getContainerBuilder();
243 243
 
244
-		foreach ($this->loadFromFile(__DIR__ . '/config/extractors.neon') as $format => $class) {
245
-			$builder->addDefinition($this->prefix('extractor.' . $format))
244
+		foreach ($this->loadFromFile(__DIR__.'/config/extractors.neon') as $format => $class) {
245
+			$builder->addDefinition($this->prefix('extractor.'.$format))
246 246
 				->setClass($class)
247 247
 				->addTag(self::TAG_EXTRACTOR, $format);
248 248
 		}
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
 
256 256
 		$this->beforeCompileLogging($config);
257 257
 
258
-		$registerToLatte = function (ServiceDefinition $def) {
258
+		$registerToLatte = function(ServiceDefinition $def) {
259 259
 			$def->addSetup('?->onCompile[] = function($engine) { ?::install($engine->getCompiler()); }', ['@self', new PhpLiteral(TranslateMacros::class)]);
260 260
 
261 261
 			$def->addSetup('addProvider', ['translator', $this->prefix('@default')])
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 		foreach ($builder->findByTag(self::TAG_EXTRACTOR) as $extractorId => $meta) {
296 296
 			Validators::assert($meta, 'string:2..');
297 297
 
298
-			$extractor->addSetup('addExtractor', [$meta, '@' . $extractorId]);
298
+			$extractor->addSetup('addExtractor', [$meta, '@'.$extractorId]);
299 299
 
300 300
 			$builder->getDefinition($extractorId)->setAutowired(FALSE);
301 301
 		}
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
 		foreach ($builder->findByTag(self::TAG_DUMPER) as $dumperId => $meta) {
305 305
 			Validators::assert($meta, 'string:2..');
306 306
 
307
-			$writer->addSetup('addDumper', [$meta, '@' . $dumperId]);
307
+			$writer->addSetup('addDumper', [$meta, '@'.$dumperId]);
308 308
 
309 309
 			$builder->getDefinition($dumperId)->setAutowired(FALSE);
310 310
 		}
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 			$config['dirs'] = array_merge($config['dirs'], array_values($extension->getTranslationResources()));
328 328
 		}
329 329
 
330
-		$config['dirs'] = array_map(function ($dir) {
330
+		$config['dirs'] = array_map(function($dir) {
331 331
 			return str_replace((DIRECTORY_SEPARATOR === '/') ? '\\' : '/', DIRECTORY_SEPARATOR, $dir);
332 332
 		}, $config['dirs']);
333 333
 
@@ -370,8 +370,8 @@  discard block
 block discarded – undo
370 370
 		$whitelistRegexp = KdybyTranslator::buildWhitelistRegexp($config['whitelist']);
371 371
 		$translator = $builder->getDefinition($this->prefix('default'));
372 372
 
373
-		$mask = array_map(function ($value) {
374
-			return '*.*.' . $value;
373
+		$mask = array_map(function($value) {
374
+			return '*.*.'.$value;
375 375
 		}, array_keys($this->loaders));
376 376
 
377 377
 		foreach (Finder::findFiles($mask)->from($dirs) as $file) {
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
 	 */
462 462
 	public static function register(Configurator $configurator)
463 463
 	{
464
-		$configurator->onCompile[] = function ($config, Compiler $compiler) {
464
+		$configurator->onCompile[] = function($config, Compiler $compiler) {
465 465
 			$compiler->addExtension('translation', new TranslationExtension());
466 466
 		};
467 467
 	}
Please login to merge, or discard this patch.
src/Diagnostics/Panel.php 2 patches
Spacing   +26 added lines, -27 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	public function getTab()
84 84
 	{
85 85
 		return '<span title="Translation"><img width="16px" height="16px" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0I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rEko0TpBwct9W+xGgKL41hWoMeJB/LQsa/JlOYkVDrmAHlpwnF0M6of2gdIC7vUvDUNk1HMbwVRbmo+jA3tOlaYByTYbRJdiG1E3UFFg2IvLxqm67qR1yg71kLflDXvwhHhsxtbSycw2xWffXiPP+/NmFTiGyX21t9m99RbWDCZ1Fy5dAlJeXyz6aOfz48Mzli6aPTp8rMXz/585UVeun7z4WW418Kll0/w9Pk1/t5JTHdh2otpElMl1PX8eP06fdus9ObhQ2g4VBrVxpvvdl/Ovmgacev2Dnf+2GXnxi6zGw/KMJrNJUXPS6fXmCaNw+d8GNV8KHXgp87xyg83tVQCALPvLlvCVUK/3tnh9t3mkw8+/u3Tx3kNu/H6C7z6063lnLBU4dd98NHzF9Z47eKpE4/7Hngw+LHHzveX3zmAyBv/xsvpP+li/lm3bxkuAAAAAElFTkSuQmCC" />'
86
-			. $this->translator->getLocale() . ($this->untranslated ? ' <b>(' . count(array_unique($this->untranslated, SORT_REGULAR)) . ' errors)</b>' : '')
86
+			. $this->translator->getLocale().($this->untranslated ? ' <b>('.count(array_unique($this->untranslated, SORT_REGULAR)).' errors)</b>' : '')
87 87
 			. '</span>';
88 88
 	}
89 89
 
@@ -114,17 +114,17 @@  discard block
 block discarded – undo
114 114
 
115 115
 				/** @var \Nette\Application\Request[] $snapshot */
116 116
 				$params = $snapshot['request']->getParameters();
117
-				$s .= '<tr><th width="10px">&nbsp;</th>' .
118
-					'<th>' . $h($snapshot['request']->getPresenterName() . (isset($params['action']) ? ':' . $params['action'] : '')) . '</th>' .
119
-					'<th>' . $h($snapshot['locale']) . '</th></tr>';
117
+				$s .= '<tr><th width="10px">&nbsp;</th>'.
118
+					'<th>'.$h($snapshot['request']->getPresenterName().(isset($params['action']) ? ':'.$params['action'] : '')).'</th>'.
119
+					'<th>'.$h($snapshot['locale']).'</th></tr>';
120 120
 
121 121
 				$l = 1;
122 122
 				/** @var mixed[][] $snapshot */
123 123
 				foreach ($snapshot['resolvers'] as $name => $resolvedLocale) {
124
-					$s .= '<tr><td>' . ($l++) . '.</td><td>' . $h($name) . '</td><td>' . $h($resolvedLocale) . '</td></tr>';
124
+					$s .= '<tr><td>'.($l++).'.</td><td>'.$h($name).'</td><td>'.$h($resolvedLocale).'</td></tr>';
125 125
 				}
126 126
 
127
-				$panel[] = '<table style="width:100%">' . $s . '</table>';
127
+				$panel[] = '<table style="width:100%">'.$s.'</table>';
128 128
 			}
129 129
 		}
130 130
 
@@ -142,14 +142,13 @@  discard block
 block discarded – undo
142 142
 			}
143 143
 
144 144
 			$panel[] = '<h2>Ignored resources</h2>';
145
-			$panel[] = '<p>Whitelist config: ' . implode(', ', array_map($h, $this->localeWhitelist)) . '</p>';
145
+			$panel[] = '<p>Whitelist config: '.implode(', ', array_map($h, $this->localeWhitelist)).'</p>';
146 146
 			$panel[] = $this->renderResources($this->ignoredResources);
147 147
 		}
148 148
 
149
-		return empty($panel) ? '' :
150
-			'<h1>Missing translations: ' . count(array_unique($this->untranslated, SORT_REGULAR)) .
151
-			', Resources: ' . count(Arrays::flatten($this->resources)) . '</h1>' .
152
-			'<div class="nette-inner tracy-inner kdyby-TranslationPanel" style="min-width:500px">' . implode($panel) . '</div>' .
149
+		return empty($panel) ? '' : '<h1>Missing translations: '.count(array_unique($this->untranslated, SORT_REGULAR)).
150
+			', Resources: '.count(Arrays::flatten($this->resources)).'</h1>'.
151
+			'<div class="nette-inner tracy-inner kdyby-TranslationPanel" style="min-width:500px">'.implode($panel).'</div>'.
153 152
 			'<style>
154 153
 				#nette-debug .kdyby-TranslationPanel h2,
155 154
 				#tracy-debug .kdyby-TranslationPanel h2 {font-size: 23px;}
@@ -167,19 +166,19 @@  discard block
 block discarded – undo
167 166
 			$s .= '<tr><td>';
168 167
 
169 168
 			if ($message instanceof \Exception || $message instanceof \Throwable) {
170
-				$s .= '<span style="color:red">' . $h($message->getMessage()) . '</span>';
169
+				$s .= '<span style="color:red">'.$h($message->getMessage()).'</span>';
171 170
 
172 171
 			} elseif ($message instanceof Html) {
173
-				$s .= '<span style="color:red">Nette\Utils\Html(' . $h((string) $message) . ')</span>';
172
+				$s .= '<span style="color:red">Nette\Utils\Html('.$h((string) $message).')</span>';
174 173
 
175 174
 			} else {
176 175
 				$s .= $h($message);
177 176
 			}
178 177
 
179
-			$s .= '</td><td>' . $h($untranslated['domain']) . '</td></tr>';
178
+			$s .= '</td><td>'.$h($untranslated['domain']).'</td></tr>';
180 179
 		}
181 180
 
182
-		return '<table style="width:100%"><tr><th>Untranslated message</th><th>Translation domain</th></tr>' . $s . '</table>';
181
+		return '<table style="width:100%"><tr><th>Untranslated message</th><th>Translation domain</th></tr>'.$s.'</table>';
183 182
 	}
184 183
 
185 184
 	private function renderResources($resourcesMap)
@@ -191,25 +190,25 @@  discard block
 block discarded – undo
191 190
 		foreach ($resourcesMap as $locale => $resources) {
192 191
 			foreach ($resources as $resourcePath => $domain) {
193 192
 				$s .= '<tr>';
194
-				$s .= '<td>' . $h($locale) . '</td>';
195
-				$s .= '<td>' . $h($domain) . '</td>';
193
+				$s .= '<td>'.$h($locale).'</td>';
194
+				$s .= '<td>'.$h($domain).'</td>';
196 195
 
197
-				$relativePath = str_replace(rtrim($this->rootDir, '/') . '/', '', $resourcePath);
196
+				$relativePath = str_replace(rtrim($this->rootDir, '/').'/', '', $resourcePath);
198 197
 				if (Strings::startsWith($relativePath, 'vendor/')) {
199 198
 					$parts = explode('/', $relativePath, 4);
200 199
 					$left = array_pop($parts);
201
-					$relativePath = $h(implode('/', $parts) . '/.../') . '<b>' . $h(basename($left)) . '</b>';
200
+					$relativePath = $h(implode('/', $parts).'/.../').'<b>'.$h(basename($left)).'</b>';
202 201
 
203 202
 				} else {
204
-					$relativePath = $h(dirname($relativePath)) . '/<b>' . $h(basename($relativePath)) . '</b>';
203
+					$relativePath = $h(dirname($relativePath)).'/<b>'.$h(basename($relativePath)).'</b>';
205 204
 				}
206 205
 
207
-				$s .= '<td>' . self::editorLink($resourcePath, 1, $relativePath) . '</td>';
206
+				$s .= '<td>'.self::editorLink($resourcePath, 1, $relativePath).'</td>';
208 207
 				$s .= '</tr>';
209 208
 			}
210 209
 		}
211 210
 
212
-		return '<table style="width:100%"><tr><th>Locale</th><th>Domain</th><th>Resource filename</th></tr>' . $s . '</table>';
211
+		return '<table style="width:100%"><tr><th>Locale</th><th>Domain</th><th>Resource filename</th></tr>'.$s.'</table>';
213 212
 	}
214 213
 
215 214
 	/**
@@ -245,7 +244,7 @@  discard block
 block discarded – undo
245 244
 	public function addResource($format, $resource, $locale, $domain)
246 245
 	{
247 246
 		if (is_array($resource)) {
248
-			$resource = 'array ' . md5(serialize($resource));
247
+			$resource = 'array '.md5(serialize($resource));
249 248
 		}
250 249
 
251 250
 		$this->resources[$locale][$resource] = $domain;
@@ -265,7 +264,7 @@  discard block
 block discarded – undo
265 264
 	public function addIgnoredResource($format, $resource, $locale, $domain)
266 265
 	{
267 266
 		if (is_array($resource)) {
268
-			$resource = 'array ' . md5(serialize($resource));
267
+			$resource = 'array '.md5(serialize($resource));
269 268
 		}
270 269
 
271 270
 		$this->ignoredResources[$locale][$resource] = $domain;
@@ -323,14 +322,14 @@  discard block
 block discarded – undo
323 322
 			return NULL;
324 323
 		}
325 324
 
326
-		$method = YamlFileLoader::class . '::load';
325
+		$method = YamlFileLoader::class.'::load';
327 326
 		$call = Helpers::findTrace($e->getPrevious()->getTrace(), $method);
328 327
 		if ($call !== NULL) {
329 328
 			return [
330 329
 				'tab' => 'YAML dictionary',
331
-				'panel' => '<p><b>File:</b> ' . self::editorLink($call['args'][0], $previous->getParsedLine()) . '</p>'
330
+				'panel' => '<p><b>File:</b> '.self::editorLink($call['args'][0], $previous->getParsedLine()).'</p>'
332 331
 					. ($previous->getParsedLine() ? BlueScreen::highlightFile($call['args'][0], $previous->getParsedLine()) : '')
333
-					. '<p>' . $previous->getMessage() . ' </p>',
332
+					. '<p>'.$previous->getMessage().' </p>',
334 333
 			];
335 334
 		}
336 335
 	}
Please login to merge, or discard this patch.
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 	}
226 226
 
227 227
 	/**
228
-	 * @param \Exception|\Throwable $e
228
+	 * @param \Exception $e
229 229
 	 * @param string|NULL $domain
230 230
 	 */
231 231
 	public function choiceError($e, $domain)
@@ -338,6 +338,7 @@  discard block
 block discarded – undo
338 338
 	/**
339 339
 	 * Returns link to editor.
340 340
 	 *
341
+	 * @param string $text
341 342
 	 * @return \Nette\Utils\Html|string
342 343
 	 */
343 344
 	private static function editorLink($file, $line, $text = NULL)
Please login to merge, or discard this patch.
src/IResourceLoader.php 1 patch
Doc Comments   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,6 +21,7 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @param string $format The format of the loader
23 23
 	 * @param \Symfony\Component\Translation\Loader\LoaderInterface $loader
24
+	 * @return void
24 25
 	 */
25 26
 	public function addLoader($format, LoaderInterface $loader);
26 27
 
@@ -33,8 +34,9 @@  discard block
 block discarded – undo
33 34
 	 * @param string $format
34 35
 	 * @param string $resource
35 36
 	 * @param string $domain
36
-	 * @param \Symfony\Component\Translation\MessageCatalogue $catalogue
37
+	 * @param MessageCatalogue $catalogue
37 38
 	 * @throws \Kdyby\Translation\LoaderNotFoundException
39
+	 * @return void
38 40
 	 */
39 41
 	public function loadResource($format, $resource, $domain, MessageCatalogue $catalogue);
40 42
 
Please login to merge, or discard this patch.