Skip to content

Commit 7e8816a

Browse files
committed
Fix return value when DateTimeImmutable::createFromFormat()
1 parent 0689799 commit 7e8816a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

timecop_php7.c

+7-1
Original file line numberDiff line numberDiff line change
@@ -1417,7 +1417,7 @@ static void _timecop_date_create_from_format(INTERNAL_FUNCTION_PARAMETERS, int i
14171417
{
14181418
zval *orig_timezone = NULL;
14191419
zval orig_format, orig_time, fixed_format, fixed_time, new_format, new_time;
1420-
zval dt, now_timestamp, tmp;
1420+
zval dt, dti, now_timestamp, tmp;
14211421
char *orig_format_str, *orig_time_str;
14221422
size_t orig_format_len, orig_time_len;
14231423
tc_timeval now;
@@ -1440,6 +1440,12 @@ static void _timecop_date_create_from_format(INTERNAL_FUNCTION_PARAMETERS, int i
14401440
memchr(orig_format_str, '|', orig_format_len)) {
14411441
zval_ptr_dtor(&orig_format);
14421442
zval_ptr_dtor(&orig_time);
1443+
1444+
if (immutable) {
1445+
call_php_method_with_1_params(NULL, TIMECOP_G(ce_DateTimeImmutable), "createfrommutable", &dti, &dt);
1446+
RETURN_ZVAL(&dti, 1, 1);
1447+
}
1448+
14431449
RETURN_ZVAL(&dt, 1, 1);
14441450
}
14451451

0 commit comments

Comments
 (0)