Skip to content

Commit fab2e8a

Browse files
committed
merged branch dantleech/enforce_sprintf_for_exceptions (PR #7620)
This PR was squashed before being merged into the master branch (closes #7620). Discussion ---------- Enforce sprintf for exceptions | Q | A | ------------- | --- | Bug fix? |no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | [yes|no] | Fixed tickets | n/a | License | MIT | Doc PR | symfony/symfony-docs#2483 Changed format of exceptions which concatenate strings as follows ```` throw new \Exception('The '.$something.' needs the '.$foobar.' parameter'); ```` to ```` throw new \Exception(sprintf('The %s needs the %s parameter', $something, $foobar)); ```` This follows discussion on mailing list: https://groups.google.com/forum/?fromgroups#!topic/symfony-devs/tecj3UOAueM Unit test results are pending... Commits ------- e655120 Enforce sprintf for exceptions
2 parents 9e58449 + 2c551d2 commit fab2e8a

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

Command/ConfigDumpReferenceCommand.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
8484
}
8585

8686
if (!$extension) {
87-
throw new \LogicException('No extensions with configuration available for "'.$name.'"');
87+
throw new \LogicException(sprintf('No extensions with configuration available for "%s"', $name));
8888
}
8989

9090
$message = 'Default configuration for "'.$name.'"';
@@ -100,7 +100,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
100100
}
101101

102102
if (!$extension) {
103-
throw new \LogicException('No extension with alias "'.$name.'" is enabled');
103+
throw new \LogicException(sprintf('No extension with alias "%s" is enabled', $name));
104104
}
105105

106106
$message = 'Default configuration for extension with alias: "'.$name.'"';
@@ -109,14 +109,11 @@ protected function execute(InputInterface $input, OutputInterface $output)
109109
$configuration = $extension->getConfiguration(array(), $containerBuilder);
110110

111111
if (!$configuration) {
112-
throw new \LogicException('The extension with alias "'.$extension->getAlias().
113-
'" does not have it\'s getConfiguration() method setup');
112+
throw new \LogicException(sprintf('The extension with alias "%s" does not have it\'s getConfiguration() method setup', $extension->getAlias()));
114113
}
115114

116115
if (!$configuration instanceof ConfigurationInterface) {
117-
throw new \LogicException(
118-
'Configuration class "'.get_class($configuration).
119-
'" should implement ConfigurationInterface in order to be dumpable');
116+
throw new \LogicException(sprintf('Configuration class "%s" should implement ConfigurationInterface in order to be dumpable', get_class($configuration)));
120117
}
121118

122119
$output->writeln($message);

0 commit comments

Comments
 (0)