summaryrefslogtreecommitdiffstats
path: root/7e8816a4be83c43f3a0b373fe3d619dff5bc5fd8.patch
blob: 748c6c9dcf6d7c10e0aa6f3dfa72677ca00d66ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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);
 	}