Bug #79975 [Opn]: DateTime::createFromFormat returns static type

From: Date: Thu, 13 Aug 2020 22:38:16 +0000
Subject: Bug #79975 [Opn]: DateTime::createFromFormat returns static type
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-228586@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79975&edit=1

 ID:                 79975
 Updated by:         derick@php.net
 Reported by:        corey dot taylor dot fl at gmail dot com
 Summary:            DateTime::createFromFormat returns static type
 Status:             Open
 Type:               Bug
 Package:            *General Issues
 PHP Version:        8.0.0beta1
 Block user comment: N
 Private report:     N

 New Comment:

This is indeed an intended big fix. As this change doesn't violate LSP (the inherited child
class still follows the is_a relationship with DateTime), how does it cause a problem in your
situation?


Previous Comments:
------------------------------------------------------------------------
[2020-08-13 22:26:37] corey dot taylor dot fl at gmail dot com

Description:
------------
I don't know if this is actually a bug or intended behavior or undefined behavior. However,
since it's been consistent up to 8.0.0beta1, I thought I'd report the change.

https://3v4l.org/dgunY


DateTime::createFromFormat() used to always return a DateTime instance if called from a class that
extended DateTime and wrapped createFromFormat().

Now, it is returning the static type. In this example,that is an ExtendsDateTime instance.

https://bugs.php.net/bug.php?id=60302

Looking, I see a very old bug that suggests this was supposed to be the fixed behavior, but clearly
wasn't. We have some low level framework behavior keyed off the type of instance constructed,
so we'd like to make sure this is the intended switch for PHP 8.



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=79975&edit=1


Thread (11 messages)

« previous php.bugs (#228586) next »