]> granicus.if.org Git - php/commitdiff
Make NumberFormatter ctor $pattern nullable
authorNikita Popov <nikita.ppv@gmail.com>
Tue, 9 Feb 2021 13:18:18 +0000 (14:18 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Tue, 9 Feb 2021 13:36:41 +0000 (14:36 +0100)
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

ext/intl/formatter/formatter.stub.php
ext/intl/formatter/formatter_arginfo.h
ext/intl/formatter/formatter_main.c
ext/intl/php_intl.stub.php
ext/intl/php_intl_arginfo.h

index 045b0640ce72f0ebb1ee321b735c2320bc630d47..19e6148b8a0233abc1fa92fdd3de3bc409433022 100644 (file)
@@ -4,13 +4,13 @@
 
 class NumberFormatter
 {
-    public function __construct(string $locale, int $style, string $pattern = "") {}
+    public function __construct(string $locale, int $style, ?string $pattern = null) {}
 
     /**
      * @return NumberFormatter|null
      * @alias numfmt_create
      */
-    public static function create(string $locale, int $style, string $pattern = "") {}
+    public static function create(string $locale, int $style, ?string $pattern = null) {}
 
     /**
      * @return string|false
index 79f977fb811f46e7186f813927e33d4225760e40..a62160597737bce1d89934d1c5ab443021d3bff8 100644 (file)
@@ -1,10 +1,10 @@
 /* This is a generated file, edit the .stub.php file instead.
- * Stub hash: 0f285bbaa6f4f37060eb8325956f41bd86e9dea3 */
+ * Stub hash: de7625297bcdb8c7e4944a319c019ed68508ea2c */
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_class_NumberFormatter___construct, 0, 0, 2)
        ZEND_ARG_TYPE_INFO(0, locale, IS_STRING, 0)
        ZEND_ARG_TYPE_INFO(0, style, IS_LONG, 0)
-       ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, pattern, IS_STRING, 0, "\"\"")
+       ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, pattern, IS_STRING, 1, "null")
 ZEND_END_ARG_INFO()
 
 #define arginfo_class_NumberFormatter_create arginfo_class_NumberFormatter___construct
index 8f44f33fa369c6ba2a02a33e91f531f4e3ef3e6e..aacae86ca694aa40bd78625a4b59163fd594801b 100644 (file)
@@ -34,7 +34,7 @@ static int numfmt_ctor(INTERNAL_FUNCTION_PARAMETERS)
        FORMATTER_METHOD_INIT_VARS;
 
        /* Parse parameters. */
-       if( zend_parse_parameters( ZEND_NUM_ARGS(), "sl|s",
+       if( zend_parse_parameters( ZEND_NUM_ARGS(), "sl|s!",
                &locale, &locale_len, &style, &pattern, &pattern_len ) == FAILURE )
        {
                return FAILURE;
index 421c1ae3dc51f58432a414c6fa713b6c6ccd5948..8600920a01aaf57822a9ad350df86aad36635cb2 100644 (file)
@@ -204,7 +204,7 @@ function datefmt_get_error_message(IntlDateFormatter $formatter): string {}
 
 /* formatter */
 
-function numfmt_create(string $locale, int $style, string $pattern = ""): ?NumberFormatter {}
+function numfmt_create(string $locale, int $style, ?string $pattern = null): ?NumberFormatter {}
 
 function numfmt_format(NumberFormatter $formatter, int|float $num, int $type = NumberFormatter::TYPE_DEFAULT): string|false {}
 
index 85cf63e5852749b4461c136ded574813b1fc32b2..351662024eeb576c0aed3a44d2785683b796744d 100644 (file)
@@ -1,5 +1,5 @@
 /* This is a generated file, edit the .stub.php file instead.
- * Stub hash: 7600b5814e257cc334ec72fc0f4c73b6a84b2745 */
+ * Stub hash: fb91064c471d6bced3a6dad8beb56c92c9047e52 */
 
 ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_intlcal_create_instance, 0, 0, IntlCalendar, 1)
        ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, timezone, "null")
@@ -370,7 +370,7 @@ ZEND_END_ARG_INFO()
 ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_numfmt_create, 0, 2, NumberFormatter, 1)
        ZEND_ARG_TYPE_INFO(0, locale, IS_STRING, 0)
        ZEND_ARG_TYPE_INFO(0, style, IS_LONG, 0)
-       ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, pattern, IS_STRING, 0, "\"\"")
+       ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, pattern, IS_STRING, 1, "null")
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_numfmt_format, 0, 2, MAY_BE_STRING|MAY_BE_FALSE)