cakephp
cakephp copied to clipboard
6.0 - RFC - Remove argument overloading
Description
We have various methods where argument overloading is used for ease of use. For e.g. for RouteBuilder::scope() if the 2nd argument is a callback it's used as the 3rd argument.
The availability of named arguments and autocompleting features of today's IDEs negate the need of such loading. Removing the overloading would make the API cleaner.
Functions list
- [ ]
RouteBuilder::scope(string $path, Closure|array $params, ?Closure $callback = null) - [ ]
RouteBuilder::resources(string $name, Closure|array $options = [], ?Closure $callback = null) - [ ]
RouteBuilder::prefix(string $name, Closure|array $params = [], ?Closure $callback = null) - [ ]
RouteBuilder::plugin(string $name, Closure|array $params = [], ?Closure $callback = null) - [x]
Entity::set(array|string $field, mixed $value = null, array $options = [])
CakePHP Version
6.0
So be clear, you just want to add extra arguments with defaults?
For most cases no extra args are needed. For e.g. only need to remove the possibility of passing value of 3rd argument at 2nd position. It was a convenience no longer required with the advent of named args.
It would be ideal to have rector rules to help with updating application and plugin logic for these changes.
It would be ideal to have rector rules to help with updating application and plugin logic for these changes.
Summoning our rector champion @LordSimal 😄
I'm not fond of all the overloaded signatures in CakePHP, but going overboard with named arguments won't improve the API for me since I write application code in Haxe, which does not have a clean way to output code with such function calls.