You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
minor symfony#28403 Consistently throw exceptions on a single line (nicolas-grekas)
This PR was merged into the 2.8 branch.
Discussion
----------
Consistently throw exceptions on a single line
| Q | A
| ------------- | ---
| Branch? | 2.8
| Bug fix? | no
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | -
| License | MIT
| Doc PR | -
Just to be consistent. Prepared using php-cs-fixer + manual tweaks.
Commits
-------
721dc86 Consistently throw exceptions on a single line
Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Routing/Router.php
+1-8Lines changed: 1 addition & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -152,14 +152,7 @@ private function resolve($value)
152
152
return (string) $resolved;
153
153
}
154
154
155
-
thrownewRuntimeException(sprintf(
156
-
'The container parameter "%s", used in the route configuration value "%s", '.
157
-
'must be a string or numeric, but it is of type %s.',
158
-
$match[1],
159
-
$value,
160
-
\gettype($resolved)
161
-
)
162
-
);
155
+
thrownewRuntimeException(sprintf('The container parameter "%s", used in the route configuration value "%s", must be a string or numeric, but it is of type %s.', $match[1], $value, \gettype($resolved)));
Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/GuardAuthenticationFactory.php
+2-8Lines changed: 2 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -94,10 +94,7 @@ private function determineEntryPoint($defaultEntryPointId, array $config)
94
94
if ($defaultEntryPointId) {
95
95
// explode if they've configured the entry_point, but there is already one
96
96
if ($config['entry_point']) {
97
-
thrownew \LogicException(sprintf(
98
-
'The guard authentication provider cannot use the "%s" entry_point because another entry point is already configured by another provider! Either remove the other provider or move the entry_point configuration as a root key under your firewall (i.e. at the same level as "guard").',
99
-
$config['entry_point']
100
-
));
97
+
thrownew \LogicException(sprintf('The guard authentication provider cannot use the "%s" entry_point because another entry point is already configured by another provider! Either remove the other provider or move the entry_point configuration as a root key under your firewall (i.e. at the same level as "guard").', $config['entry_point']));
101
98
}
102
99
103
100
return$defaultEntryPointId;
@@ -115,9 +112,6 @@ private function determineEntryPoint($defaultEntryPointId, array $config)
115
112
}
116
113
117
114
// we have multiple entry points - we must ask them to configure one
118
-
thrownew \LogicException(sprintf(
119
-
'Because you have multiple guard configurators, you need to set the "guard.entry_point" key to one of your configurators (%s)',
120
-
implode(', ', $authenticatorIds)
121
-
));
115
+
thrownew \LogicException(sprintf('Because you have multiple guard configurators, you need to set the "guard.entry_point" key to one of your configurators (%s)', implode(', ', $authenticatorIds)));
@@ -363,13 +356,7 @@ protected function mergeValues($leftSide, $rightSide)
363
356
// no conflict
364
357
if (!array_key_exists($k, $leftSide)) {
365
358
if (!$this->allowNewKeys) {
366
-
$ex = newInvalidConfigurationException(sprintf(
367
-
'You are not allowed to define new elements for path "%s". '
368
-
.'Please define all elements for this path in one config file. '
369
-
.'If you are trying to overwrite an element, make sure you redefine it '
370
-
.'with the same name.',
371
-
$this->getPath()
372
-
));
359
+
$ex = newInvalidConfigurationException(sprintf('You are not allowed to define new elements for path "%s". Please define all elements for this path in one config file. If you are trying to overwrite an element, make sure you redefine it with the same name.', $this->getPath()));
Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/Definition/BaseNode.php
+1-6Lines changed: 1 addition & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -205,12 +205,7 @@ public function getPath()
205
205
finalpublicfunctionmerge($leftSide, $rightSide)
206
206
{
207
207
if (!$this->allowOverwrite) {
208
-
thrownewForbiddenOverwriteException(sprintf(
209
-
'Configuration path "%s" cannot be overwritten. You have to '
210
-
.'define all options for this path, and any of its sub-paths in '
211
-
.'one configuration section.',
212
-
$this->getPath()
213
-
));
208
+
thrownewForbiddenOverwriteException(sprintf('Configuration path "%s" cannot be overwritten. You have to define all options for this path, and any of its sub-paths in one configuration section.', $this->getPath()));
sprintf('->addDefaultChildrenIfNoneSet() should set default children names as ->useAttributeAsKey() is used at path "%s"', $path)
463
-
);
449
+
thrownewInvalidDefinitionException(sprintf('->addDefaultChildrenIfNoneSet() should set default children names as ->useAttributeAsKey() is used at path "%s"', $path));
464
450
}
465
451
466
452
if (null === $this->key && (\is_string($this->addDefaultChildren) || \is_array($this->addDefaultChildren))) {
467
-
thrownewInvalidDefinitionException(
468
-
sprintf('->addDefaultChildrenIfNoneSet() might not set default children names as ->useAttributeAsKey() is not used at path "%s"', $path)
469
-
);
453
+
thrownewInvalidDefinitionException(sprintf('->addDefaultChildrenIfNoneSet() might not set default children names as ->useAttributeAsKey() is not used at path "%s"', $path));
$ex = newInvalidConfigurationException(sprintf('The value %s is not allowed for path "%s". Permissible values: %s', json_encode($value), $this->getPath(), implode(', ', array_map('json_encode', $this->values))));
thrownewUnsetKeyException(sprintf('Unsetting key for path "%s", value: %s', $this->getPath(), json_encode($value)));
190
189
}
191
190
192
191
foreach ($valueas$k => $v) {
@@ -199,8 +198,7 @@ protected function finalizeValue($value)
199
198
}
200
199
201
200
if (\count($value) < $this->minNumberOfElements) {
202
-
$msg = sprintf('The path "%s" should have at least %d element(s) defined.', $this->getPath(), $this->minNumberOfElements);
203
-
$ex = newInvalidConfigurationException($msg);
201
+
$ex = newInvalidConfigurationException(sprintf('The path "%s" should have at least %d element(s) defined.', $this->getPath(), $this->minNumberOfElements));
204
202
$ex->setPath($this->getPath());
205
203
206
204
throw$ex;
@@ -232,8 +230,7 @@ protected function normalizeValue($value)
232
230
foreach ($valueas$k => $v) {
233
231
if (null !== $this->keyAttribute && \is_array($v)) {
234
232
if (!isset($v[$this->keyAttribute]) && \is_int($k) && !$isAssoc) {
235
-
$msg = sprintf('The attribute "%s" must be set for path "%s".', $this->keyAttribute, $this->getPath());
236
-
$ex = newInvalidConfigurationException($msg);
233
+
$ex = newInvalidConfigurationException(sprintf('The attribute "%s" must be set for path "%s".', $this->keyAttribute, $this->getPath()));
237
234
$ex->setPath($this->getPath());
238
235
239
236
throw$ex;
@@ -262,8 +259,7 @@ protected function normalizeValue($value)
262
259
}
263
260
264
261
if (array_key_exists($k, $normalized)) {
265
-
$msg = sprintf('Duplicate key "%s" for path "%s".', $k, $this->getPath());
266
-
$ex = newDuplicateKeyException($msg);
262
+
$ex = newDuplicateKeyException(sprintf('Duplicate key "%s" for path "%s".', $k, $this->getPath()));
267
263
$ex->setPath($this->getPath());
268
264
269
265
throw$ex;
@@ -314,11 +310,7 @@ protected function mergeValues($leftSide, $rightSide)
314
310
// no conflict
315
311
if (!array_key_exists($k, $leftSide)) {
316
312
if (!$this->allowNewKeys) {
317
-
$ex = newInvalidConfigurationException(sprintf(
318
-
'You are not allowed to define new elements for path "%s". '.
319
-
'Please define all elements for this path in one config file.',
320
-
$this->getPath()
321
-
));
313
+
$ex = newInvalidConfigurationException(sprintf('You are not allowed to define new elements for path "%s". Please define all elements for this path in one config file.', $this->getPath()));
0 commit comments