Skip to content

Commit

Permalink
Add @psalm-return -1|0|1 on compareTo methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
gnutix committed Mar 23, 2024
1 parent 0b6900e commit fe52b56
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Duration.php
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,8 @@ public function abs(): Duration
* @param Duration $that The other duration to compare to.
*
* @return int [-1,0,1] If this duration is less than, equal to, or greater than the given duration.
*
* @psalm-return -1|0|1
*/
public function compareTo(Duration $that): int
{
Expand Down
2 changes: 2 additions & 0 deletions src/Instant.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ public function getNano(): int
* Compares this instant with another.
*
* @return int [-1,0,1] If this instant is before, on, or after the given instant.
*
* @psalm-return -1|0|1
*/
public function compareTo(Instant $that): int
{
Expand Down
2 changes: 2 additions & 0 deletions src/LocalDate.php
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,8 @@ public function minusDays(int $days): LocalDate
* Returns -1 if this date is before the given date, 1 if after, 0 if the dates are equal.
*
* @return int [-1,0,1] If this date is before, on, or after the given date.
*
* @psalm-return -1|0|1
*/
public function compareTo(LocalDate $that): int
{
Expand Down
2 changes: 2 additions & 0 deletions src/LocalDateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,8 @@ public function minusNanos(int $nanos): LocalDateTime
* @param LocalDateTime $that The date-time to compare to.
*
* @return int [-1,0,1] If this date-time is before, on, or after the given date-time.
*
* @psalm-return -1|0|1
*/
public function compareTo(LocalDateTime $that): int
{
Expand Down
2 changes: 2 additions & 0 deletions src/LocalTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,8 @@ public function minusNanos(int $nanos): LocalTime
* @param LocalTime $that The time to compare to.
*
* @return int [-1,0,1] If this time is before, on, or after the given time.
*
* @psalm-return -1|0|1
*/
public function compareTo(LocalTime $that): int
{
Expand Down
2 changes: 2 additions & 0 deletions src/MonthDay.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ public function getDayOfMonth(): int
* Returns -1 if this date is before the given date, 1 if after, 0 if the dates are equal.
*
* @return int [-1,0,1] If this date is before, on, or after the given date.
*
* @psalm-return -1|0|1
*/
public function compareTo(MonthDay $that): int
{
Expand Down
2 changes: 2 additions & 0 deletions src/Year.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ public function minus(int $years): Year
* @param Year $that The year to compare to.
*
* @return int [-1, 0, 1] If this year is before, equal to, or after the given year.
*
* @psalm-return -1|0|1
*/
public function compareTo(Year $that): int
{
Expand Down
2 changes: 2 additions & 0 deletions src/YearMonth.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ public function getLengthOfYear(): int

/**
* @return int [-1,0,1] If this year-month is before, on, or after the given year-month.
*
* @psalm-return -1|0|1
*/
public function compareTo(YearMonth $that): int
{
Expand Down
2 changes: 2 additions & 0 deletions src/YearWeek.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ public function getWeek(): int

/**
* @return int [-1,0,1] If this year-week is before, on, or after the given year-week.
*
* @psalm-return -1|0|1
*/
public function compareTo(YearWeek $that): int
{
Expand Down
2 changes: 2 additions & 0 deletions src/ZonedDateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,8 @@ public function minusSeconds(int $seconds): ZonedDateTime
* The comparison is performed on the instant.
*
* @return int [-1,0,1] If this zoned date-time is before, on, or after the given one.
*
* @psalm-return -1|0|1
*/
public function compareTo(ZonedDateTime $that): int
{
Expand Down

0 comments on commit fe52b56

Please sign in to comment.