From e98ed1657721a5282ce457f1bad0045deb36dd13 Mon Sep 17 00:00:00 2001 From: George Steel Date: Sat, 9 Sep 2023 23:26:55 +0100 Subject: [PATCH] `DateTimeZone::getName()` always returns `non-empty-string` and cannot be constructed with an empty string Signed-off-by: George Steel --- dictionaries/CallMap.php | 4 ++-- dictionaries/CallMap_historical.php | 4 ++-- stubs/CoreImmutableClasses.phpstub | 1 + tests/PureAnnotationTest.php | 5 ++++- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/dictionaries/CallMap.php b/dictionaries/CallMap.php index 8c77bba5218..947f1789ac4 100644 --- a/dictionaries/CallMap.php +++ b/dictionaries/CallMap.php @@ -1390,11 +1390,11 @@ 'DateTimeInterface::getTimezone' => ['DateTimeZone|false'], 'DateTimeInterface::__serialize' => ['array'], 'DateTimeInterface::__unserialize' => ['void', 'data'=>'array'], -'DateTimeZone::__construct' => ['void', 'timezone'=>'string'], +'DateTimeZone::__construct' => ['void', 'timezone'=>'non-empty-string'], 'DateTimeZone::__set_state' => ['DateTimeZone', 'array'=>'array'], 'DateTimeZone::__wakeup' => ['void'], 'DateTimeZone::getLocation' => ['array|false'], -'DateTimeZone::getName' => ['string'], +'DateTimeZone::getName' => ['non-empty-string'], 'DateTimeZone::getOffset' => ['int', 'datetime'=>'DateTimeInterface'], 'DateTimeZone::getTransitions' => ['list|false', 'timestampBegin='=>'int', 'timestampEnd='=>'int'], 'DateTimeZone::listAbbreviations' => ['array>'], diff --git a/dictionaries/CallMap_historical.php b/dictionaries/CallMap_historical.php index 1e3e862ac3e..cdefa273d5b 100644 --- a/dictionaries/CallMap_historical.php +++ b/dictionaries/CallMap_historical.php @@ -847,11 +847,11 @@ 'DateTimeInterface::getOffset' => ['int'], 'DateTimeInterface::getTimestamp' => ['int|false'], 'DateTimeInterface::getTimezone' => ['DateTimeZone|false'], - 'DateTimeZone::__construct' => ['void', 'timezone'=>'string'], + 'DateTimeZone::__construct' => ['void', 'timezone'=>'non-empty-string'], 'DateTimeZone::__set_state' => ['DateTimeZone', 'array'=>'array'], 'DateTimeZone::__wakeup' => ['void'], 'DateTimeZone::getLocation' => ['array|false'], - 'DateTimeZone::getName' => ['string'], + 'DateTimeZone::getName' => ['non-empty-string'], 'DateTimeZone::getOffset' => ['int|false', 'datetime'=>'DateTimeInterface'], 'DateTimeZone::getTransitions' => ['list|false', 'timestampBegin='=>'int', 'timestampEnd='=>'int'], 'DateTimeZone::listAbbreviations' => ['array>'], diff --git a/stubs/CoreImmutableClasses.phpstub b/stubs/CoreImmutableClasses.phpstub index 91c0a41c69c..8698d1151ca 100644 --- a/stubs/CoreImmutableClasses.phpstub +++ b/stubs/CoreImmutableClasses.phpstub @@ -105,6 +105,7 @@ class DateTimeImmutable implements DateTimeInterface */ class DateTimeZone { + /** @param non-empty-string $timezone */ public function __construct(string $timezone) {} } diff --git a/tests/PureAnnotationTest.php b/tests/PureAnnotationTest.php index 11f3a99422c..f27632baed6 100644 --- a/tests/PureAnnotationTest.php +++ b/tests/PureAnnotationTest.php @@ -152,7 +152,10 @@ function foo(array $arr) : array { 'code' => '