Skip to content

Commit 165f544

Browse files
bor0nikic
authored andcommitted
Fix bug #65502: DateTimeImmutable::createFromFormat returns DateTime
DateTimeImmutable::createFromFormat should call date_create_immutable_from_format instead of date_create_from_format
1 parent d7f5f1e commit 165f544

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ PHP NEWS
3636
. Fixed bug #65458 (curl memory leak). (Adam)
3737

3838
- Datetime:
39+
. Fixed bug #65502 (DateTimeImmutable::createFromFormat returns DateTime).
40+
(Boro Sitnikovski)
3941
. Fixed bug #65548 (Comparison for DateTimeImmutable doesn't work).
4042
(Boro Sitnikovski)
4143
. Fixed bug #65554 (createFromFormat broken when weekday name is followed

ext/date/php_date.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ const zend_function_entry date_funcs_immutable[] = {
480480
PHP_ME(DateTimeImmutable, __construct, arginfo_date_create, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
481481
PHP_ME(DateTime, __wakeup, NULL, ZEND_ACC_PUBLIC)
482482
PHP_ME(DateTimeImmutable, __set_state, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
483-
PHP_ME_MAPPING(createFromFormat, date_create_from_format, arginfo_date_create_from_format, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
483+
PHP_ME_MAPPING(createFromFormat, date_create_immutable_from_format, arginfo_date_create_from_format, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
484484
PHP_ME_MAPPING(getLastErrors, date_get_last_errors, arginfo_date_get_last_errors, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
485485
PHP_ME_MAPPING(format, date_format, arginfo_date_method_format, 0)
486486
PHP_ME_MAPPING(getTimezone, date_timezone_get, arginfo_date_method_timezone_get, 0)

ext/date/tests/bug65502.phpt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
Test for bug #65502: DateTimeImmutable::createFromFormat returns DateTime
3+
--CREDITS--
4+
Boro Sitnikovski <buritomath@yahoo.com>
5+
--INI--
6+
date.timezone = UTC
7+
--FILE--
8+
<?php
9+
echo get_class(DateTimeImmutable::createFromFormat('j-M-Y', '12-Sep-2013'));
10+
?>
11+
--EXPECT--
12+
DateTimeImmutable

0 commit comments

Comments
 (0)