Skip to content

Commit 37b3092

Browse files
committed
Fix more specific return type hints for some ext/date methods
Ideally, these methods should have been declared with a static return type, so let's add a PHPDoc type hint + a TODO for fixing the issue in the future.
1 parent f06fb22 commit 37b3092

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

ext/date/php_date.stub.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -225,10 +225,14 @@ public function __wakeup(): void {}
225225
/** @tentative-return-type */
226226
public static function __set_state(array $array): DateTime {}
227227

228-
/** @tentative-return-type */
229-
public static function createFromImmutable(DateTimeImmutable $object): DateTime {}
228+
/**
229+
* @tentative-return-type
230+
* @return static
231+
*/
232+
public static function createFromImmutable(DateTimeImmutable $object): DateTime {} // TODO return type should be static
230233

231-
public static function createFromInterface(DateTimeInterface $object): DateTime {}
234+
/** @return static */
235+
public static function createFromInterface(DateTimeInterface $object): DateTime {} // TODO return type should be static
232236

233237
/**
234238
* @tentative-return-type
@@ -403,10 +407,14 @@ public function setISODate(int $year, int $week, int $dayOfWeek = 1): DateTimeIm
403407
/** @tentative-return-type */
404408
public function setTimestamp(int $timestamp): DateTimeImmutable {}
405409

406-
/** @tentative-return-type */
407-
public static function createFromMutable(DateTime $object): DateTimeImmutable {}
410+
/**
411+
* @tentative-return-type
412+
* @return static
413+
*/
414+
public static function createFromMutable(DateTime $object): DateTimeImmutable {} // TODO return type should be static
408415

409-
public static function createFromInterface(DateTimeInterface $object): DateTimeImmutable {}
416+
/** @return static */
417+
public static function createFromInterface(DateTimeInterface $object): DateTimeImmutable {} // TODO return type should be static
410418
}
411419

412420
class DateTimeZone

ext/date/php_date_arginfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: db6fd5b6c366dd8ee48ead99d235baa86e564401 */
2+
* Stub hash: 86c6321ad1dc6f0efe94669dc6fd759752c32302 */
33

44
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_strtotime, 0, 1, MAY_BE_LONG|MAY_BE_FALSE)
55
ZEND_ARG_TYPE_INFO(0, datetime, IS_STRING, 0)

0 commit comments

Comments
 (0)