-
Notifications
You must be signed in to change notification settings - Fork 181
Fix(deprecation) Optional parameter declared before required parameter is implicitly treated as a required parameter #365
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
I didn't go into the details, but one question came up: can Actually, I would like to point out that you have to do the same after PR as before, if only the |
As far as I understood, they are non nullable. That's the reason, why I'd prefer to not introduce the pseudo nullable arguments. On the other hand, it's the least BC-risking fix to the current situation. |
symfony1/lib/widget/sfWidgetForm.class.php Lines 164 to 172 in 0c9ba11
Here it is decided that neither the name nor the value will be printed. They can both be null. It is possible that other widgets exclude null values, but it is sure that phpdoc is almost always wrong. |
I would like to do a breaking change. |
I'd prefer not changing too much. The changes in this pr are no BC at all, but IMO at least |
I have the feeling that we are pushing the problem in front of us.
In that case, we should add tests for all cases (null, non-null, int, string, array) directly to the class. Once we have those and have clarified the operation:
|
Although I do understand your points and wishes for clean code, I don't have the time to take care of it now. But I'm happy if anyone else could take it up from here or if we just merge this to master to get rid of "declaring mandatory arguments after optional arguments is deprecated" and take care of the proper type later, as this probably isn't the last occurrence of type issues. I think both proposals are minimal changes and, at least the change of this pr, does not bring any new allowed values, as |
02332db
to
73ce58f
Compare
@thePanz wdyt? While upgrading our codebase to 8.4, we keep running into this warning. |
73ce58f
to
8536ada
Compare
Thanks @thirsch and @connorhu for mentioning here, this is a tough one. I would thus suggest to put its default value as an empty string (as it is already initialized in the class itself). Regarding the WDYT about this signature for the sfFormField::__construct() method? The same would be applied to sfFormFieldSchema too.
|
8536ada
to
34ae6bb
Compare
LGTM, I've updated the branch. |
…r is implicitly treated as a required parameter
34ae6bb
to
8e83b1e
Compare
Thanks for your approve @thePanz. Do you know, why merging is blocked? If I switch back to "the classic merge experience", everything looks fine. |
I used the "Rebase and merge", worked now 👍 |
This pr aims to fix the deprecation warnings raised by having required parameters after optional parameters. The given change would have the least possible impact instead of introducing a BC by changing the signature to e. g. require the parameter $parent or change the order.
wdyt? As named parameters have been introduced in PHP 8.0, there might be no call without the parameter being explicitly set to
null
and we could consider it safe to change the signature topublic function __construct(sfWidgetForm $widget, ?sfFormField $parent, $name, $value, ?sfValidatorError $error = null)
?I'd prefer the changed signature, as it is much cleaner to not introduce a pseudo-optional name and value argument.