summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--06897991d042115185fd98ff4e79569fbe51e0bf.patch25
-rw-r--r--61748491a773a7f47694e2fd97dc2c3c61ce9f18.patch171
-rw-r--r--70fe4e091eadb40a57b90c0d6345b7722b6817db.patch162
-rw-r--r--7e8816a4be83c43f3a0b373fe3d619dff5bc5fd8.patch35
-rw-r--r--REFLECTION148
-rw-r--r--ab34c77a5a9c8611d1fc87601fcd72c9defb809d.patch27
-rw-r--r--php-pecl-timecop.spec46
7 files changed, 550 insertions, 64 deletions
diff --git a/06897991d042115185fd98ff4e79569fbe51e0bf.patch b/06897991d042115185fd98ff4e79569fbe51e0bf.patch
new file mode 100644
index 0000000..ad74ac6
--- /dev/null
+++ b/06897991d042115185fd98ff4e79569fbe51e0bf.patch
@@ -0,0 +1,25 @@
+From 06897991d042115185fd98ff4e79569fbe51e0bf Mon Sep 17 00:00:00 2001
+From: USAMI Kenta <tadsan@zonu.me>
+Date: Thu, 11 Jul 2019 17:36:55 +0900
+Subject: [PATCH] Add temporary tests to detect class errors
+
+---
+ tests/immutable_override_008.phpt | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/tests/immutable_override_008.phpt b/tests/immutable_override_008.phpt
+index 8ecec38..7addcf3 100644
+--- a/tests/immutable_override_008.phpt
++++ b/tests/immutable_override_008.phpt
+@@ -35,6 +35,11 @@ var_dump($dt0->format("Y-m-d H:i:s.uP"));
+ foreach ($tests_args as $args) {
+ timecop_freeze($dt0);
+ $dt1 = call_user_func_array(array("DateTimeImmutable","createFromFormat"), $args);
++ if (!$dt1 instanceof DateTimeImmutable) {
++ // TODO: output an appropriate message
++ echo get_class($dt1), "\n";
++ }
++
+ var_dump($dt1->format("Y-m-d H:i:s.uP"));
+ while (true) {
+ /* test for equality between timecop_date_create_from_format() and date_create_from_format() */
diff --git a/61748491a773a7f47694e2fd97dc2c3c61ce9f18.patch b/61748491a773a7f47694e2fd97dc2c3c61ce9f18.patch
new file mode 100644
index 0000000..d9710e8
--- /dev/null
+++ b/61748491a773a7f47694e2fd97dc2c3c61ce9f18.patch
@@ -0,0 +1,171 @@
+From 61748491a773a7f47694e2fd97dc2c3c61ce9f18 Mon Sep 17 00:00:00 2001
+From: Yoshio HANAWA <y@hnw.jp>
+Date: Wed, 2 Oct 2019 23:53:44 +0900
+Subject: [PATCH] Refactoring
+
+---
+ .travis.yml | 3 +--
+ tests/date_007.phpt | 2 +-
+ tests/date_008.phpt | 2 +-
+ tests/date_override_007.phpt | 2 +-
+ tests/date_override_008.phpt | 2 +-
+ tests/immutable_007.phpt | 2 +-
+ tests/immutable_008.phpt | 2 +-
+ tests/immutable_override_007.phpt | 2 +-
+ tests/immutable_override_008.phpt | 2 +-
+ timecop_php7.c | 17 ++++++++---------
+ 10 files changed, 17 insertions(+), 19 deletions(-)
+
+diff --git a/tests/date_007.phpt b/tests/date_007.phpt
+index db490d8..759c09c 100644
+--- a/tests/date_007.phpt
++++ b/tests/date_007.phpt
+@@ -58,7 +58,7 @@ string\(32\) "2010-09-02 03:04:05\.000000-07:00"
+ string\(32\) "2010-12-24 03:04:05\.000000-08:00"
+ string\(32\) "2010-01-02 05:00:00\.000000\+09:00"
+ string\(32\) "2010-01-02 00:00:59\.000000-08:00"
+-string\(32\) "2010-01-02 (00|03):(00|04):(00|05)\.654321-08:00"
++string\(32\) "2010-01-02 (00:00:00|03:04:05)\.654321-08:00"
+ string\(32\) "2012-03-31 12:34:56\.000000-07:00"
+ string\(32\) "1970-01-01 12:34:56\.000000-08:00"
+ string\(32\) "1970-01-01 19:00:00\.000000-05:00"
+diff --git a/tests/date_008.phpt b/tests/date_008.phpt
+index 851c953..b91c833 100644
+--- a/tests/date_008.phpt
++++ b/tests/date_008.phpt
+@@ -59,7 +59,7 @@ string\(32\) "2010-09-02 03:04:05\.000000-07:00"
+ string\(32\) "2010-12-24 03:04:05\.000000-08:00"
+ string\(32\) "2010-01-02 05:00:00\.000000\+09:00"
+ string\(32\) "2010-01-02 00:00:59\.000000-08:00"
+-string\(32\) "2010-01-02 (00|03):(00|04):(00|05)\.654321-08:00"
++string\(32\) "2010-01-02 (00:00:00|03:04:05)\.654321-08:00"
+ string\(32\) "2012-03-31 12:34:56\.000000-07:00"
+ string\(32\) "1970-01-01 12:34:56\.000000-08:00"
+ string\(32\) "1970-01-01 19:00:00\.000000-05:00"
+diff --git a/tests/date_override_007.phpt b/tests/date_override_007.phpt
+index 6dd8311..c34708f 100644
+--- a/tests/date_override_007.phpt
++++ b/tests/date_override_007.phpt
+@@ -60,7 +60,7 @@ string\(32\) "2010-09-02 03:04:05\.000000-07:00"
+ string\(32\) "2010-12-24 03:04:05\.000000-08:00"
+ string\(32\) "2010-01-02 05:00:00\.000000\+09:00"
+ string\(32\) "2010-01-02 00:00:59\.000000-08:00"
+-string\(32\) "2010-01-02 (00|03):(00|04):(00|05)\.654321-08:00"
++string\(32\) "2010-01-02 (00:00:00|03:04:05)\.654321-08:00"
+ string\(32\) "2012-03-31 12:34:56\.000000-07:00"
+ string\(32\) "1970-01-01 12:34:56\.000000-08:00"
+ string\(32\) "1970-01-01 19:00:00\.000000-05:00"
+diff --git a/tests/date_override_008.phpt b/tests/date_override_008.phpt
+index 8d38c04..1764c0a 100644
+--- a/tests/date_override_008.phpt
++++ b/tests/date_override_008.phpt
+@@ -61,7 +61,7 @@ string\(32\) "2010-09-02 03:04:05\.000000-07:00"
+ string\(32\) "2010-12-24 03:04:05\.000000-08:00"
+ string\(32\) "2010-01-02 05:00:00\.000000\+09:00"
+ string\(32\) "2010-01-02 00:00:59\.000000-08:00"
+-string\(32\) "2010-01-02 (00|03):(00|04):(00|05)\.654321-08:00"
++string\(32\) "2010-01-02 (00:00:00|03:04:05)\.654321-08:00"
+ string\(32\) "2012-03-31 12:34:56\.000000-07:00"
+ string\(32\) "1970-01-01 12:34:56\.000000-08:00"
+ string\(32\) "1970-01-01 19:00:00\.000000-05:00"
+diff --git a/tests/immutable_007.phpt b/tests/immutable_007.phpt
+index 3bcf5c0..36249d2 100644
+--- a/tests/immutable_007.phpt
++++ b/tests/immutable_007.phpt
+@@ -58,7 +58,7 @@ string\(32\) "2010-09-02 03:04:05\.000000-07:00"
+ string\(32\) "2010-12-24 03:04:05\.000000-08:00"
+ string\(32\) "2010-01-02 05:00:00\.000000\+09:00"
+ string\(32\) "2010-01-02 00:00:59\.000000-08:00"
+-string\(32\) "2010-01-02 (00|03):(00|04):(00|05)\.654321-08:00"
++string\(32\) "2010-01-02 (00:00:00|03:04:05)\.654321-08:00"
+ string\(32\) "2012-03-31 12:34:56\.000000-07:00"
+ string\(32\) "1970-01-01 12:34:56\.000000-08:00"
+ string\(32\) "1970-01-01 19:00:00\.000000-05:00"
+diff --git a/tests/immutable_008.phpt b/tests/immutable_008.phpt
+index 8fd738f..06f1539 100644
+--- a/tests/immutable_008.phpt
++++ b/tests/immutable_008.phpt
+@@ -59,7 +59,7 @@ string\(32\) "2010-09-02 03:04:05\.000000-07:00"
+ string\(32\) "2010-12-24 03:04:05\.000000-08:00"
+ string\(32\) "2010-01-02 05:00:00\.000000\+09:00"
+ string\(32\) "2010-01-02 00:00:59\.000000-08:00"
+-string\(32\) "2010-01-02 (00|03):(00|04):(00|05)\.654321-08:00"
++string\(32\) "2010-01-02 (00:00:00|03:04:05)\.654321-08:00"
+ string\(32\) "2012-03-31 12:34:56\.000000-07:00"
+ string\(32\) "1970-01-01 12:34:56\.000000-08:00"
+ string\(32\) "1970-01-01 19:00:00\.000000-05:00"
+diff --git a/tests/immutable_override_007.phpt b/tests/immutable_override_007.phpt
+index 7d26767..38390ab 100644
+--- a/tests/immutable_override_007.phpt
++++ b/tests/immutable_override_007.phpt
+@@ -60,7 +60,7 @@ string\(32\) "2010-09-02 03:04:05\.000000-07:00"
+ string\(32\) "2010-12-24 03:04:05\.000000-08:00"
+ string\(32\) "2010-01-02 05:00:00\.000000\+09:00"
+ string\(32\) "2010-01-02 00:00:59\.000000-08:00"
+-string\(32\) "2010-01-02 (00|03):(00|04):(00|05)\.654321-08:00"
++string\(32\) "2010-01-02 (00:00:00|03:04:05)\.654321-08:00"
+ string\(32\) "2012-03-31 12:34:56\.000000-07:00"
+ string\(32\) "1970-01-01 12:34:56\.000000-08:00"
+ string\(32\) "1970-01-01 19:00:00\.000000-05:00"
+diff --git a/tests/immutable_override_008.phpt b/tests/immutable_override_008.phpt
+index 567ae25..b7dfa4a 100644
+--- a/tests/immutable_override_008.phpt
++++ b/tests/immutable_override_008.phpt
+@@ -66,7 +66,7 @@ string\(32\) "2010-09-02 03:04:05\.000000-07:00"
+ string\(32\) "2010-12-24 03:04:05\.000000-08:00"
+ string\(32\) "2010-01-02 05:00:00\.000000\+09:00"
+ string\(32\) "2010-01-02 00:00:59\.000000-08:00"
+-string\(32\) "2010-01-02 (00|03):(00|04):(00|05)\.654321-08:00"
++string\(32\) "2010-01-02 (00:00:00|03:04:05)\.654321-08:00"
+ string\(32\) "2012-03-31 12:34:56\.000000-07:00"
+ string\(32\) "1970-01-01 12:34:56\.000000-08:00"
+ string\(32\) "1970-01-01 19:00:00\.000000-05:00"
+diff --git a/timecop_php7.c b/timecop_php7.c
+index df430cd..0e95945 100644
+--- a/timecop_php7.c
++++ b/timecop_php7.c
+@@ -1433,6 +1433,8 @@ static void _timecop_date_create_from_format(INTERNAL_FUNCTION_PARAMETERS, int i
+
+ call_php_function_with_3_params(ORIG_FUNC_NAME("date_create_from_format"), &dt, &orig_format, &orig_time, orig_timezone);
+ if (Z_TYPE(dt) == IS_FALSE) {
++ zval_ptr_dtor(&orig_format);
++ zval_ptr_dtor(&orig_time);
+ RETURN_FALSE;
+ }
+
+@@ -1443,6 +1445,7 @@ static void _timecop_date_create_from_format(INTERNAL_FUNCTION_PARAMETERS, int i
+
+ if (immutable) {
+ call_php_method_with_1_params(NULL, TIMECOP_G(ce_DateTimeImmutable), "createfrommutable", &dti, &dt);
++ zval_ptr_dtor(&dt);
+ RETURN_ZVAL(&dti, 1, 1);
+ }
+
+@@ -1458,7 +1461,11 @@ static void _timecop_date_create_from_format(INTERNAL_FUNCTION_PARAMETERS, int i
+ call_php_method_with_1_params(&dt, TIMECOP_G(ce_DateTime), "format", &fixed_time, &tmp);
+ zval_ptr_dtor(&tmp);
+
+- if (memchr(orig_format_str, 'g', orig_format_len) ||
++ if (
++#if PHP_VERSION_ID >= 70300
++ memchr(orig_format_str, 'u', orig_format_len) ||
++#endif
++ memchr(orig_format_str, 'g', orig_format_len) ||
+ memchr(orig_format_str, 'h', orig_format_len) ||
+ memchr(orig_format_str, 'G', orig_format_len) ||
+ memchr(orig_format_str, 'H', orig_format_len) ||
+@@ -1478,14 +1485,6 @@ static void _timecop_date_create_from_format(INTERNAL_FUNCTION_PARAMETERS, int i
+ memchr(orig_format_str, 'l', orig_format_len) ||
+ memchr(orig_format_str, 'U', orig_format_len)) {
+ ZVAL_STRING(&fixed_format, "Y-m-d H:i:s.??????");
+- } else if (memchr(orig_format_str, 'u', orig_format_len)) {
+- #if PHP_VERSION_ID >= 70300
+- ZVAL_STRING(&fixed_format, "Y-m-d ??:??:??.??????");
+- #elif PHP_VERSION_ID >= 70100
+- ZVAL_STRING(&fixed_format, "Y-m-d H:i:s.u");
+- #else
+- ZVAL_STRING(&fixed_format, "Y-m-d H:i:s.??????");
+- #endif
+ } else {
+ #if PHP_VERSION_ID >= 70100
+ ZVAL_STRING(&fixed_format, "Y-m-d H:i:s.u");
diff --git a/70fe4e091eadb40a57b90c0d6345b7722b6817db.patch b/70fe4e091eadb40a57b90c0d6345b7722b6817db.patch
new file mode 100644
index 0000000..2e74b59
--- /dev/null
+++ b/70fe4e091eadb40a57b90c0d6345b7722b6817db.patch
@@ -0,0 +1,162 @@
+From 70fe4e091eadb40a57b90c0d6345b7722b6817db Mon Sep 17 00:00:00 2001
+From: Thijs <thijs@305.nl>
+Date: Thu, 29 Aug 2019 16:55:46 +0200
+Subject: [PATCH] Fixed issue with microseconds on php 7.3
+
+---
+ .travis.yml | 1 +
+ tests/date_007.phpt | 2 +-
+ tests/date_008.phpt | 2 +-
+ tests/date_override_007.phpt | 2 +-
+ tests/date_override_008.phpt | 2 +-
+ tests/immutable_007.phpt | 2 +-
+ tests/immutable_008.phpt | 2 +-
+ tests/immutable_override_007.phpt | 2 +-
+ tests/immutable_override_008.phpt | 2 +-
+ timecop_php7.c | 21 +++++++++++++++------
+ 10 files changed, 24 insertions(+), 14 deletions(-)
+
+diff --git a/tests/date_007.phpt b/tests/date_007.phpt
+index fe47ded..db490d8 100644
+--- a/tests/date_007.phpt
++++ b/tests/date_007.phpt
+@@ -58,7 +58,7 @@ string\(32\) "2010-09-02 03:04:05\.000000-07:00"
+ string\(32\) "2010-12-24 03:04:05\.000000-08:00"
+ string\(32\) "2010-01-02 05:00:00\.000000\+09:00"
+ string\(32\) "2010-01-02 00:00:59\.000000-08:00"
+-string\(32\) "2010-01-02 03:04:05\.654321-08:00"
++string\(32\) "2010-01-02 (00|03):(00|04):(00|05)\.654321-08:00"
+ string\(32\) "2012-03-31 12:34:56\.000000-07:00"
+ string\(32\) "1970-01-01 12:34:56\.000000-08:00"
+ string\(32\) "1970-01-01 19:00:00\.000000-05:00"
+diff --git a/tests/date_008.phpt b/tests/date_008.phpt
+index 25ea7b1..851c953 100644
+--- a/tests/date_008.phpt
++++ b/tests/date_008.phpt
+@@ -59,7 +59,7 @@ string\(32\) "2010-09-02 03:04:05\.000000-07:00"
+ string\(32\) "2010-12-24 03:04:05\.000000-08:00"
+ string\(32\) "2010-01-02 05:00:00\.000000\+09:00"
+ string\(32\) "2010-01-02 00:00:59\.000000-08:00"
+-string\(32\) "2010-01-02 03:04:05\.654321-08:00"
++string\(32\) "2010-01-02 (00|03):(00|04):(00|05)\.654321-08:00"
+ string\(32\) "2012-03-31 12:34:56\.000000-07:00"
+ string\(32\) "1970-01-01 12:34:56\.000000-08:00"
+ string\(32\) "1970-01-01 19:00:00\.000000-05:00"
+diff --git a/tests/date_override_007.phpt b/tests/date_override_007.phpt
+index 804a982..6dd8311 100644
+--- a/tests/date_override_007.phpt
++++ b/tests/date_override_007.phpt
+@@ -60,7 +60,7 @@ string\(32\) "2010-09-02 03:04:05\.000000-07:00"
+ string\(32\) "2010-12-24 03:04:05\.000000-08:00"
+ string\(32\) "2010-01-02 05:00:00\.000000\+09:00"
+ string\(32\) "2010-01-02 00:00:59\.000000-08:00"
+-string\(32\) "2010-01-02 03:04:05\.654321-08:00"
++string\(32\) "2010-01-02 (00|03):(00|04):(00|05)\.654321-08:00"
+ string\(32\) "2012-03-31 12:34:56\.000000-07:00"
+ string\(32\) "1970-01-01 12:34:56\.000000-08:00"
+ string\(32\) "1970-01-01 19:00:00\.000000-05:00"
+diff --git a/tests/date_override_008.phpt b/tests/date_override_008.phpt
+index 9002b2f..8d38c04 100644
+--- a/tests/date_override_008.phpt
++++ b/tests/date_override_008.phpt
+@@ -61,7 +61,7 @@ string\(32\) "2010-09-02 03:04:05\.000000-07:00"
+ string\(32\) "2010-12-24 03:04:05\.000000-08:00"
+ string\(32\) "2010-01-02 05:00:00\.000000\+09:00"
+ string\(32\) "2010-01-02 00:00:59\.000000-08:00"
+-string\(32\) "2010-01-02 03:04:05\.654321-08:00"
++string\(32\) "2010-01-02 (00|03):(00|04):(00|05)\.654321-08:00"
+ string\(32\) "2012-03-31 12:34:56\.000000-07:00"
+ string\(32\) "1970-01-01 12:34:56\.000000-08:00"
+ string\(32\) "1970-01-01 19:00:00\.000000-05:00"
+diff --git a/tests/immutable_007.phpt b/tests/immutable_007.phpt
+index 22d2742..3bcf5c0 100644
+--- a/tests/immutable_007.phpt
++++ b/tests/immutable_007.phpt
+@@ -58,7 +58,7 @@ string\(32\) "2010-09-02 03:04:05\.000000-07:00"
+ string\(32\) "2010-12-24 03:04:05\.000000-08:00"
+ string\(32\) "2010-01-02 05:00:00\.000000\+09:00"
+ string\(32\) "2010-01-02 00:00:59\.000000-08:00"
+-string\(32\) "2010-01-02 03:04:05\.654321-08:00"
++string\(32\) "2010-01-02 (00|03):(00|04):(00|05)\.654321-08:00"
+ string\(32\) "2012-03-31 12:34:56\.000000-07:00"
+ string\(32\) "1970-01-01 12:34:56\.000000-08:00"
+ string\(32\) "1970-01-01 19:00:00\.000000-05:00"
+diff --git a/tests/immutable_008.phpt b/tests/immutable_008.phpt
+index fa82837..8fd738f 100644
+--- a/tests/immutable_008.phpt
++++ b/tests/immutable_008.phpt
+@@ -59,7 +59,7 @@ string\(32\) "2010-09-02 03:04:05\.000000-07:00"
+ string\(32\) "2010-12-24 03:04:05\.000000-08:00"
+ string\(32\) "2010-01-02 05:00:00\.000000\+09:00"
+ string\(32\) "2010-01-02 00:00:59\.000000-08:00"
+-string\(32\) "2010-01-02 03:04:05\.654321-08:00"
++string\(32\) "2010-01-02 (00|03):(00|04):(00|05)\.654321-08:00"
+ string\(32\) "2012-03-31 12:34:56\.000000-07:00"
+ string\(32\) "1970-01-01 12:34:56\.000000-08:00"
+ string\(32\) "1970-01-01 19:00:00\.000000-05:00"
+diff --git a/tests/immutable_override_007.phpt b/tests/immutable_override_007.phpt
+index 1bb9992..7d26767 100644
+--- a/tests/immutable_override_007.phpt
++++ b/tests/immutable_override_007.phpt
+@@ -60,7 +60,7 @@ string\(32\) "2010-09-02 03:04:05\.000000-07:00"
+ string\(32\) "2010-12-24 03:04:05\.000000-08:00"
+ string\(32\) "2010-01-02 05:00:00\.000000\+09:00"
+ string\(32\) "2010-01-02 00:00:59\.000000-08:00"
+-string\(32\) "2010-01-02 03:04:05\.654321-08:00"
++string\(32\) "2010-01-02 (00|03):(00|04):(00|05)\.654321-08:00"
+ string\(32\) "2012-03-31 12:34:56\.000000-07:00"
+ string\(32\) "1970-01-01 12:34:56\.000000-08:00"
+ string\(32\) "1970-01-01 19:00:00\.000000-05:00"
+diff --git a/tests/immutable_override_008.phpt b/tests/immutable_override_008.phpt
+index 8ecec38..1c74cc9 100644
+--- a/tests/immutable_override_008.phpt
++++ b/tests/immutable_override_008.phpt
+@@ -61,7 +61,7 @@ string\(32\) "2010-09-02 03:04:05\.000000-07:00"
+ string\(32\) "2010-12-24 03:04:05\.000000-08:00"
+ string\(32\) "2010-01-02 05:00:00\.000000\+09:00"
+ string\(32\) "2010-01-02 00:00:59\.000000-08:00"
+-string\(32\) "2010-01-02 03:04:05\.654321-08:00"
++string\(32\) "2010-01-02 (00|03):(00|04):(00|05)\.654321-08:00"
+ string\(32\) "2012-03-31 12:34:56\.000000-07:00"
+ string\(32\) "1970-01-01 12:34:56\.000000-08:00"
+ string\(32\) "1970-01-01 19:00:00\.000000-05:00"
+diff --git a/timecop_php7.c b/timecop_php7.c
+index 8d7faec..93c51e6 100644
+--- a/timecop_php7.c
++++ b/timecop_php7.c
+@@ -1457,7 +1457,8 @@ static void _timecop_date_create_from_format(INTERNAL_FUNCTION_PARAMETERS, int i
+ memchr(orig_format_str, 'G', orig_format_len) ||
+ memchr(orig_format_str, 'H', orig_format_len) ||
+ memchr(orig_format_str, 'i', orig_format_len) ||
+- memchr(orig_format_str, 's', orig_format_len)) {
++ memchr(orig_format_str, 's', orig_format_len)
++ ) {
+ ZVAL_STRING(&fixed_format, "Y-m-d ??:??:??.??????");
+ } else if (memchr(orig_format_str, 'Y', orig_format_len) ||
+ memchr(orig_format_str, 'y', orig_format_len) ||
+@@ -1471,12 +1472,20 @@ static void _timecop_date_create_from_format(INTERNAL_FUNCTION_PARAMETERS, int i
+ memchr(orig_format_str, 'l', orig_format_len) ||
+ memchr(orig_format_str, 'U', orig_format_len)) {
+ ZVAL_STRING(&fixed_format, "Y-m-d H:i:s.??????");
++ } else if (memchr(orig_format_str, 'u', orig_format_len)) {
++ #if PHP_VERSION_ID >= 70300
++ ZVAL_STRING(&fixed_format, "Y-m-d ??:??:??.??????");
++ #elif PHP_VERSION_ID >= 70100
++ ZVAL_STRING(&fixed_format, "Y-m-d H:i:s.u");
++ #else
++ ZVAL_STRING(&fixed_format, "Y-m-d H:i:s.??????");
++ #endif
+ } else {
+-#if PHP_VERSION_ID >= 70100
+- ZVAL_STRING(&fixed_format, "Y-m-d H:i:s.u");
+-#else
+- ZVAL_STRING(&fixed_format, "Y-m-d H:i:s.??????");
+-#endif
++ #if PHP_VERSION_ID >= 70100
++ ZVAL_STRING(&fixed_format, "Y-m-d H:i:s.u");
++ #else
++ ZVAL_STRING(&fixed_format, "Y-m-d H:i:s.??????");
++ #endif
+ }
+
+ ZVAL_STRING(&tmp, "%s %s");
diff --git a/7e8816a4be83c43f3a0b373fe3d619dff5bc5fd8.patch b/7e8816a4be83c43f3a0b373fe3d619dff5bc5fd8.patch
new file mode 100644
index 0000000..748c6c9
--- /dev/null
+++ b/7e8816a4be83c43f3a0b373fe3d619dff5bc5fd8.patch
@@ -0,0 +1,35 @@
+From 7e8816a4be83c43f3a0b373fe3d619dff5bc5fd8 Mon Sep 17 00:00:00 2001
+From: USAMI Kenta <tadsan@zonu.me>
+Date: Thu, 11 Jul 2019 18:23:23 +0900
+Subject: [PATCH] Fix return value when DateTimeImmutable::createFromFormat()
+
+---
+ timecop_php7.c | 8 +++++++-
+ 1 file changed, 7 insertions(+), 1 deletion(-)
+
+diff --git a/timecop_php7.c b/timecop_php7.c
+index 8d7faec..8493033 100644
+--- a/timecop_php7.c
++++ b/timecop_php7.c
+@@ -1417,7 +1417,7 @@ static void _timecop_date_create_from_format(INTERNAL_FUNCTION_PARAMETERS, int i
+ {
+ zval *orig_timezone = NULL;
+ zval orig_format, orig_time, fixed_format, fixed_time, new_format, new_time;
+- zval dt, now_timestamp, tmp;
++ zval dt, dti, now_timestamp, tmp;
+ char *orig_format_str, *orig_time_str;
+ size_t orig_format_len, orig_time_len;
+ tc_timeval now;
+@@ -1440,6 +1440,12 @@ static void _timecop_date_create_from_format(INTERNAL_FUNCTION_PARAMETERS, int i
+ memchr(orig_format_str, '|', orig_format_len)) {
+ zval_ptr_dtor(&orig_format);
+ zval_ptr_dtor(&orig_time);
++
++ if (immutable) {
++ call_php_method_with_1_params(NULL, TIMECOP_G(ce_DateTimeImmutable), "createfrommutable", &dti, &dt);
++ RETURN_ZVAL(&dti, 1, 1);
++ }
++
+ RETURN_ZVAL(&dt, 1, 1);
+ }
+
diff --git a/REFLECTION b/REFLECTION
index 35e1cc9..693efa5 100644
--- a/REFLECTION
+++ b/REFLECTION
@@ -1,4 +1,4 @@
-Extension [ <persistent> extension #149 timecop version 1.2.10 ] {
+Extension [ <persistent> extension #105 timecop version 1.2.10 ] {
- INI {
Entry [ timecop.func_override <SYSTEM> ]
@@ -111,7 +111,7 @@ Extension [ <persistent> extension #149 timecop version 1.2.10 ] {
- Parameters [3] {
Parameter #0 [ <required> $format ]
Parameter #1 [ <required> $time ]
- Parameter #2 [ <optional> $object ]
+ Parameter #2 [ <optional> DateTimeZone or NULL $object ]
}
}
Function [ <internal:timecop> function timecop_date_create_immutable_from_format ] {
@@ -119,7 +119,7 @@ Extension [ <persistent> extension #149 timecop version 1.2.10 ] {
- Parameters [3] {
Parameter #0 [ <required> $format ]
Parameter #1 [ <required> $time ]
- Parameter #2 [ <optional> $object ]
+ Parameter #2 [ <optional> DateTimeZone or NULL $object ]
}
}
Function [ <internal:timecop> function timecop_microtime ] {
@@ -275,7 +275,7 @@ Extension [ <persistent> extension #149 timecop version 1.2.10 ] {
- Parameters [3] {
Parameter #0 [ <required> $format ]
Parameter #1 [ <required> $time ]
- Parameter #2 [ <optional> $object ]
+ Parameter #2 [ <optional> DateTimeZone or NULL $object ]
}
}
Function [ <internal:timecop> function timecop_date_create_immutable ] {
@@ -290,7 +290,7 @@ Extension [ <persistent> extension #149 timecop version 1.2.10 ] {
- Parameters [3] {
Parameter #0 [ <required> $format ]
Parameter #1 [ <required> $time ]
- Parameter #2 [ <optional> $object ]
+ Parameter #2 [ <optional> DateTimeZone or NULL $object ]
}
}
}
@@ -343,35 +343,46 @@ Extension [ <persistent> extension #149 timecop version 1.2.10 ] {
Class [ <internal:timecop> class TimecopDateTime extends DateTime implements DateTimeInterface ] {
- Constants [13] {
- Constant [ string ATOM ] { Y-m-d\TH:i:sP }
- Constant [ string COOKIE ] { l, d-M-Y H:i:s T }
- Constant [ string ISO8601 ] { Y-m-d\TH:i:sO }
- Constant [ string RFC822 ] { D, d M y H:i:s O }
- Constant [ string RFC850 ] { l, d-M-y H:i:s T }
- Constant [ string RFC1036 ] { D, d M y H:i:s O }
- Constant [ string RFC1123 ] { D, d M Y H:i:s O }
- Constant [ string RFC7231 ] { D, d M Y H:i:s \G\M\T }
- Constant [ string RFC2822 ] { D, d M Y H:i:s O }
- Constant [ string RFC3339 ] { Y-m-d\TH:i:sP }
- Constant [ string RFC3339_EXTENDED ] { Y-m-d\TH:i:s.vP }
- Constant [ string RSS ] { D, d M Y H:i:s O }
- Constant [ string W3C ] { Y-m-d\TH:i:sP }
+ Constant [ public string ATOM ] { Y-m-d\TH:i:sP }
+ Constant [ public string COOKIE ] { l, d-M-Y H:i:s T }
+ Constant [ public string ISO8601 ] { Y-m-d\TH:i:sO }
+ Constant [ public string RFC822 ] { D, d M y H:i:s O }
+ Constant [ public string RFC850 ] { l, d-M-y H:i:s T }
+ Constant [ public string RFC1036 ] { D, d M y H:i:s O }
+ Constant [ public string RFC1123 ] { D, d M Y H:i:s O }
+ Constant [ public string RFC7231 ] { D, d M Y H:i:s \G\M\T }
+ Constant [ public string RFC2822 ] { D, d M Y H:i:s O }
+ Constant [ public string RFC3339 ] { Y-m-d\TH:i:sP }
+ Constant [ public string RFC3339_EXTENDED ] { Y-m-d\TH:i:s.vP }
+ Constant [ public string RSS ] { D, d M Y H:i:s O }
+ Constant [ public string W3C ] { Y-m-d\TH:i:sP }
}
- Static properties [0] {
}
- - Static methods [3] {
+ - Static methods [4] {
Method [ <internal:timecop, prototype DateTimeImmutable> static public method createFromFormat ] {
- Parameters [3] {
Parameter #0 [ <required> $format ]
Parameter #1 [ <required> $time ]
- Parameter #2 [ <optional> $object ]
+ Parameter #2 [ <optional> DateTimeZone or NULL $object ]
}
}
Method [ <internal:date, inherits DateTime> static public method __set_state ] {
+
+ - Parameters [1] {
+ Parameter #0 [ <required> array $array ]
+ }
+ }
+
+ Method [ <internal:date, inherits DateTime> static public method createFromImmutable ] {
+
+ - Parameters [1] {
+ Parameter #0 [ <required> $DateTimeImmutable ]
+ }
}
Method [ <internal:date, inherits DateTime> static public method getLastErrors ] {
@@ -445,10 +456,11 @@ Extension [ <persistent> extension #149 timecop version 1.2.10 ] {
Method [ <internal:date, inherits DateTime> public method setTime ] {
- - Parameters [3] {
+ - Parameters [4] {
Parameter #0 [ <required> $hour ]
Parameter #1 [ <required> $minute ]
Parameter #2 [ <optional> $second ]
+ Parameter #3 [ <optional> $microseconds ]
}
}
@@ -496,26 +508,37 @@ Extension [ <persistent> extension #149 timecop version 1.2.10 ] {
Class [ <internal:timecop> class TimecopOrigDateTime extends DateTime implements DateTimeInterface ] {
- Constants [13] {
- Constant [ string ATOM ] { Y-m-d\TH:i:sP }
- Constant [ string COOKIE ] { l, d-M-Y H:i:s T }
- Constant [ string ISO8601 ] { Y-m-d\TH:i:sO }
- Constant [ string RFC822 ] { D, d M y H:i:s O }
- Constant [ string RFC850 ] { l, d-M-y H:i:s T }
- Constant [ string RFC1036 ] { D, d M y H:i:s O }
- Constant [ string RFC1123 ] { D, d M Y H:i:s O }
- Constant [ string RFC7231 ] { D, d M Y H:i:s \G\M\T }
- Constant [ string RFC2822 ] { D, d M Y H:i:s O }
- Constant [ string RFC3339 ] { Y-m-d\TH:i:sP }
- Constant [ string RFC3339_EXTENDED ] { Y-m-d\TH:i:s.vP }
- Constant [ string RSS ] { D, d M Y H:i:s O }
- Constant [ string W3C ] { Y-m-d\TH:i:sP }
+ Constant [ public string ATOM ] { Y-m-d\TH:i:sP }
+ Constant [ public string COOKIE ] { l, d-M-Y H:i:s T }
+ Constant [ public string ISO8601 ] { Y-m-d\TH:i:sO }
+ Constant [ public string RFC822 ] { D, d M y H:i:s O }
+ Constant [ public string RFC850 ] { l, d-M-y H:i:s T }
+ Constant [ public string RFC1036 ] { D, d M y H:i:s O }
+ Constant [ public string RFC1123 ] { D, d M Y H:i:s O }
+ Constant [ public string RFC7231 ] { D, d M Y H:i:s \G\M\T }
+ Constant [ public string RFC2822 ] { D, d M Y H:i:s O }
+ Constant [ public string RFC3339 ] { Y-m-d\TH:i:sP }
+ Constant [ public string RFC3339_EXTENDED ] { Y-m-d\TH:i:s.vP }
+ Constant [ public string RSS ] { D, d M Y H:i:s O }
+ Constant [ public string W3C ] { Y-m-d\TH:i:sP }
}
- Static properties [0] {
}
- - Static methods [3] {
+ - Static methods [4] {
Method [ <internal:date, inherits DateTime> static public method __set_state ] {
+
+ - Parameters [1] {
+ Parameter #0 [ <required> array $array ]
+ }
+ }
+
+ Method [ <internal:date, inherits DateTime> static public method createFromImmutable ] {
+
+ - Parameters [1] {
+ Parameter #0 [ <required> $DateTimeImmutable ]
+ }
}
Method [ <internal:date, inherits DateTime> static public method createFromFormat ] {
@@ -523,7 +546,7 @@ Extension [ <persistent> extension #149 timecop version 1.2.10 ] {
- Parameters [3] {
Parameter #0 [ <required> $format ]
Parameter #1 [ <required> $time ]
- Parameter #2 [ <optional> $object ]
+ Parameter #2 [ <optional> DateTimeZone or NULL $object ]
}
}
@@ -598,10 +621,11 @@ Extension [ <persistent> extension #149 timecop version 1.2.10 ] {
Method [ <internal:date, inherits DateTime> public method setTime ] {
- - Parameters [3] {
+ - Parameters [4] {
Parameter #0 [ <required> $hour ]
Parameter #1 [ <required> $minute ]
Parameter #2 [ <optional> $second ]
+ Parameter #3 [ <optional> $microseconds ]
}
}
@@ -648,23 +672,40 @@ Extension [ <persistent> extension #149 timecop version 1.2.10 ] {
Class [ <internal:timecop> class TimecopDateTimeImmutable extends DateTimeImmutable implements DateTimeInterface ] {
- - Constants [0] {
+ - Constants [13] {
+ Constant [ public string ATOM ] { Y-m-d\TH:i:sP }
+ Constant [ public string COOKIE ] { l, d-M-Y H:i:s T }
+ Constant [ public string ISO8601 ] { Y-m-d\TH:i:sO }
+ Constant [ public string RFC822 ] { D, d M y H:i:s O }
+ Constant [ public string RFC850 ] { l, d-M-y H:i:s T }
+ Constant [ public string RFC1036 ] { D, d M y H:i:s O }
+ Constant [ public string RFC1123 ] { D, d M Y H:i:s O }
+ Constant [ public string RFC7231 ] { D, d M Y H:i:s \G\M\T }
+ Constant [ public string RFC2822 ] { D, d M Y H:i:s O }
+ Constant [ public string RFC3339 ] { Y-m-d\TH:i:sP }
+ Constant [ public string RFC3339_EXTENDED ] { Y-m-d\TH:i:s.vP }
+ Constant [ public string RSS ] { D, d M Y H:i:s O }
+ Constant [ public string W3C ] { Y-m-d\TH:i:sP }
}
- Static properties [0] {
}
- Static methods [4] {
- Method [ <internal:timecop> static public method createFromFormat ] {
+ Method [ <internal:timecop, prototype DateTimeImmutable> static public method createFromFormat ] {
- Parameters [3] {
Parameter #0 [ <required> $format ]
Parameter #1 [ <required> $time ]
- Parameter #2 [ <optional> $object ]
+ Parameter #2 [ <optional> DateTimeZone or NULL $object ]
}
}
Method [ <internal:date, inherits DateTimeImmutable> static public method __set_state ] {
+
+ - Parameters [1] {
+ Parameter #0 [ <required> array $array ]
+ }
}
Method [ <internal:date, inherits DateTimeImmutable> static public method getLastErrors ] {
@@ -759,10 +800,11 @@ Extension [ <persistent> extension #149 timecop version 1.2.10 ] {
Method [ <internal:date, inherits DateTimeImmutable> public method setTime ] {
- - Parameters [3] {
+ - Parameters [4] {
Parameter #0 [ <required> $hour ]
Parameter #1 [ <required> $minute ]
Parameter #2 [ <optional> $second ]
+ Parameter #3 [ <optional> $microseconds ]
}
}
@@ -795,7 +837,20 @@ Extension [ <persistent> extension #149 timecop version 1.2.10 ] {
Class [ <internal:timecop> class TimecopOrigDateTimeImmutable extends DateTimeImmutable implements DateTimeInterface ] {
- - Constants [0] {
+ - Constants [13] {
+ Constant [ public string ATOM ] { Y-m-d\TH:i:sP }
+ Constant [ public string COOKIE ] { l, d-M-Y H:i:s T }
+ Constant [ public string ISO8601 ] { Y-m-d\TH:i:sO }
+ Constant [ public string RFC822 ] { D, d M y H:i:s O }
+ Constant [ public string RFC850 ] { l, d-M-y H:i:s T }
+ Constant [ public string RFC1036 ] { D, d M y H:i:s O }
+ Constant [ public string RFC1123 ] { D, d M Y H:i:s O }
+ Constant [ public string RFC7231 ] { D, d M Y H:i:s \G\M\T }
+ Constant [ public string RFC2822 ] { D, d M Y H:i:s O }
+ Constant [ public string RFC3339 ] { Y-m-d\TH:i:sP }
+ Constant [ public string RFC3339_EXTENDED ] { Y-m-d\TH:i:s.vP }
+ Constant [ public string RSS ] { D, d M Y H:i:s O }
+ Constant [ public string W3C ] { Y-m-d\TH:i:sP }
}
- Static properties [0] {
@@ -803,6 +858,10 @@ Extension [ <persistent> extension #149 timecop version 1.2.10 ] {
- Static methods [4] {
Method [ <internal:date, inherits DateTimeImmutable> static public method __set_state ] {
+
+ - Parameters [1] {
+ Parameter #0 [ <required> array $array ]
+ }
}
Method [ <internal:date, inherits DateTimeImmutable> static public method createFromFormat ] {
@@ -810,7 +869,7 @@ Extension [ <persistent> extension #149 timecop version 1.2.10 ] {
- Parameters [3] {
Parameter #0 [ <required> $format ]
Parameter #1 [ <required> $time ]
- Parameter #2 [ <optional> $object ]
+ Parameter #2 [ <optional> DateTimeZone or NULL $object ]
}
}
@@ -906,10 +965,11 @@ Extension [ <persistent> extension #149 timecop version 1.2.10 ] {
Method [ <internal:date, inherits DateTimeImmutable> public method setTime ] {
- - Parameters [3] {
+ - Parameters [4] {
Parameter #0 [ <required> $hour ]
Parameter #1 [ <required> $minute ]
Parameter #2 [ <optional> $second ]
+ Parameter #3 [ <optional> $microseconds ]
}
}
diff --git a/ab34c77a5a9c8611d1fc87601fcd72c9defb809d.patch b/ab34c77a5a9c8611d1fc87601fcd72c9defb809d.patch
new file mode 100644
index 0000000..9ca5605
--- /dev/null
+++ b/ab34c77a5a9c8611d1fc87601fcd72c9defb809d.patch
@@ -0,0 +1,27 @@
+From ab34c77a5a9c8611d1fc87601fcd72c9defb809d Mon Sep 17 00:00:00 2001
+From: USAMI Kenta <tadsan@zonu.me>
+Date: Thu, 11 Jul 2019 18:54:00 +0900
+Subject: [PATCH] Fix return value when DateTimeImmutable::createFromFormat()
+ for PHP 5
+
+---
+ timecop_php5.c | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/timecop_php5.c b/timecop_php5.c
+index 316d74a..5c16177 100644
+--- a/timecop_php5.c
++++ b/timecop_php5.c
+@@ -1520,6 +1520,12 @@ static void _timecop_date_create_from_format(INTERNAL_FUNCTION_PARAMETERS, int i
+
+ if (memchr(orig_format_str, '!', orig_format_len) ||
+ memchr(orig_format_str, '|', orig_format_len)) {
++
++ if (immutable) {
++ call_php_function_with_3_params(ORIG_FUNC_NAME("date_create_immutable_from_format"), &new_dt, &orig_format, &orig_time, orig_timezone);
++ RETURN_ZVAL(new_dt, 1, 1);
++ }
++
+ RETURN_ZVAL(dt, 1, 1);
+ }
+
diff --git a/php-pecl-timecop.spec b/php-pecl-timecop.spec
index 52931f8..280b6fd 100644
--- a/php-pecl-timecop.spec
+++ b/php-pecl-timecop.spec
@@ -12,7 +12,9 @@
%endif
%global pecl_name timecop
-%global with_zts 0%{!?_without_zts:%{?__ztsphp:1}}
+# Disable ZTS for now
+# PR 45 seems needed, but raise segfaults
+%global with_zts 0
%global with_tests %{?_without_tests:0}%{!?_without_tests:1}
%if "%{php_version}" < "5.6"
%global ini_name %{pecl_name}.ini
@@ -23,7 +25,7 @@
Summary: Time travel and freezing extension
Name: %{?sub_prefix}php-pecl-timecop
Version: 1.2.10
-Release: 5%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}}
+Release: 9%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}}
License: MIT
URL: http://pecl.php.net/package/%{pecl_name}
Source0: http://pecl.php.net/get/%{pecl_name}-%{version}.tgz
@@ -32,6 +34,12 @@ Source0: http://pecl.php.net/get/%{pecl_name}-%{version}.tgz
Patch0: https://patch-diff.githubusercontent.com/raw/hnw/php-timecop/pull/44.patch
# https://github.com/hnw/php-timecop/pull/45 for ZTS
Patch1: https://patch-diff.githubusercontent.com/raw/hnw/php-timecop/pull/45.patch
+# Upstream patches
+Patch2: https://github.com/hnw/php-timecop/commit/70fe4e091eadb40a57b90c0d6345b7722b6817db.patch
+Patch3: https://github.com/hnw/php-timecop/commit/06897991d042115185fd98ff4e79569fbe51e0bf.patch
+Patch4: https://github.com/hnw/php-timecop/commit/7e8816a4be83c43f3a0b373fe3d619dff5bc5fd8.patch
+Patch5: https://github.com/hnw/php-timecop/commit/ab34c77a5a9c8611d1fc87601fcd72c9defb809d.patch
+Patch6: https://github.com/hnw/php-timecop/commit/61748491a773a7f47694e2fd97dc2c3c61ce9f18.patch
BuildRequires: %{?dtsprefix}gcc
BuildRequires: %{?scl_prefix}php-devel
@@ -53,18 +61,18 @@ Provides: %{?scl_prefix}php-pecl-%{pecl_name}%{?_isa} = %{version}-%{relea
%if "%{?vendor}" == "Remi Collet" && 0%{!?scl:1} && 0%{?rhel}
# Other third party repo stuff
-%if "%{php_version}" > "7.1"
-Obsoletes: php71u-pecl-%{pecl_name} <= %{version}
-Obsoletes: php71w-pecl-%{pecl_name} <= %{version}
-%endif
%if "%{php_version}" > "7.2"
Obsoletes: php72u-pecl-%{pecl_name} <= %{version}
Obsoletes: php72w-pecl-%{pecl_name} <= %{version}
%endif
%if "%{php_version}" > "7.3"
-Obsoletes: php73u-pecl-%{pecl_name} <= %{version}
+Obsoletes: php73-pecl-%{pecl_name} <= %{version}
Obsoletes: php73w-pecl-%{pecl_name} <= %{version}
%endif
+%if "%{php_version}" > "7.4"
+Obsoletes: php74-pecl-%{pecl_name} <= %{version}
+Obsoletes: php74w-pecl-%{pecl_name} <= %{version}
+%endif
%endif
%if 0%{?fedora} < 20 && 0%{?rhel} < 7
@@ -91,8 +99,13 @@ sed -e 's/role="test"/role="src"/' \
-i package.xml
cd NTS
-%patch0 -p1 -b .pr44
-%patch1 -p1 -b .pr45
+#patch0 -p1 -b .pr44
+#patch1 -p1 -b .pr45
+%patch2 -p1 -b .up1
+%patch3 -p1 -b .up2
+%patch4 -p1 -b .up3
+%patch5 -p1 -b .up4
+%patch6 -p1 -b .up5
# Sanity check, really often broken
extver=$(sed -n '/#define PHP_TIMECOP_VERSION/{s/.* "//;s/".*$//;p}' php_timecop.h)
@@ -173,17 +186,6 @@ fi
--modules | grep %{pecl_name}
%if %{with_tests}
-%if "%{php_version}" > "7.3"
-rm ?TS/tests/date_007.phpt
-rm ?TS/tests/date_008.phpt
-rm ?TS/tests/date_override_007.phpt
-rm ?TS/tests/date_override_008.phpt
-rm ?TS/tests/immutable_007.phpt
-rm ?TS/tests/immutable_008.phpt
-rm ?TS/tests/immutable_override_007.phpt
-rm ?TS/tests/immutable_override_008.phpt
-%endif
-
cd NTS
: Upstream test suite for NTS extension
TEST_PHP_EXECUTABLE=%{__php} \
@@ -246,6 +248,10 @@ fi
%changelog
+* Sun Dec 15 2019 Remi Collet <remi@remirepo.net> - 1.2.10-9
+- add upstream patches for 7.3 and 7.4
+- disable ZTS for now
+
* Thu Feb 28 2019 Remi Collet <remi@remirepo.net> - 1.2.10-5
- fix strict_types support, patch from
https://github.com/hnw/php-timecop/pull/44