Named Arguments
Named Arguments are this beautiful beautiful thing that you can use instead of the standard “positional arguments”
Positional arguments are the way we all know it. For example
$someTableClass->find('list', ['limit' => 200, 'keyField' => 'id', 'valueField' => 'name']);
This looks normal until you see Named Arguments:
$someTableClass->find(keyField: 'id', valueField: 'name', options: ['limit' => 200], type: 'list');
The order does NOT matter, and you can automatically put parameters into the function by name so the function can recognise what it is.
This is very useful for functions like the one shown where theres nested parameters that you can assign through named arguments. Its also useful if you just want to utilize a parameter for which you'd have to enter some meaningless values to reach the necessary position, since you can just enter the needed parameter as a named one.
You can also mix positional arguments with named ones, you can't however put named ones before positional ones since that would mess up the position.
$someTableClass->find('list', keyField: 'id', valueField: 'name', options: ['limit' => 200]);
This works because the “type” parameter is the first parameter in that function and the rest comes after.
