8000 Merge branch '2.7' into 2.8 · lrlopez/symfony@4b68eb1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4b68eb1

Browse files
Merge branch '2.7' into 2.8
* 2.7: [Validator] Added Swedish translations improve exceptions when parsing malformed files Dispatch console.terminate *after* console.exception
2 parents d1c51a3 + 249d130 commit 4b68eb1

File tree

7 files changed

+39
-12
lines changed

7 files changed

+39
-12
lines changed

src/Symfony/Component/Console/Application.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -885,13 +885,15 @@ protected function doRunCommand(Command $command, InputInterface $input, OutputI
885885
try {
886886
$exitCode = $command->run($input, $output);
887887
} catch (\Exception $e) {
888+
$event = new ConsoleExceptionEvent($command, $input, $output, $e, $e->getCode());
889+
$this->dispatcher->dispatch(ConsoleEvents::EXCEPTION, $event);
890+
891+
$e = $event->getException();
892+
888893
$event = new ConsoleTerminateEvent($command, $input, $output, $e->getCode());
889894
$this->dispatcher->dispatch(ConsoleEvents::TERMINATE, $event);
890895

891-
$event = new ConsoleExceptionEvent($command, $input, $output, $e, $event->getExitCode());
892-
$this->dispatcher->dispatch(ConsoleEvents::EXCEPTION, $event);
893-
894-
throw $event->getException();
896+
throw $e;
895897
}
896898
} else {
897899
$exitCode = ConsoleCommandEvent::RETURN_CODE_DISABLED;

src/Symfony/Component/Console/Tests/ApplicationTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,7 @@ public function testRunWithDispatcher()
884884

885885
$tester = new ApplicationTester($application);
886886
$tester->run(array('command' => 'foo'));
887-
$this->assertEquals('before.foo.after.', $tester->getDisplay());
887+
$this->assertEquals('before.foo.after.'.PHP_EOL, $tester->getDisplay());
888888
}
889889

890890
/**
@@ -920,7 +920,7 @@ public function testRunDispatchesAllEventsWithException()
920920

921921
$tester = new ApplicationTester($application);
922922
$tester->run(array('command' => 'foo'));
923-
$this->assertContains('before.foo.after.caught.', $tester->getDisplay());
923+
$this->assertContains('before.foo.caught.after.', $tester->getDisplay());
924924
}
925925

926926
public function testRunWithDispatcherSkippingCommand()
@@ -965,14 +965,14 @@ protected function getDispatcher($skipCommand = false)
965965
}
966966
});
967967
$dispatcher->addListener('console.terminate', function (ConsoleTerminateEvent $event) use ($skipCommand) {
968-
$event->getOutput()->write('after.');
968+
$event->getOutput()->writeln('after.');
969969

970970
if (!$skipCommand) {
971971
$event->setExitCode(113);
972972
}
973973
8000 });
974974
$dispatcher->addListener('console.exception', function (ConsoleExceptionEvent $event) {
975-
$event->getOutput()->writeln('caught.');
975+
$event->getOutput()->write('caught.');
976976

977977
$event->setException(new \LogicException('caught.', $event->getExitCode(), $event->getException()));
978978
});

src/Symfony/Component/Debug/Debug.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public static function enable($errorReportingLevel = null, $displayErrors = true
5353
ini_set('display_errors', 1);
5454
}
5555
if ($displayErrors) {
56-
ErrorHandler::register(new ErrorHandler(new BufferingLogger()))->screamAt(E_DEPRECATED | E_USER_DEPRECATED);
56+
ErrorHandler::register(new ErrorHandler(new BufferingLogger()));
5757
} else {
5858
ErrorHandler::register()->throwAt(0, true);
5959
}

src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
2020
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
2121
use Symfony\Component\Config\Resource\FileResource;
22+
use Symfony\Component\Yaml\Exception\ParseException;
2223
use Symfony\Component\Yaml\Parser as YamlParser;
2324
use Symfony\Component\ExpressionLanguage\Expression;
2425

@@ -324,7 +325,13 @@ protected function loadFile($file)
324325
$this->yamlParser = new YamlParser();
325326
}
326327

327-
return $this->validate($this->yamlParser->parse(file_get_contents($file)), $file);
328+
try {
329+
$configuration = $this->yamlParser->parse(file_get_contents($file));
330+
} catch (ParseException $e) {
331+
throw new \InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML.', $file), 0, $e);
332+
}
333+
334+
return $this->validate($configuration, $file);
328335
}
329336

330337
/**

src/Symfony/Component/Routing/Loader/YamlFileLoader.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\Component\Routing\RouteCollection;
1515
use Symfony\Component\Routing\Route;
1616
use Symfony\Component\Config\Resource\FileResource;
17+
use Symfony\Component\Yaml\Exception\ParseException;
1718
use Symfony\Component\Yaml\Parser as YamlParser;
1819
use Symfony\Component\Config\Loader\FileLoader;
1920

@@ -60,7 +61,11 @@ public function load($file, $type = null)
6061
$this->yamlParser = new YamlParser();
6162
}
6263

63-
$config = $this->yamlParser->parse(file_get_contents($path));
64+
try {
65+
$config = $this->yamlParser->parse(file_get_contents($path));
66+
} catch (ParseException $e) {
67+
throw new \InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML.', $path), 0, $e);
68+
}
6469

6570
$collection = new RouteCollection();
6671
$collection->addResource(new FileResource($path));

src/Symfony/Component/Validator/Mapping/Loader/YamlFileLoader.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Validator\Mapping\Loader;
1313

1414
use Symfony\Component\Validator\Mapping\ClassMetadata;
15+
use Symfony\Component\Yaml\Exception\ParseException;
1516
use Symfony\Component\Yaml\Parser as YamlParser;
1617

1718
/**
@@ -117,7 +118,11 @@ protected function parseNodes(array $nodes)
117118
*/
118119
private function parseFile($path)
119120
{
120-
$classes = $this->yamlParser->parse(file_get_contents($path));
121+
try {
122+
$classes = $this->yamlParser->parse(file_get_contents($path));
123+
} catch (ParseException $e) {
124+
throw new \InvalidArgumentException(sprintf('The file "%s" does not contain valid.', $path), 0, $e);
125+
}
121126

122127
// empty file
123128
if (null === $classes) {

src/Symfony/Component/Validator/Resources/translations/validators.sv.xlf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,14 @@
302302
<source>An empty file is not allowed.</source>
303303
<target>En tom fil är inte tillåten.</target>
304304
</trans-unit>
305+
<trans-unit id="79">
306+
<source>The host could not be resolved.</source>
307+
<target>Värddatorn kunde inte hittas.</target>
308+
</trans-unit>
309+
<trans-unit id="80">
310+
<source>This value does not match the expected {{ charset }} charset.</source>
311+
<target>Detta värde har inte den förväntade teckenkodningen {{ charset }}.</target>
312+
</trans-unit>
305313
</body>
306314
</file>
307315
</xliff>

0 commit comments

Comments
 (0)
0