-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
unified return null usages #10717
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
unified return null usages #10717
Conversation
@@ -785,7 +785,7 @@ protected function getNode($position) | |||
// @codeCoverageIgnoreStart | |||
} | |||
|
|||
return null; | |||
return; |
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 one could be removed
Hm I prefer explicit |
Well, people need to learn PHP then. |
👍 being consistent and across projects, great! |
👍 |
👍 for this (although I could agree with @Tobion), I prefer consistency over any specific style. |
i too prefer |
And what if an interface explicitly states to return either a value or null? |
I prefer being explicit over implicit, too, but 👍 for the consistency regardless. |
@sstok What do you mean? This PR is just about removing code that does not do anything. |
Well it wasn't clear if that was the case, as it stated |
@sstok if you must return null just don't use return in the function and PHP will return null when the function ends. |
@fabpot Given that fabbot already validates this, I suggest merging the PR to avoid having such changes done by all other PRs out there |
This PR was merged into the 2.3 branch. Discussion ---------- unified return null usages | Q | A | ------------- | --- | License | MIT This PR unifies the way we return `null` from a function or method: * always use `return;` instead of `return null;` (the current code base uses both); * never use `return;` at the end of a function/method. Commits ------- d1d569b unified return null usages
Ah, I missed this one. I disagree with this PR too. I thought that the rules were fairly simple:
IMO, this conveys the purpose of the code much better than what is done in this PR. Of course, PHP supports what is done here, but then PHP supports a lot of confusing things (using undeclared properties etc.). -1, FWIW. |
…lver (Tobion) This PR was merged into the 4.4 branch. Discussion ---------- use proper return types in ErrorHandler and ArgumentResolver | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | tiny | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | | License | MIT | Doc PR | Found those things while reviewing #31996 which missed some return types due to using `return` instead of `return null`. It's part of fixing #17201 (due to #10717). See also #30869 that somebody was stumbling over. Commits ------- 2f9121b use proper return types in ErrorHandler and ArgumentResolver
This PR was merged into the 2.3 branch. Discussion ---------- unified return null usages | Q | A | ------------- | --- | License | MIT This PR unifies the way we return `null` from a function or method: * always use `return;` instead of `return null;` (the current code base uses both); * never use `return;` at the end of a function/method. Commits ------- d1d569b unified return null usages
This PR unifies the way we return
null
from a function or method:return;
instead ofreturn null;
(the current code base uses both);return;
at the end of a function/method.