diff options
author | Christoph M. Becker <cmbecker69@gmx.de> | 2021-02-17 17:31:47 +0100 |
---|---|---|
committer | Christoph M. Becker <cmbecker69@gmx.de> | 2021-02-17 17:31:47 +0100 |
commit | b074e3b52b4dbc961b1b7e8ff80f6c6237666bbf (patch) | |
tree | 2d44f083dabe25f124b97322f4ecc3315460b1ec | |
parent | de5b42219c65f2d939caaa5ec8e39ead813ced15 (diff) | |
parent | 553a0c52b12d414c83130d845968fac5841236bf (diff) | |
download | php-git-b074e3b52b4dbc961b1b7e8ff80f6c6237666bbf.tar.gz |
Merge branch 'PHP-8.0'
* PHP-8.0:
Fix #80763: msgfmt_format() does not accept DateTime references
-rw-r--r-- | ext/intl/common/common_date.cpp | 4 | ||||
-rw-r--r-- | ext/intl/tests/bug80763.phpt | 16 |
2 files changed, 20 insertions, 0 deletions
diff --git a/ext/intl/common/common_date.cpp b/ext/intl/common/common_date.cpp index d4767dc63b..5c1134aae7 100644 --- a/ext/intl/common/common_date.cpp +++ b/ext/intl/common/common_date.cpp @@ -173,6 +173,7 @@ U_CFUNC double intl_zval_to_millis(zval *z, intl_error *err, const char *func) return ZEND_NAN; } +try_again: switch (Z_TYPE_P(z)) { case IS_STRING: type = is_numeric_string(Z_STRVAL_P(z), Z_STRLEN_P(z), &lv, &rv, 0); @@ -225,6 +226,9 @@ U_CFUNC double intl_zval_to_millis(zval *z, intl_error *err, const char *func) efree(message); } break; + case IS_REFERENCE: + z = Z_REFVAL_P(z); + goto try_again; default: spprintf(&message, 0, "%s: invalid PHP type for date", func); intl_errors_set(err, U_ILLEGAL_ARGUMENT_ERROR, diff --git a/ext/intl/tests/bug80763.phpt b/ext/intl/tests/bug80763.phpt new file mode 100644 index 0000000000..bd5aeb45c6 --- /dev/null +++ b/ext/intl/tests/bug80763.phpt @@ -0,0 +1,16 @@ +--TEST-- +Bug #80763 (msgfmt_format() does not accept DateTime references) +--SKIPIF-- +<?php +if (!extension_loaded('intl')) die('skip intl extension not available'); +?> +--FILE-- +<?php +$today = new DateTime('2021-02-17 12:00:00'); +$formatter = new \MessageFormatter('en_US', 'Today is {today, date, full}.'); +$params = ['today' => $today]; +array_walk($params, fn() => 1); +var_dump($formatter->format($params)); +?> +--EXPECT-- +string(38) "Today is Wednesday, February 17, 2021." |