Skip to content

Commit 48b465f

Browse files
committed
minor #14937 Standardize the name of the exception variables (javiereguiluz)
This PR was squashed before being merged into the 2.3 branch (closes #14937). Discussion ---------- Standardize the name of the exception variables | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - See symfony/symfony-docs#4491 for the context of this change. In Symfony source code there are 410 `try ... catch` blocks. More than 95% of them use `$e` as the name of the exception variable. After applying these changes, 407 out of 410 variables are named `$e`. These are the three cases where I didn't change the name of the `$e` variable: * Nested exception in https://github.com/symfony/symfony/blob/2.3/src/Symfony/Component/Routing/Matcher/RedirectableUrlMatcher.php#L40. It uses `$e2` as the name of the nested variable. * Nested exception in https://github.com/symfony/symfony/blob/2.3/src/Symfony/Bundle/TwigBundle/TwigEngine.php#L82. I changed the name of the `$ex` variable to `$e2` to match the previous syntax. * https://github.com/symfony/symfony/blob/2.3/src/Symfony/Component/Console/Helper/DialogHelper.php#L463. I don't know if it's safe to change the name of the `$error` exception variable. Commits ------- e8b924c Standardize the name of the exception variables
2 parents 368fb15 + 1ec522b commit 48b465f

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Helper/DialogHelper.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -452,18 +452,18 @@ private function hasSttyAvailable()
452452
*/
453453
private function validateAttempts($interviewer, OutputInterface $output, $validator, $attempts)
454454
{
455-
$error = null;
455+
$e = null;
456456
while (false === $attempts || $attempts--) {
457-
if (null !== $error) {
458-
$output->writeln($this->getHelperSet()->get('formatter')->formatBlock($error->getMessage(), 'error'));
457+
if (null !== $e) {
458+
$output->writeln($this->getHelperSet()->get('formatter')->formatBlock($e->getMessage(), 'error'));
459459
}
460460

461461
try {
462462
return call_user_func($validator, $interviewer());
463-
} catch (\Exception $error) {
463+
} catch (\Exception $e) {
464464
}
465465
}
466466

467-
throw $error;
467+
throw $e;
468468
}
469469
}

0 commit comments

Comments
 (0)