-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Return fixer should be risky #1638
Comments
Could you provide example of risky change as well? |
Just have a fuction marked as return void, and put |
One could argue the code that said |
We've made a change to the code behaviour, if you see what I mean. |
👍 for change. Also, it needs to be documented well why it is risky ;) |
That website doesn't contain the void return type code that's new in php 7.1. |
Only HHVM 3.11 actually gave an output of anything close to what php 7.1.0 will give when it's released. The old version of php 7.1 still thought void was the name of an object. |
I'm ignoring hhvm... Behavior on php7.1 will be same way, just a bit different Error will be thrown, isn't it? |
Yeh, but in terms of recognising void as a type rather than a class name, it was closer. |
We'll need to wait for the december version of php 7.1 to make it to 3v4l.org |
The problem exists even without change to PHP, as showed on 3v4l. |
not really - there's still a type error before and after on 7.0 |
So let us see what error will be thrown, maybe it will be in same inheritance line. |
Well, actually, this fixer should be removed from the Symfony level if this RFC is accepted in PHP 7, because the rule defined in the Symfony coding standards will become invalid (I already don't like this rule) |
OK, actually, the RFC is already accepted. So we should start a discussion in Symfony instead. |
Doesn't mean another RFC can't be proposed that changes the definition. I preferred the definition that |
I actually prefer this definition: if the return value should not be used, why should the code be allowed to return one ? |
this is not true. The existing failure on 3v4l is the PHP 7.0 one, which is checking a class typehint. The validation of the void return type is done at compile time, not at runtime, so they won't be any exception catched in your 3v4l snippet (the try statement will not even be reached) |
Well, why not? |
It doesn't matter, that's the point. |
note; if the |
change is finally accepted by Symfony symfony/symfony#17201 TODO:
|
that's not risky. The risky fixer would be the one doing the opposite change (
This one should not be removed. We haven't changed our phpdoc CS. |
I created #1916 to suggest another fixer which would be useful in the Symfony ruleset to replace |
So we still want to remove both |
What will be the default return value after 7.1? If it is (on a side note; for constructors I still like to remove any |
(constructors are totally different case, eg you shouldn't typehint constructor output with |
|
huh? <?php
function foo(): void {
return null;
} PHP 7.1.0alpha1:
|
@keradus Are we still talking about |
@keradus but the existing fixer is not risky, because it does not add |
…id (keradus) This PR was merged into the 1.13 branch. Discussion ---------- EmptyReturnFixer - it's now risky fixer due to null vs void ref #1638 https://3v4l.org/7HscE Commits ------- fc82a1b EmptyReturnFixer - it's now risky fixer due to null vs void
The
return null;
toreturn;
fixer we have needs to be marked as risky as it could break code on php 7.1.See https://wiki.php.net/rfc/void_return_type.
Also note that the rfc actually changes the definition of
void
from what we thought it was before. It now strictly means nothing rather than just garbage.The text was updated successfully, but these errors were encountered: