[php-src] PR #18519: Intl: Add a new IntlListFormatter class
| From: | BogdanUngureanu | Date: | Wed, 07 May 2025 22:47:02 +0000 |
| Subject: | [php-src] PR #18519: Intl: Add a new IntlListFormatter class | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-31648@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/18519
Author: BogdanUngureanu
This PR adds support for ICU's ListFormatter implementation by implementing a new
IntlListFormatter class in PHP.
The class supports ANDs, ORs and UNIT format types. However, they are only available if ICU version
is 67 or above. On older versions of ICU, we only allow TYPE_AND and WIDTH_WIDE - we need this
because, from what I've understood, the minimum version ICU supported is 57, which was bumped
from 50 last year.
The class API is pretty simple:
```
$formatter = new IntlListFormatter('EN_US', IntlListFormatter::TYPE_AND,
IntlListFormatter::WIDTH_WIDE);
echo $formatter->format([1,2,3]);
```
will display
> 1, 2, and 3
I have some questions here:
- Do I need to create an RFC for this new addition?
- I haven't used a namespace and used Intl prefix for consistency sake. Should it be behind a
Intl namespace? I haven't seen a class that uses it so I thought I should go with the prefix.