[php-src] Issue #10824: Calling `parent::` static method returns self instance

From: Date: Fri, 10 Mar 2023 14:05:36 +0000
Subject: [php-src] Issue #10824: Calling `parent::` static method returns self instance
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-243886@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/10824 Author: bburnichon ### Description The following code: ```php <?php class MyDateTime extends DateTimeImmutable { public static function createFromFormat($format, $time, $timezone = null): self { $instance = parent::createFromFormat($format, $time, $timezone); var_dump($instance); return new self($instance->format('Y-m-d H:i:s.u'), $instance->getTimezone()); } } $now = MyDateTime::createFromFormat('U.u', '1678119664.436');``` Resulted in this output: ``` object(MyDateTime)#1 (3) { ["date"]=> string(26) "2023-03-06 16:21:04.436000" ["timezone_type"]=> int(1) ["timezone"]=> string(6) "+00:00" } ``` But I expected this output instead: ``` object(DateTimeImmutable)#1 (3) { ["date"]=> string(26) "2023-03-06 16:21:04.436000" ["timezone_type"]=> int(1) ["timezone"]=> string(6) "+00:00" } ``` See results on https://3v4l.org/e8OHM ### PHP Version PHP > 8.0.0 ### Operating System Ubuntu

« previous php.bugs (#243886) next »