-
-
Notifications
You must be signed in to change notification settings - Fork 432
[CodeQuality] Change behaviour of OptionalParametersAfterRequiredRector to fill null default value when previous param is optional #7222
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
…or to fill null default value when previous param is optional
|
I will verify the usage when on types as well. |
|
I add for param typed dd8cca8 |
|
I add requirement for |
|
All checks have passed 🎉 @TomasVotruba it is ready for review. |
|
Looks good 👍 |
|
This seems can be improved for more reasonable default value. I am thinking of add MixedType: Ok to add null default value
Nullable/Union with nullable: Ok to add null default value?AnyTipe --> null Scalar:
Array
Union + Scalar: use first type basic value
Object type + union: nullable
This will require some proper maps, I will look into it. |
|
After some thinking, just remove previous params default is better, since even on named argument usage, the value is always null if not defined, see I will look into it..., to see if there is drawback, eg; on override method, etc |
|
On PHP 8.0, it seems not fatal error when optional is not filled before required, see https://3v4l.org/0jdGl#v8.0.0 got: On PHP 8.1, it seems cause fatal error when optioanl is not filed before required, see https://3v4l.org/0jdGl#v8.1.12 got: so add |
|
I created new PR to fill reasonable default value, so default value on previous params keep working |
|
This pull request has been automatically locked because it has been closed for 150 days. Please open a new PR if you want to continue the work. |
@afaibyshev @calebdw @TomasVotruba this is possible solution for
Fixes rectorphp/rector#9317
instead of swap param/argument, fill it with default value null instead.