-
Notifications
You must be signed in to change notification settings - Fork 178
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
Fix(deprecation) Optional parameter declared before required parameter is implicitly treated as a required parameter #365
base: master
Are you sure you want to change the base?
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 |
…r is implicitly treated as a required parameter
02332db
to
73ce58f
Compare
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.