PHP 8.0 named arguments
Blog post from Upsun
PHP 8.0 introduces named arguments, a feature that allows developers to specify parameters by name rather than position, enhancing code readability and flexibility. This feature addresses common issues with positional arguments, such as forgetting parameter order or meaning, by allowing parameters to be specified in any order and combined with positional arguments. Named arguments are particularly useful for constructing complex structures, as demonstrated with PHP's array_fill() function and PSR-7 URL objects, where they simplify syntax and improve clarity. While they offer significant advantages, such as making API calls more self-documenting, named arguments also require developers to consider parameter names as part of the API, as changing them could affect users relying on these names. This feature complements other PHP 8.0 enhancements, like constructor property promotion, and follows successful implementations in languages like Python and Ruby.