Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@
/tools/phpstan/*
!/tools/phpstan/composer.json
!/tools/phpstan/phpstan.neon
!/tools/phpstan/src/
2 changes: 2 additions & 0 deletions src/Clock.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ interface Clock
{
/**
* Returns the current time.
*
* @phpstan-impure
*/
public function getTime(): Instant;
}
10 changes: 10 additions & 0 deletions src/Clock/FixedClock.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,35 @@ final class FixedClock implements Clock
{
/**
* @param Instant $instant The time to set the clock at.
*
* @phpstan-pure
*/
public function __construct(
private Instant $instant,
) {
}

/**
* @phpstan-pure
*/
#[Override]
public function getTime(): Instant
{
return $this->instant;
}

/**
* @phpstan-impure
*/
public function setTime(Instant $instant): void
{
$this->instant = $instant;
}

/**
* Moves the clock by a number of seconds and/or nanos.
*
* @phpstan-impure
*/
public function move(int $seconds, int $nanos = 0): void
{
Expand Down
2 changes: 2 additions & 0 deletions src/Clock/OffsetClock.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
/**
* @param Clock $referenceClock The reference clock.
* @param Duration $offset The offset to apply to the clock.
*
* @phpstan-pure
*/
public function __construct(
private Clock $referenceClock,
Expand Down
2 changes: 2 additions & 0 deletions src/Clock/ScaleClock.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

/**
* This clock makes the time move at a given pace.
*
* @phpstan-all-methods-impure
*/
final readonly class ScaleClock implements Clock
{
Expand Down
2 changes: 2 additions & 0 deletions src/DateTimeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

/**
* This exception is used to indicate problems with creating, querying and manipulating date-time objects.
*
* @phpstan-all-methods-pure
*/
class DateTimeException extends RuntimeException
{
Expand Down
4 changes: 4 additions & 0 deletions src/DayOfWeek.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

/**
* Represents a day-of-week such as Tuesday.
*
* @phpstan-all-methods-pure
*/
enum DayOfWeek: int implements JsonSerializable
{
Expand All @@ -24,6 +26,8 @@ enum DayOfWeek: int implements JsonSerializable
* Returns the current day-of-week in the given time-zone, according to the given clock.
*
* If no clock is provided, the system clock is used.
*
* @phpstan-impure
*/
public static function now(TimeZone $timeZone, ?Clock $clock = null): DayOfWeek
{
Expand Down
4 changes: 4 additions & 0 deletions src/DefaultClock.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@
* This is where the default clock is set for all methods such as `now()`.
*
* The default clock is the system clock by default, but can be changed for testing.
*
* @phpstan-all-methods-impure
*/
final class DefaultClock
{
private static ?Clock $clock = null;

/**
* Private constructor. This class is not instantiable.
*
* @phpstan-pure
*/
private function __construct()
{
Expand Down
2 changes: 2 additions & 0 deletions src/Duration.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
* Represents a duration of time measured in seconds.
*
* This class is immutable.
*
* @phpstan-all-methods-pure
*/
final readonly class Duration implements JsonSerializable, Stringable
{
Expand Down
4 changes: 4 additions & 0 deletions src/Field/DayOfMonth.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

/**
* The day-of-month field.
*
* @phpstan-all-methods-pure
*/
final class DayOfMonth
{
Expand All @@ -29,6 +31,8 @@ final class DayOfMonth
* @throws DateTimeException If the day-of-month is not valid.
*
* @phpstan-assert int<1, 31> $dayOfMonth
*
* @phpstan-pure
*/
public static function check(int $dayOfMonth, ?int $monthOfYear = null, ?int $year = null): void
{
Expand Down
4 changes: 4 additions & 0 deletions src/Field/DayOfWeek.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

/**
* The day-of-week field.
*
* @phpstan-all-methods-pure
*/
final class DayOfWeek
{
Expand All @@ -22,6 +24,8 @@ final class DayOfWeek
* @throws DateTimeException If the day-of-week is not valid.
*
* @phpstan-assert int<1, 7> $dayOfWeek
*
* @phpstan-pure
*/
public static function check(int $dayOfWeek): void
{
Expand Down
4 changes: 4 additions & 0 deletions src/Field/DayOfYear.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

/**
* The day-of-year field.
*
* @phpstan-all-methods-pure
*/
final class DayOfYear
{
Expand All @@ -23,6 +25,8 @@ final class DayOfYear
* @throws DateTimeException If the day-of-year is not valid.
*
* @phpstan-assert int<1, 366> $dayOfYear
*
* @phpstan-pure
*/
public static function check(int $dayOfYear, ?int $year = null): void
{
Expand Down
2 changes: 2 additions & 0 deletions src/Field/FractionOfSecond.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
* This is used together with nano-of-second: fraction-of-second is used during parsing
* as its length can range anywhere from 1 to 9; the number is then padded right with
* zeros to make it 9 digits long, effectively becoming a nano-of-second.
*
* @phpstan-all-methods-pure
*/
final class FractionOfSecond
{
Expand Down
4 changes: 4 additions & 0 deletions src/Field/HourOfDay.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

/**
* The hour-of-day field.
*
* @phpstan-all-methods-pure
*/
final class HourOfDay
{
Expand All @@ -25,6 +27,8 @@ final class HourOfDay
* @param int $hourOfDay The hour-of-day to check.
*
* @throws DateTimeException If the hour-of-day is not valid.
*
* @phpstan-pure
*/
public static function check(int $hourOfDay): void
{
Expand Down
4 changes: 4 additions & 0 deletions src/Field/MinuteOfHour.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

/**
* The minute-of-hour field.
*
* @phpstan-all-methods-pure
*/
final class MinuteOfHour
{
Expand All @@ -25,6 +27,8 @@ final class MinuteOfHour
* @param int $minuteOfHour The minute-of-hour to check.
*
* @throws DateTimeException If the minute-of-hour is not valid.
*
* @phpstan-pure
*/
public static function check(int $minuteOfHour): void
{
Expand Down
4 changes: 4 additions & 0 deletions src/Field/MonthOfYear.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

/**
* The month-of-year field.
*
* @phpstan-all-methods-pure
*/
final class MonthOfYear
{
Expand All @@ -27,6 +29,8 @@ final class MonthOfYear
* @throws DateTimeException If the month-of-year is not valid.
*
* @phpstan-assert int<1, 12> $monthOfYear
*
* @phpstan-pure
*/
public static function check(int $monthOfYear): void
{
Expand Down
4 changes: 4 additions & 0 deletions src/Field/NanoOfSecond.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

/**
* The nano-of-second field.
*
* @phpstan-all-methods-pure
*/
final class NanoOfSecond
{
Expand All @@ -20,6 +22,8 @@ final class NanoOfSecond
* @param int $nanoOfSecond The nano-of-second to check.
*
* @throws DateTimeException If the nano-of-second is not valid.
*
* @phpstan-pure
*/
public static function check(int $nanoOfSecond): void
{
Expand Down
4 changes: 4 additions & 0 deletions src/Field/SecondOfDay.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

/**
* The second-of-day field.
*
* @phpstan-all-methods-pure
*/
final class SecondOfDay
{
Expand All @@ -20,6 +22,8 @@ final class SecondOfDay
* @param int $secondOfDay The second-of-day to check.
*
* @throws DateTimeException If the second-of-day is not valid.
*
* @phpstan-pure
*/
public static function check(int $secondOfDay): void
{
Expand Down
4 changes: 4 additions & 0 deletions src/Field/SecondOfMinute.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

/**
* The second-of-minute field.
*
* @phpstan-all-methods-pure
*/
final class SecondOfMinute
{
Expand All @@ -25,6 +27,8 @@ final class SecondOfMinute
* @param int $secondOfMinute The second-of-minute to check.
*
* @throws DateTimeException If the second-of-minute is not valid.
*
* @phpstan-pure
*/
public static function check(int $secondOfMinute): void
{
Expand Down
4 changes: 4 additions & 0 deletions src/Field/TimeZoneOffsetHour.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

/**
* The hour part of the time-zone offset.
*
* @phpstan-all-methods-pure
*/
final class TimeZoneOffsetHour
{
Expand All @@ -25,6 +27,8 @@ final class TimeZoneOffsetHour
* @param int $offsetHour The offset-hour to check.
*
* @throws DateTimeException If the offset-hour is not valid.
*
* @phpstan-pure
*/
public static function check(int $offsetHour): void
{
Expand Down
4 changes: 4 additions & 0 deletions src/Field/TimeZoneOffsetMinute.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

/**
* The minute part of the time-zone offset.
*
* @phpstan-all-methods-pure
*/
final class TimeZoneOffsetMinute
{
Expand All @@ -25,6 +27,8 @@ final class TimeZoneOffsetMinute
* @param int $offsetMinute The offset-minute to check.
*
* @throws DateTimeException If the offset-minute is not valid.
*
* @phpstan-pure
*/
public static function check(int $offsetMinute): void
{
Expand Down
4 changes: 4 additions & 0 deletions src/Field/TimeZoneOffsetSecond.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

/**
* The second part of the time-zone offset.
*
* @phpstan-all-methods-pure
*/
final class TimeZoneOffsetSecond
{
Expand All @@ -25,6 +27,8 @@ final class TimeZoneOffsetSecond
* @param int $offsetSecond The offset-second to check.
*
* @throws DateTimeException If the offset-second is not valid.
*
* @phpstan-pure
*/
public static function check(int $offsetSecond): void
{
Expand Down
2 changes: 2 additions & 0 deletions src/Field/TimeZoneOffsetSign.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

/**
* The time-zone offset sign, '+', '-', 'Z' or 'z'.
*
* @phpstan-all-methods-pure
*/
final class TimeZoneOffsetSign
{
Expand Down
4 changes: 4 additions & 0 deletions src/Field/TimeZoneOffsetTotalSeconds.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
* The total number of seconds in a time-zone offset, from -64800 to 64800 (-18:00 to +18:00).
*
* The offset is relative to UTC/Greenwich.
*
* @phpstan-all-methods-pure
*/
final class TimeZoneOffsetTotalSeconds
{
Expand All @@ -27,6 +29,8 @@ final class TimeZoneOffsetTotalSeconds
* @param int $offsetSeconds The offset-seconds to check.
*
* @throws DateTimeException If the offset-seconds is not valid.
*
* @phpstan-pure
*/
public static function check(int $offsetSeconds): void
{
Expand Down
2 changes: 2 additions & 0 deletions src/Field/TimeZoneRegion.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

/**
* The time-zone region, such as 'Europe/London'.
*
* @phpstan-all-methods-pure
*/
final class TimeZoneRegion
{
Expand Down
Loading
Loading