-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Specify that caught exceptions should be assigned to a variable named $e
#4491
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
Conversation
… `$e` 320 out of 372 catches use `$e`.
It's just a minor thing, but I think it will help a lot. One example could be where you have a |
👍 |
@@ -141,6 +141,8 @@ Naming Conventions | |||
|
|||
* Don't forget to look at the more verbose :doc:`conventions` document for | |||
more subjective naming considerations. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This item should then end with a semicolon.
In my opinion this makes sense. But let's see what the rest (especially @symfony/deciders) think about this. |
-1
|
But the standard should be
That would be wrong So would:
I think the standard should be |
@wouterj your answer surprises me because you are always in for cleaning inconsistencies :) I think @dantleech has reported a hard to justify inconsistency: Symfony uses |
I agree with @wouterj about dictating conventions for variables, but I also agree with @javiereguiluz. I think that we should make an exception for
|
I can find one, which uses using a very unconclusive search that assumes that nested I would say that this should be a guideline. If you must have nested exceptions you should make an exception to the rule. It seems to happen rarely enough. |
@symfony/deciders what are your opinion on this proposed CS? |
ping @stof @fabpot @jakzal @weaverryan can you please share your opinion on this topic? |
👎 I would not put this into coding standards. It should be up to the author of code to give proper names so the code is readable, and that's not something you can standardise. However, I'd vote 👍 if someone sent a PR to symfony/symfony fixing the inconsistency. Especially that there's only few instances that don't follow this pattern. |
This pull request can be closed because doc managers and Symfony deciders are against it. Moreover, the idea proposed by @dantleech to update the exception variables to |
I agree. Though thanks to @dantleech for starting the discussion and to @javiereguiluz for updating the code. |
…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
…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
…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
…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
…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
…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
320 out of 372 catches in the symfony code base use
$e
.I think it would be good to make this a standard?
i.e.
as opposed to using variations:
$ex
(5 instances)$exception
(2 instances), etc.