PHP :: Bug #65502 :: DateTimeImmutable::createFromFormat returns DateTime

Bug #65502 DateTimeImmutable::createFromFormat returns DateTime
Submitted: 2013-08-22 11:27 UTC Modified: -
From: carlos at encore-lab dot com Assigned:
Status: Closed Package: Date/time related
PHP Version: 5.5.2 OS: CentOS 6.4 i386
Private report: No CVE-ID: None

 [2013-08-22 11:27 UTC] carlos at encore-lab dot com

Description:
------------
---
From manual page: http://www.php.net/datetimeimmutable.createfromformat
---

According to the manual (and the common sense also), 
DateTimeImmutable::createFromFormat should return a DateTimeImmutable object, but 
instead of that it returns a DateTime one.

Test script:
---------------
I've used the CLI console to test it:

php > $today = DateTimeImmutable::createFromFormat('Y-m-d|', '2013-08-22');
php > $tomorrow = $today->add(new DateInterval('P1D'));
php > var_dump($today->format('Y-m-d'), $tomorrow->format('Y-m-d'));
string(10) "2013-08-23"
string(10) "2013-08-23"
php > var_dump($today instanceof DateTimeImmutable);
bool(false)
php > var_dump($today instanceof DateTime);
bool(true)

Expected result:
----------------
$today must contain a DateTimeImmutable object and thus it must be immutable.

Actual result:
--------------
$today is a DateTime object instead of DateTimeImmutable

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports

 [2013-09-12 13:23 UTC] nikic@php.net

-Status: Open +Status: Closed