Skip to content

Standardize the name of the exception variables #14937

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

javiereguiluz
Copy link
Member

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:

@dosten
Copy link
Contributor

dosten commented Jun 10, 2015

👍 I think that it's safe to change the name of the $error exception variable.

@Tobion
Copy link
Contributor

Tobion commented Jun 11, 2015

👍

@stof
Copy link
Member

stof commented Jun 11, 2015

it is safe to change the variable name if you change it everywhere in the method

@javiereguiluz
Copy link
Member Author

OK. I've updated the last variable name, so now 100% of non-nested exception variables are called $e.

@fabpot
Copy link
Member

fabpot commented Jun 15, 2015

Thank you @javiereguiluz.

fabpot added a commit that referenced this pull request Jun 15, 2015
…guiluz)

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
@fabpot fabpot closed this Jun 15, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants