[php-src] master: ext/date: Change return type to static (#23317)
| From: | Arshid via GitHub | Date: | Thu, 17 Sep 2026 20:44:07 +0000 |
| Subject: | [php-src] master: ext/date: Change return type to static (#23317) | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-141257@lists.php.net to get a copy of this message | ||
Author: Arshid (arshidkv12)
Committer: GitHub (web-flow)
Pusher: kocsismate
Date: 2026-09-17T22:44:04+02:00
Commit: https://github.com/php/php-src/commit/8b005d47025e4c54aed27f4ff6374bed7ca0206f
Raw diff: https://github.com/php/php-src/commit/8b005d47025e4c54aed27f4ff6374bed7ca0206f.diff
ext/date: Change return type to static (#23317)
Changed paths:
M UPGRADING
M ext/date/php_date.stub.php
M ext/date/php_date_arginfo.h
Diff:
diff --git a/UPGRADING b/UPGRADING
index 2d1ecc641668..835e48868877 100644
--- a/UPGRADING
+++ b/UPGRADING
@@ -616,6 +616,23 @@ PHP 8.6 UPGRADE NOTES
* SplFileObject::getCsvControl()
RFC: https://wiki.php.net/rfc/deprecations_php_8_6#deprecate_splfileobject_csv_methods
+- Date:
+ . The following DateTime, DateTimeImmutable, DateTimeZone, DateInterval, and DatePeriod methods
now have tentative static return types:
+ DateTime::createFromInterface()
+ DateTimeImmutable::__set_state()
+ DateTimeImmutable::modify()
+ DateTimeImmutable::add()
+ DateTimeImmutable::sub()
+ DateTimeImmutable::setTimezone()
+ DateTimeImmutable::setTime()
+ DateTimeImmutable::setDate()
+ DateTimeImmutable::setISODate()
+ DateTimeImmutable::setTimestamp()
+ DateTimeImmutable::createFromInterface()
+ DateTimeZone::__set_state()
+ DateInterval::__set_state()
+ DatePeriod::__set_state()
+
- Standard:
. metaphone() is deprecated.
Please use a userland phonetic matching library instead.
diff --git a/ext/date/php_date.stub.php b/ext/date/php_date.stub.php
index da2182dfb6fa..5ea2bb1bc5ee 100644
--- a/ext/date/php_date.stub.php
+++ b/ext/date/php_date.stub.php
@@ -349,8 +349,8 @@ public static function __set_state(array $array): DateTime {}
/** @tentative-return-type */
public static function createFromImmutable(DateTimeImmutable $object): static {}
- /** @return static */
- public static function createFromInterface(DateTimeInterface $object): DateTime {} // TODO
return type should be static
+ /** @tentative-return-type */
+ public static function createFromInterface(DateTimeInterface $object): static {}
/**
* @tentative-return-type
@@ -462,7 +462,7 @@ public function __unserialize(array $data): void {}
public function __wakeup(): void {}
/** @tentative-return-type */
- public static function __set_state(array $array): DateTimeImmutable {}
+ public static function __set_state(array $array): static {}
/**
* @tentative-return-type
@@ -517,35 +517,35 @@ public function diff(DateTimeInterface $targetObject, bool $absolute = false):
D
/** @tentative-return-type */
#[\NoDiscard(message: "as DateTimeImmutable::modify() does not modify the object
itself")]
- public function modify(string $modifier): DateTimeImmutable {}
+ public function modify(string $modifier): static {}
/** @tentative-return-type */
#[\NoDiscard(message: "as DateTimeImmutable::add() does not modify the object
itself")]
- public function add(DateInterval $interval): DateTimeImmutable {}
+ public function add(DateInterval $interval): static {}
/** @tentative-return-type */
#[\NoDiscard(message: "as DateTimeImmutable::sub() does not modify the object
itself")]
- public function sub(DateInterval $interval): DateTimeImmutable {}
+ public function sub(DateInterval $interval): static {}
/** @tentative-return-type */
#[\NoDiscard(message: "as DateTimeImmutable::setTimezone() does not modify the object
itself")]
- public function setTimezone(DateTimeZone $timezone): DateTimeImmutable {}
+ public function setTimezone(DateTimeZone $timezone): static {}
/** @tentative-return-type */
#[\NoDiscard(message: "as DateTimeImmutable::setTime() does not modify the object
itself")]
- public function setTime(int $hour, int $minute, int $second = 0, int $microsecond = 0):
DateTimeImmutable {}
+ public function setTime(int $hour, int $minute, int $second = 0, int $microsecond = 0): static
{}
/** @tentative-return-type */
#[\NoDiscard(message: "as DateTimeImmutable::setDate() does not modify the object
itself")]
- public function setDate(int $year, int $month, int $day): DateTimeImmutable {}
+ public function setDate(int $year, int $month, int $day): static {}
/** @tentative-return-type */
#[\NoDiscard(message: "as DateTimeImmutable::setISODate() does not modify the object
itself")]
- public function setISODate(int $year, int $week, int $dayOfWeek = 1): DateTimeImmutable {}
+ public function setISODate(int $year, int $week, int $dayOfWeek = 1): static {}
/** @tentative-return-type */
#[\NoDiscard(message: "as DateTimeImmutable::setTimestamp() does not modify the object
itself")]
- public function setTimestamp(int $timestamp): DateTimeImmutable {}
+ public function setTimestamp(int $timestamp): static {}
#[\NoDiscard(message: "as DateTimeImmutable::setMicrosecond() does not modify the object
itself")]
public function setMicrosecond(int $microsecond): static {}
@@ -553,8 +553,8 @@ public function setMicrosecond(int $microsecond): static {}
/** @tentative-return-type */
public static function createFromMutable(DateTime $object): static {}
- /** @return static */
- public static function createFromInterface(DateTimeInterface $object): DateTimeImmutable {} //
TODO return type should be static
+ /** @tentative-return-type */
+ public static function createFromInterface(DateTimeInterface $object): static {}
}
class DateTimeZone
@@ -639,7 +639,7 @@ public function __unserialize(array $data): void {}
public function __wakeup(): void {}
/** @tentative-return-type */
- public static function __set_state(array $array): DateTimeZone {}
+ public static function __set_state(array $array): static {}
}
class DateInterval
@@ -666,7 +666,7 @@ public function __unserialize(array $data): void;
public function __wakeup(): void {}
/** @tentative-return-type */
- public static function __set_state(array $array): DateInterval {}
+ public static function __set_state(array $array): static {}
}
class DatePeriod implements IteratorAggregate
@@ -743,7 +743,7 @@ public function __unserialize(array $data): void;
public function __wakeup(): void {}
/** @tentative-return-type */
- public static function __set_state(array $array): DatePeriod {}
+ public static function __set_state(array $array): static {}
public function getIterator(): Iterator {}
}
diff --git a/ext/date/php_date_arginfo.h b/ext/date/php_date_arginfo.h
index ce72ee903d96..7dc1061446c5 100644
--- a/ext/date/php_date_arginfo.h
+++ b/ext/date/php_date_arginfo.h
@@ -1,5 +1,5 @@
/* This is a generated file, edit php_date.stub.php instead.
- * Stub hash: 8556e1b5f05ae9f78200f05f01d9f8e815cba49d */
+ * Stub hash: f82824bc7dc4c7672f03d3c2698c6a958a730fa8 */
#include "zend_attributes.h"
#include "zend_constants.h"
@@ -275,7 +275,7 @@ ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_DateTime_createF
ZEND_ARG_OBJ_INFO(0, object, DateTimeImmutable, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_DateTime_createFromInterface, 0, 1, DateTime,
0)
+ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_DateTime_createFromInterface, 0, 1,
IS_STATIC, 0)
ZEND_ARG_OBJ_INFO(0, object, DateTimeInterface, 0)
ZEND_END_ARG_INFO()
@@ -353,7 +353,7 @@ ZEND_END_ARG_INFO()
#define arginfo_class_DateTimeImmutable___wakeup arginfo_class_DateTimeInterface___wakeup
-ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_OBJ_INFO_EX(arginfo_class_DateTimeImmutable___set_state, 0, 1,
DateTimeImmutable, 0)
+ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_DateTimeImmutable___set_state, 0,
1, IS_STATIC, 0)
ZEND_ARG_TYPE_INFO(0, array, IS_ARRAY, 0)
ZEND_END_ARG_INFO()
@@ -379,40 +379,40 @@ ZEND_END_ARG_INFO()
#define arginfo_class_DateTimeImmutable_diff arginfo_class_DateTimeInterface_diff
-ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_OBJ_INFO_EX(arginfo_class_DateTimeImmutable_modify, 0, 1,
DateTimeImmutable, 0)
+ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_DateTimeImmutable_modify, 0, 1,
IS_STATIC, 0)
ZEND_ARG_TYPE_INFO(0, modifier, IS_STRING, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_OBJ_INFO_EX(arginfo_class_DateTimeImmutable_add, 0, 1,
DateTimeImmutable, 0)
+ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_DateTimeImmutable_add, 0, 1,
IS_STATIC, 0)
ZEND_ARG_OBJ_INFO(0, interval, DateInterval, 0)
ZEND_END_ARG_INFO()
#define arginfo_class_DateTimeImmutable_sub arginfo_class_DateTimeImmutable_add
-ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_OBJ_INFO_EX(arginfo_class_DateTimeImmutable_setTimezone, 0, 1,
DateTimeImmutable, 0)
+ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_DateTimeImmutable_setTimezone, 0,
1, IS_STATIC, 0)
ZEND_ARG_OBJ_INFO(0, timezone, DateTimeZone, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_OBJ_INFO_EX(arginfo_class_DateTimeImmutable_setTime, 0, 2,
DateTimeImmutable, 0)
+ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_DateTimeImmutable_setTime, 0, 2,
IS_STATIC, 0)
ZEND_ARG_TYPE_INFO(0, hour, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, minute, IS_LONG, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, second, IS_LONG, 0, "0")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, microsecond, IS_LONG, 0, "0")
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_OBJ_INFO_EX(arginfo_class_DateTimeImmutable_setDate, 0, 3,
DateTimeImmutable, 0)
+ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_DateTimeImmutable_setDate, 0, 3,
IS_STATIC, 0)
ZEND_ARG_TYPE_INFO(0, year, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, month, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, day, IS_LONG, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_OBJ_INFO_EX(arginfo_class_DateTimeImmutable_setISODate, 0, 2,
DateTimeImmutable, 0)
+ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_DateTimeImmutable_setISODate, 0, 2,
IS_STATIC, 0)
ZEND_ARG_TYPE_INFO(0, year, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, week, IS_LONG, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, dayOfWeek, IS_LONG, 0, "1")
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_OBJ_INFO_EX(arginfo_class_DateTimeImmutable_setTimestamp, 0,
1, DateTimeImmutable, 0)
+ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_DateTimeImmutable_setTimestamp, 0,
1, IS_STATIC, 0)
ZEND_ARG_TYPE_INFO(0, timestamp, IS_LONG, 0)
ZEND_END_ARG_INFO()
@@ -422,9 +422,7 @@ ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_DateTimeImmutabl
ZEND_ARG_OBJ_INFO(0, object, DateTime, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_DateTimeImmutable_createFromInterface, 0, 1,
DateTimeImmutable, 0)
- ZEND_ARG_OBJ_INFO(0, object, DateTimeInterface, 0)
-ZEND_END_ARG_INFO()
+#define arginfo_class_DateTimeImmutable_createFromInterface
arginfo_class_DateTime_createFromInterface
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_DateTimeZone___construct, 0, 0, 1)
ZEND_ARG_TYPE_INFO(0, timezone, IS_STRING, 0)
@@ -458,9 +456,7 @@ ZEND_END_ARG_INFO()
#define arginfo_class_DateTimeZone___wakeup arginfo_class_DateTimeInterface___wakeup
-ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_OBJ_INFO_EX(arginfo_class_DateTimeZone___set_state, 0, 1,
DateTimeZone, 0)
- ZEND_ARG_TYPE_INFO(0, array, IS_ARRAY, 0)
-ZEND_END_ARG_INFO()
+#define arginfo_class_DateTimeZone___set_state arginfo_class_DateTimeImmutable___set_state
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_DateInterval___construct, 0, 0, 1)
ZEND_ARG_TYPE_INFO(0, duration, IS_STRING, 0)
@@ -478,9 +474,7 @@ ZEND_END_ARG_INFO()
#define arginfo_class_DateInterval___wakeup arginfo_class_DateTimeInterface___wakeup
-ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_OBJ_INFO_EX(arginfo_class_DateInterval___set_state, 0, 1,
DateInterval, 0)
- ZEND_ARG_TYPE_INFO(0, array, IS_ARRAY, 0)
-ZEND_END_ARG_INFO()
+#define arginfo_class_DateInterval___set_state arginfo_class_DateTimeImmutable___set_state
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_DatePeriod_createFromISO8601String, 0, 1,
IS_STATIC, 0)
ZEND_ARG_TYPE_INFO(0, specification, IS_STRING, 0)
@@ -512,9 +506,7 @@ ZEND_END_ARG_INFO()
#define arginfo_class_DatePeriod___wakeup arginfo_class_DateTimeInterface___wakeup
-ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_OBJ_INFO_EX(arginfo_class_DatePeriod___set_state, 0, 1,
DatePeriod, 0)
- ZEND_ARG_TYPE_INFO(0, array, IS_ARRAY, 0)
-ZEND_END_ARG_INFO()
+#define arginfo_class_DatePeriod___set_state arginfo_class_DateTimeImmutable___set_state
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_DatePeriod_getIterator, 0, 0, Iterator, 0)
ZEND_END_ARG_INFO()