Skip to content

Commit 694bc7e

Browse files
committed
Readonly classes
1 parent db2279e commit 694bc7e

17 files changed

+57
-57
lines changed

src/Clock/OffsetClock.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212
/**
1313
* This clock adds an offset to an underlying clock.
1414
*/
15-
final class OffsetClock implements Clock
15+
final readonly class OffsetClock implements Clock
1616
{
1717
/**
1818
* @param Clock $referenceClock The reference clock.
1919
* @param Duration $offset The offset to apply to the clock.
2020
*/
2121
public function __construct(
22-
private readonly Clock $referenceClock,
23-
private readonly Duration $offset,
22+
private Clock $referenceClock,
23+
private Duration $offset,
2424
) {
2525
}
2626

src/Clock/ScaleClock.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
/**
1313
* This clock makes the time move at a given pace.
1414
*/
15-
final class ScaleClock implements Clock
15+
final readonly class ScaleClock implements Clock
1616
{
1717
/**
1818
* The start time.
1919
*/
20-
private readonly Instant $startTime;
20+
private Instant $startTime;
2121

2222
/**
2323
* - a scale > 1 makes the time move at an accelerated pace;
@@ -29,8 +29,8 @@ final class ScaleClock implements Clock
2929
* @param int $timeScale The time scale.
3030
*/
3131
public function __construct(
32-
private readonly Clock $referenceClock,
33-
private readonly int $timeScale,
32+
private Clock $referenceClock,
33+
private int $timeScale,
3434
) {
3535
$this->startTime = $this->referenceClock->getTime();
3636
}

src/Duration.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
*
2424
* This class is immutable.
2525
*/
26-
final class Duration implements JsonSerializable, Stringable
26+
final readonly class Duration implements JsonSerializable, Stringable
2727
{
2828
/**
2929
* Private constructor. Use one of the factory methods to obtain a Duration.
@@ -33,8 +33,8 @@ final class Duration implements JsonSerializable, Stringable
3333
* A duration of -1 nanoseconds is stored as -1 seconds plus 999,999,999 nanoseconds.
3434
*/
3535
private function __construct(
36-
private readonly int $seconds,
37-
private readonly int $nanos = 0,
36+
private int $seconds,
37+
private int $nanos = 0,
3838
) {
3939
}
4040

src/Instant.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* without any calendar concept of date, time or time zone. It is not very meaningful to humans,
2424
* but can be converted to a `ZonedDateTime` by providing a time zone.
2525
*/
26-
final class Instant implements JsonSerializable, Stringable
26+
final readonly class Instant implements JsonSerializable, Stringable
2727
{
2828
/**
2929
* Private constructor. Use of() to obtain an Instant.
@@ -32,8 +32,8 @@ final class Instant implements JsonSerializable, Stringable
3232
* @param int $nano The nanosecond adjustment to the epoch second, validated in the range 0 to 999,999,999.
3333
*/
3434
private function __construct(
35-
private readonly int $epochSecond,
36-
private readonly int $nano,
35+
private int $epochSecond,
36+
private int $nano,
3737
) {
3838
}
3939

src/Interval.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414
*
1515
* This class is immutable.
1616
*/
17-
final class Interval implements JsonSerializable, Stringable
17+
final readonly class Interval implements JsonSerializable, Stringable
1818
{
1919
/**
2020
* @param Instant $start The start instant, inclusive.
2121
* @param Instant $end The end instant, exclusive, validated as not before the start instant.
2222
*/
2323
private function __construct(
24-
private readonly Instant $start,
25-
private readonly Instant $end,
24+
private Instant $start,
25+
private Instant $end,
2626
) {
2727
}
2828

src/LocalDate.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
*
3030
* This class is immutable.
3131
*/
32-
final class LocalDate implements JsonSerializable, Stringable
32+
final readonly class LocalDate implements JsonSerializable, Stringable
3333
{
3434
/**
3535
* The minimum supported year for instances of `LocalDate`, -999,999.
@@ -59,9 +59,9 @@ final class LocalDate implements JsonSerializable, Stringable
5959
* @param int<1, 31> $day The day-of-month, validated from 1 to 31, valid for the year-month.
6060
*/
6161
private function __construct(
62-
private readonly int $year,
63-
private readonly int $month,
64-
private readonly int $day,
62+
private int $year,
63+
private int $month,
64+
private int $day,
6565
) {
6666
}
6767

src/LocalDateRange.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@
2525
*
2626
* @template-implements IteratorAggregate<LocalDate>
2727
*/
28-
final class LocalDateRange implements IteratorAggregate, Countable, JsonSerializable, Stringable
28+
final readonly class LocalDateRange implements IteratorAggregate, Countable, JsonSerializable, Stringable
2929
{
3030
/**
3131
* @param LocalDate $start The start date, inclusive.
3232
* @param LocalDate $end The end date, inclusive, validated as not before the start date.
3333
*/
3434
private function __construct(
35-
private readonly LocalDate $start,
36-
private readonly LocalDate $end,
35+
private LocalDate $start,
36+
private LocalDate $end,
3737
) {
3838
}
3939

src/LocalDateTime.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323
*
2424
* This class is immutable.
2525
*/
26-
final class LocalDateTime implements JsonSerializable, Stringable
26+
final readonly class LocalDateTime implements JsonSerializable, Stringable
2727
{
2828
public function __construct(
29-
private readonly LocalDate $date,
30-
private readonly LocalTime $time,
29+
private LocalDate $date,
30+
private LocalTime $time,
3131
) {
3232
}
3333

src/LocalTime.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
*
3131
* This class is immutable.
3232
*/
33-
final class LocalTime implements JsonSerializable, Stringable
33+
final readonly class LocalTime implements JsonSerializable, Stringable
3434
{
3535
public const MONTHS_PER_YEAR = 12;
3636
public const DAYS_PER_WEEK = 7;
@@ -53,10 +53,10 @@ final class LocalTime implements JsonSerializable, Stringable
5353
* @param int $nano The nano-of-second, validated in the range 0 to 999,999,999.
5454
*/
5555
private function __construct(
56-
private readonly int $hour,
57-
private readonly int $minute,
58-
private readonly int $second,
59-
private readonly int $nano,
56+
private int $hour,
57+
private int $minute,
58+
private int $second,
59+
private int $nano,
6060
) {
6161
}
6262

src/MonthDay.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
/**
1818
* A month-day in the ISO-8601 calendar system, such as `--12-03`.
1919
*/
20-
final class MonthDay implements JsonSerializable, Stringable
20+
final readonly class MonthDay implements JsonSerializable, Stringable
2121
{
2222
/**
2323
* Private constructor. Use of() to obtain an instance.
@@ -26,8 +26,8 @@ final class MonthDay implements JsonSerializable, Stringable
2626
* @param int<1, 31> $day The day-of-month, valid for this month.
2727
*/
2828
private function __construct(
29-
private readonly int $month,
30-
private readonly int $day,
29+
private int $month,
30+
private int $day,
3131
) {
3232
}
3333

0 commit comments

Comments
 (0)