Skip to content

Commit 607cd31

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 3f3d93d + 92bd870 commit 607cd31

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

DataCollector/RequestDataCollector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public function collect(Request $request, Response $response, \Exception $except
125125
'file' => $r->getFileName(),
126126
'line' => $r->getStartLine(),
127127
);
128-
} catch (\ReflectionException $re) {
128+
} catch (\ReflectionException $e) {
129129
if (is_callable($controller)) {
130130
// using __call or __callStatic
131131
$this->data['controller'] = array(

Tests/DependencyInjection/ContainerAwareHttpKernelTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,10 @@ public function testHandleRestoresThePreviousRequestOnException($type)
137137
try {
138138
$kernel->handle($request, $type);
139139
$this->fail('->handle() suppresses the controller exception');
140-
} catch (\PHPUnit_Framework_Exception $exception) {
141-
throw $exception;
142-
} catch (\Exception $actual) {
143-
$this->assertSame($expected, $actual, '->handle() throws the controller exception');
140+
} catch (\PHPUnit_Framework_Exception $e) {
141+
throw $e;
142+
} catch (\Exception $e) {
143+
$this->assertSame($expected, $e, '->handle() throws the controller exception');
144144
}
145145
}
146146

0 commit comments

Comments
 (0)