Skip to content

Commit f5768ea

Browse files
committed
Make NumberFormatter ctor $pattern nullable
Whether the pattern is needed depends on the used style. If no pattern is needed, null is a more sensible value than an empty string. fixup
1 parent 186f9ba commit f5768ea

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

ext/intl/formatter/formatter.stub.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44

55
class NumberFormatter
66
{
7-
public function __construct(string $locale, int $style, string $pattern = "") {}
7+
public function __construct(string $locale, int $style, ?string $pattern = null) {}
88

99
/**
1010
* @return NumberFormatter|null
1111
* @alias numfmt_create
1212
*/
13-
public static function create(string $locale, int $style, string $pattern = "") {}
13+
public static function create(string $locale, int $style, ?string $pattern = null) {}
1414

1515
/**
1616
* @return string|false

ext/intl/formatter/formatter_arginfo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: 0f285bbaa6f4f37060eb8325956f41bd86e9dea3 */
2+
* Stub hash: de7625297bcdb8c7e4944a319c019ed68508ea2c */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_NumberFormatter___construct, 0, 0, 2)
55
ZEND_ARG_TYPE_INFO(0, locale, IS_STRING, 0)
66
ZEND_ARG_TYPE_INFO(0, style, IS_LONG, 0)
7-
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, pattern, IS_STRING, 0, "\"\"")
7+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, pattern, IS_STRING, 1, "null")
88
ZEND_END_ARG_INFO()
99

1010
#define arginfo_class_NumberFormatter_create arginfo_class_NumberFormatter___construct

ext/intl/formatter/formatter_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ static int numfmt_ctor(INTERNAL_FUNCTION_PARAMETERS)
3434
FORMATTER_METHOD_INIT_VARS;
3535

3636
/* Parse parameters. */
37-
if( zend_parse_parameters( ZEND_NUM_ARGS(), "sl|s",
37+
if( zend_parse_parameters( ZEND_NUM_ARGS(), "sl|s!",
3838
&locale, &locale_len, &style, &pattern, &pattern_len ) == FAILURE )
3939
{
4040
return FAILURE;

ext/intl/php_intl.stub.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ function datefmt_get_error_message(IntlDateFormatter $formatter): string {}
204204

205205
/* formatter */
206206

207-
function numfmt_create(string $locale, int $style, string $pattern = ""): ?NumberFormatter {}
207+
function numfmt_create(string $locale, int $style, ?string $pattern = null): ?NumberFormatter {}
208208

209209
function numfmt_format(NumberFormatter $formatter, int|float $num, int $type = NumberFormatter::TYPE_DEFAULT): string|false {}
210210

ext/intl/php_intl_arginfo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: 7600b5814e257cc334ec72fc0f4c73b6a84b2745 */
2+
* Stub hash: fb91064c471d6bced3a6dad8beb56c92c9047e52 */
33

44
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_intlcal_create_instance, 0, 0, IntlCalendar, 1)
55
ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, timezone, "null")
@@ -370,7 +370,7 @@ ZEND_END_ARG_INFO()
370370
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_numfmt_create, 0, 2, NumberFormatter, 1)
371371
ZEND_ARG_TYPE_INFO(0, locale, IS_STRING, 0)
372372
ZEND_ARG_TYPE_INFO(0, style, IS_LONG, 0)
373-
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, pattern, IS_STRING, 0, "\"\"")
373+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, pattern, IS_STRING, 1, "null")
374374
ZEND_END_ARG_INFO()
375375

376376
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_numfmt_format, 0, 2, MAY_BE_STRING|MAY_BE_FALSE)

0 commit comments

Comments
 (0)