Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
FROM debian:bullseye

# Install build dependencies
RUN apt-get update && apt-get install -y \
build-essential \
wget \
tar \
pkg-config \
libtool \
automake \
autoconf \
unzip \
bison \
re2c \
libxml2-dev \
libsqlite3-dev \
libonig-dev \
libzip-dev \
g++ \
locales \
libiconv-hook-dev || true \
&& rm -rf /var/lib/apt/lists/*

RUN apt-get install -y pkg-config build-essential autoconf bison re2c libxml2-dev libsqlite3-dev

WORKDIR /tmp
RUN wget https://github.com/unicode-org/icu/releases/download/release-62-2/icu4c-62_2-src.tgz && \
tar -xzf icu4c-62_2-src.tgz && \
cd icu/source && \
./configure --prefix=/usr/local && \
make -j$(nproc) && \
make install && \
ldconfig

WORKDIR /app
COPY . /app
RUN ./buildconf --force
RUN ./configure --enable-debug --enable-intl CFLAGS="-g -O0"
RUN make -j4
2 changes: 2 additions & 0 deletions ext/intl/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ if test "$PHP_INTL" != "no"; then
dateformat/datepatterngenerator_class.cpp \
dateformat/datepatterngenerator_methods.cpp \
msgformat/msgformat_helpers.cpp \
rangeformatter/rangeformatter_class.cpp \
timezone/timezone_class.cpp \
timezone/timezone_methods.cpp \
calendar/calendar_class.cpp \
Expand Down Expand Up @@ -123,6 +124,7 @@ if test "$PHP_INTL" != "no"; then
$ext_builddir/listformatter
$ext_builddir/msgformat
$ext_builddir/normalizer
$ext_builddir/rangeformatter
$ext_builddir/resourcebundle
$ext_builddir/spoofchecker
$ext_builddir/timezone
Expand Down
3 changes: 3 additions & 0 deletions ext/intl/config.w32
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ if (PHP_INTL != "no") {
normalizer_class.cpp \
normalizer_normalize.cpp \
", "intl");
ADD_SOURCES(configure_module_dirname + "/rangeformatter", "\
rangeformatter_class.cpp \
", "intl");
ADD_SOURCES(configure_module_dirname + "/dateformat", "\
dateformat.c \
dateformat_class.c \
Expand Down
4 changes: 4 additions & 0 deletions ext/intl/php_intl.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include "locale/locale_class.h"

#include "listformatter/listformatter_class.h"
#include "rangeformatter/rangeformatter_class.h"

#include "dateformat/dateformat.h"
#include "dateformat/dateformat_class.h"
Expand Down Expand Up @@ -175,6 +176,9 @@ PHP_MINIT_FUNCTION( intl )
/* Register 'ListFormatter' PHP class */
listformatter_register_class( );

/* Register 'NumberRangeFormatter' PHP class */
rangeformatter_register_class( );

/* Register 'Normalizer' PHP class */
normalizer_register_Normalizer_class( );

Expand Down
61 changes: 61 additions & 0 deletions ext/intl/rangeformatter/rangeformatter.stub.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php

/** @generate-class-entries */

/**
* @not-serializable
* @strict-properties
*/
final class IntlNumberRangeFormatter {
#if U_ICU_VERSION_MAJOR_NUM >= 63
/** @cvalue UNUM_RANGE_COLLAPSE_AUTO */
public const int COLLAPSE_AUTO = UNKNOWN;

/** @cvalue UNUM_RANGE_COLLAPSE_NONE */
public const int COLLAPSE_NONE = UNKNOWN;

/** @cvalue UNUM_RANGE_COLLAPSE_UNIT */
public const int COLLAPSE_UNIT = UNKNOWN;

/** @cvalue UNUM_RANGE_COLLAPSE_ALL */
public const int COLLAPSE_ALL = UNKNOWN;

/** @cvalue UNUM_IDENTITY_FALLBACK_SINGLE_VALUE */
public const int IDENTITY_FALLBACK_SINGLE_VALUE = UNKNOWN;

/** @cvalue UNUM_IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE */
public const int IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE = UNKNOWN;

/** @cvalue UNUM_IDENTITY_FALLBACK_APPROXIMATELY */
public const int IDENTITY_FALLBACK_APPROXIMATELY = UNKNOWN;

/** @cvalue UNUM_IDENTITY_FALLBACK_RANGE */
public const int IDENTITY_FALLBACK_RANGE = UNKNOWN;
#else
public const int COLLAPSE_AUTO = 0;

public const int COLLAPSE_NONE = 1;

public const int COLLAPSE_UNIT = 2;

public const int COLLAPSE_ALL = 3;

public const int IDENTITY_FALLBACK_SINGLE_VALUE = 0;

public const int IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE = 1;

public const int IDENTITY_FALLBACK_APPROXIMATELY = 2;

public const int IDENTITY_FALLBACK_RANGE = 3;
#endif

private function __construct() {}

public static function createFromSkeleton(string $skeleton, string $locale, int $collapse, int $identityFallback): IntlNumberRangeFormatter {}
Copy link
Member

@kocsismate kocsismate Jul 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope I won't upset you too much, but I think these changes will need an RFC, because any API changes involve a lot of bikeshedding lately.

For example, we have started to use enums more often (see my https://wiki.php.net/rfc/url_parsing_api RFC), so I think this practice could be continued in your case too.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I see that you have recently added the ListFormatter class in #18519 that also has some enum-like constants. It probably also makes sense to stay consistent with the current convention of intl (class constants), so I don't insist on my above suggestion.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we decide that we should employ nicer features in intl, we should do a thorough review of not only the constants ,but other mechanisms (like error handling) as well. And then we can make one compelling holistic RFC (if we would desire to do so ;) ).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I see that you have recently added the ListFormatter class in #18519 that also has some enum-like constants. It probably also makes sense to stay consistent with the current convention of intl (class constants), so I don't insist on my above suggestion.

Yeah, that was my reasoning. Since that one didn't need an RFC, I thought this one also won't need it.

If we decide that we should employ nicer features in intl, we should do a thorough review of not only the constants ,but other mechanisms (like error handling) as well. And then we can make one compelling holistic RFC (if we would desire to do so ;) ).

Sounds fair. I think for now the API I'm proposing is ok. I do agree introducing the new NumberFormatter will require an RFC.


public function format(float|int $start, float|int $end): string {}

public function getErrorCode(): int {}

public function getErrorMessage(): string {}
}
148 changes: 148 additions & 0 deletions ext/intl/rangeformatter/rangeformatter_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading