Hi internals,

This is a proposal to allow to append the `default` pattern by comma to
the end of the last match branch. (Like a conditional_expression)

This allows to re-use the return_expression if required and avoids code
duplication.

PROPOSAL: PHP 8.2

<?php
return match ($locale) {
    'de_DE', 'de_CH', 'de_AT' => loadGermanLanguageSettings(),
    'en_US', 'en_GB', default => loadDefaultLanguageSettings(),
};
?>

// PHP 8.1 (Current implementation works like before)

<?php
return match ($locale) {
    'de_DE', 'de_CH', 'de_AT' => loadGermanLanguageSettings(),
    'en_US', 'en_GB' => loadDefaultLanguageSettings(),
    default => loadDefaultLanguageSettings(),
};
?>

The `default` pattern must be the last item in the last expression branch.

Thanks,
Andreas

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to