[CodeQuality] Change behaviour of OptionalParametersAfterRequiredRector to fill null default value when previous param is optional#7222
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 |
@afaibyshev @calebdw @TomasVotruba this is possible solution for
Fixes rectorphp/rector#9317
instead of swap param/argument, fill it with default value null instead.