mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
d56303aa54
Now that PHP has support for named parameters, and we can use them in Moodle, we should ditch `$options` arrays and use first-class, documented, parameters. Whilst this may seem scary, dumb, overwhelming, please note that you do not need to supply all args, for example, to change the last parameter of `format_text` you no longer need to do this: return \core\container::get(\core\formatting::class)->format_text( $text, FORMAT_MOODLE, $context, false, null, true, true, true, false, false, true, ); Instead you can do: return \core\container::get(\core\formatting::class)->format_text( $text, FORMAT_MOODLE, $context, allowid: true, ); Or better still: return \core\container::get(\core\formatting::class)->format_text( text: $text, format: FORMAT_MOODLE, context: $context, allowid: true, ); This means that we can get defaults in the function signature, improves our typing, and allows for deprecation and changes to options. It also sets us up for success in the future.