Skip to content

Commit

Permalink
Readonly properties
Browse files Browse the repository at this point in the history
  • Loading branch information
BenMorel committed Oct 17, 2023
1 parent c3a7c3e commit 8fcf8d5
Show file tree
Hide file tree
Showing 20 changed files with 43 additions and 43 deletions.
4 changes: 2 additions & 2 deletions src/Clock/OffsetClock.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ final class OffsetClock implements Clock
/**
* The reference clock.
*/
private Clock $referenceClock;
private readonly Clock $referenceClock;

/**
* The offset to apply to the clock.
*/
private Duration $offset;
private readonly Duration $offset;

/**
* @param Clock $referenceClock The reference clock.
Expand Down
6 changes: 3 additions & 3 deletions src/Clock/ScaleClock.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ final class ScaleClock implements Clock
/**
* The reference clock.
*/
private Clock $referenceClock;
private readonly Clock $referenceClock;

/**
* The start time.
*/
private Instant $startTime;
private readonly Instant $startTime;

/**
* The time scale.
*/
private int $timeScale;
private readonly int $timeScale;

/**
* - a scale > 1 makes the time move at an accelerated pace;
Expand Down
4 changes: 2 additions & 2 deletions src/Duration.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ final class Duration implements JsonSerializable, Stringable
/**
* The duration in seconds.
*/
private int $seconds;
private readonly int $seconds;

/**
* The nanoseconds adjustment to the duration, in the range 0 to 999,999,999.
*
* A duration of -1 nanoseconds is stored as -1 seconds plus 999,999,999 nanoseconds.
*/
private int $nanos;
private readonly int $nanos;

/**
* Private constructor. Use one of the factory methods to obtain a Duration.
Expand Down
4 changes: 2 additions & 2 deletions src/Instant.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ final class Instant implements JsonSerializable, Stringable
/**
* The number of seconds since the epoch of 1970-01-01T00:00:00Z.
*/
private int $epochSecond;
private readonly int $epochSecond;

/**
* The nanoseconds adjustment to the epoch second, in the range 0 to 999,999,999.
*/
private int $nano;
private readonly int $nano;

/**
* Private constructor. Use of() to obtain an Instant.
Expand Down
4 changes: 2 additions & 2 deletions src/Interval.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ final class Interval implements JsonSerializable, Stringable
/**
* The start instant, inclusive.
*/
private Instant $start;
private readonly Instant $start;

/**
* The end instant, exclusive.
*/
private Instant $end;
private readonly Instant $end;

/**
* @param Instant $startInclusive The start instant, inclusive.
Expand Down
6 changes: 3 additions & 3 deletions src/LocalDate.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,17 @@ final class LocalDate implements JsonSerializable, Stringable
/**
* The year.
*/
private int $year;
private readonly int $year;

/**
* The month-of-year.
*/
private int $month;
private readonly int $month;

/**
* The day-of-month.
*/
private int $day;
private readonly int $day;

/**
* Private constructor. Use of() to obtain an instance.
Expand Down
4 changes: 2 additions & 2 deletions src/LocalDateRange.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ final class LocalDateRange implements IteratorAggregate, Countable, JsonSerializ
/**
* The start date, inclusive.
*/
private LocalDate $start;
private readonly LocalDate $start;

/**
* The end date, inclusive.
*/
private LocalDate $end;
private readonly LocalDate $end;

/**
* @param LocalDate $start The start date, inclusive.
Expand Down
4 changes: 2 additions & 2 deletions src/LocalDateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
*/
final class LocalDateTime implements JsonSerializable, Stringable
{
private LocalDate $date;
private readonly LocalDate $date;

private LocalTime $time;
private readonly LocalTime $time;

public function __construct(LocalDate $date, LocalTime $time)
{
Expand Down
8 changes: 4 additions & 4 deletions src/LocalTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,22 @@ final class LocalTime implements JsonSerializable, Stringable
/**
* The hour, in the range 0 to 23.
*/
private int $hour;
private readonly int $hour;

/**
* The minute, in the range 0 to 59.
*/
private int $minute;
private readonly int $minute;

/**
* The second, in the range 0 to 59.
*/
private int $second;
private readonly int $second;

/**
* The nanosecond, in the range 0 to 999,999,999.
*/
private int $nano;
private readonly int $nano;

/**
* Private constructor. Use of() to obtain an instance.
Expand Down
4 changes: 2 additions & 2 deletions src/MonthDay.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ final class MonthDay implements JsonSerializable, Stringable
/**
* The month-of-year, from 1 to 12.
*/
private int $month;
private readonly int $month;

/**
* The day-of-month, from 1 to 31.
*/
private int $day;
private readonly int $day;

/**
* Private constructor. Use of() to obtain an instance.
Expand Down
4 changes: 2 additions & 2 deletions src/Parser/PatternParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
*/
final class PatternParser implements DateTimeParser
{
private string $pattern;
private readonly string $pattern;

/**
* @var string[]
*/
private array $fields;
private readonly array $fields;

/**
* @param string $pattern The regular expression pattern.
Expand Down
6 changes: 3 additions & 3 deletions src/Period.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
*/
final class Period implements JsonSerializable, Stringable
{
private int $years;
private readonly int $years;

private int $months;
private readonly int $months;

private int $days;
private readonly int $days;

/**
* Private constructor. Use of() to obtain an instance.
Expand Down
2 changes: 1 addition & 1 deletion src/Stopwatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
final class Stopwatch
{
private Clock $clock;
private readonly Clock $clock;

/**
* The total time the stopwatch has been running, excluding the time elapsed since it was started.
Expand Down
2 changes: 1 addition & 1 deletion src/TimeZoneOffset.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
final class TimeZoneOffset extends TimeZone
{
private int $totalSeconds;
private readonly int $totalSeconds;

/**
* The string representation of this time-zone offset.
Expand Down
2 changes: 1 addition & 1 deletion src/TimeZoneRegion.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
final class TimeZoneRegion extends TimeZone
{
private DateTimeZone $zone;
private readonly DateTimeZone $zone;

/**
* Private constructor. Use a factory method to obtain an instance.
Expand Down
2 changes: 1 addition & 1 deletion src/Year.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ final class Year implements JsonSerializable, Stringable
/**
* The year being represented.
*/
private int $year;
private readonly int $year;

/**
* @param int $year The year to represent, validated.
Expand Down
4 changes: 2 additions & 2 deletions src/YearMonth.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ final class YearMonth implements JsonSerializable, Stringable
/**
* The year, from MIN_YEAR to MAX_YEAR.
*/
private int $year;
private readonly int $year;

/**
* The month, from 1 to 12.
*/
private int $month;
private readonly int $month;

/**
* @param int $year The year, validated from MIN_YEAR to MAX_YEAR.
Expand Down
4 changes: 2 additions & 2 deletions src/YearMonthRange.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ class YearMonthRange implements IteratorAggregate, Countable, JsonSerializable,
/**
* The start year-month, inclusive.
*/
private YearMonth $start;
private readonly YearMonth $start;

/**
* The end year-month, inclusive.
*/
private YearMonth $end;
private readonly YearMonth $end;

/**
* @param YearMonth $start The start year-month, inclusive.
Expand Down
4 changes: 2 additions & 2 deletions src/YearWeek.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ final class YearWeek implements JsonSerializable, Stringable
/**
* The year, from MIN_YEAR to MAX_YEAR.
*/
private int $year;
private readonly int $year;

/**
* The week number, from 1 to 53. Must be valid for the year.
*/
private int $week;
private readonly int $week;

/**
* @param int $year The year, validated from MIN_YEAR to MAX_YEAR.
Expand Down
8 changes: 4 additions & 4 deletions src/ZonedDateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,25 @@ class ZonedDateTime implements JsonSerializable, Stringable
/**
* The local date-time.
*/
private LocalDateTime $localDateTime;
private readonly LocalDateTime $localDateTime;

/**
* The time-zone offset from UTC/Greenwich.
*/
private TimeZoneOffset $timeZoneOffset;
private readonly TimeZoneOffset $timeZoneOffset;

/**
* The time-zone.
*
* It is either a TimeZoneRegion if this ZonedDateTime is region-based,
* or the same instance as the offset if this ZonedDateTime is offset-based.
*/
private TimeZone $timeZone;
private readonly TimeZone $timeZone;

/**
* The instant represented by this ZonedDateTime.
*/
private Instant $instant;
private readonly Instant $instant;

/**
* Private constructor. Use a factory method to obtain an instance.
Expand Down

0 comments on commit 8fcf8d5

Please sign in to comment.