-
Notifications
You must be signed in to change notification settings - Fork 11.2k
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
[8.x] Fixes for PHP 8.1 in Illuminate\Support #37087
Conversation
@jrmajor yes those changes for 9.x seem okay to me. @taylorotwell for you as well? |
I don't like those. I always prefer defaults as |
Since PHP 8.0 has been released, named arguments can be used for skipping parameters, so as more and more people upgrade, this stops being an important problem. Correct defaults help you understand what the method does. For example, if you're not sure whether |
Laravel does not support or recommend named parameters, in the sense that they are not included in the BC promise, and could be broken in patch relases. |
@GrahamCampbell Even taking this into account, it's still easier to see what's the default value (you'd need to do this anyway to see if it's a By the way, it's a shame that Laravel does not support named arguments. Do you plan to support it in future releases? With little or no type hints, and now no support for named parameters, it seems like Laravel is falling behind a bit. |
This has nothing to do with being left behind. @jrmajor Laravel is a framework that aims to provide the best performance and perfect flexibility with the least code possible, so they add by calculating even a single letter they add. The things they add are also very careful. |
@selcukcukur How does not supporting named arguments provide more flexibility? It's preventing users from using new language features, that's why I've written about “falling behind”. Hope that they will be supported in the future releases though. Also, the ability to pass objects to functions that expect a string is a little bit more of flexibility than I would usually need. |
@jrmajor we decided against it because it would mean we sometimes would need to wait a year for a new major release to rename parameters. We don't want to be bound by that. |
Fixes passing
null
to non-nullable parameters.Would you accept a PR to 9.x changing the following default parameters?
Note that
Str::substrCount()
already has default$offset = 0
.