1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Merge pull request #9220 from othercorey/dateperiod-end

closes https://github.com/vimeo/psalm/issues/9147
This commit is contained in:
Bruce Weirdan 2023-02-03 16:02:59 -04:00 committed by GitHub
commit 498cc45e90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 2 deletions

View File

@ -220,12 +220,12 @@ class DatePeriod implements IteratorAggregate
/** /**
* @param Start $start * @param Start $start
* @param (Start is string ? 0|self::EXCLUDE_START_DATE : DateInterval) $interval * @param (Start is string ? 0|self::EXCLUDE_START_DATE : DateInterval) $interval
* @param (Start is string ? never : DateTimeInterface|positive-int) $end * @param (Start is string ? never : (DateTimeInterface|positive-int)) $end
* @param (Start is string ? never : 0|self::EXCLUDE_START_DATE) $options * @param (Start is string ? never : 0|self::EXCLUDE_START_DATE) $options
*/ */
public function __construct($start, $interval = 0, $end = 1, $options = 0) {} public function __construct($start, $interval = 0, $end = 1, $options = 0) {}
/** @psalm-return (Start is string ? (Traversable<int, DateTime>&Iterator) : (Traversable<int, Start>&Iterator)) */ /** @psalm-return (Start is string ? Iterator<int, DateTime> : Iterator<int, Start>) */
public function getIterator(): Iterator {} public function getIterator(): Iterator {}
} }

View File

@ -10,4 +10,27 @@ namespace {
/** @return non-empty-list<ReflectionNamedType|ReflectionIntersectionType> */ /** @return non-empty-list<ReflectionNamedType|ReflectionIntersectionType> */
public function getTypes(): array {} public function getTypes(): array {}
} }
/**
* @psalm-immutable
*
* @template-covariant Start of string|DateTimeInterface
* @implements IteratorAggregate<int, DateTimeInterface>
*/
class DatePeriod implements IteratorAggregate
{
const EXCLUDE_START_DATE = 1;
const INCLUDE_END_DATE = 2;
/**
* @param Start $start
* @param (Start is string ? int-mask<self::EXCLUDE_START_DATE, self::INCLUDE_END_DATE> : DateInterval) $interval
* @param (Start is string ? never : (DateTimeInterface|positive-int)) $end
* @param (Start is string ? never : int-mask<self::EXCLUDE_START_DATE, self::INCLUDE_END_DATE>) $options
*/
public function __construct($start, $interval = 0, $end = 1, $options = 0) {}
/** @psalm-return (Start is string ? Iterator<int, DateTime> : Iterator<int, Start>) */
public function getIterator(): Iterator {}
}
} }