Skip to content

Commit

Permalink
Add void return type, clean up redundant docblocks
Browse files Browse the repository at this point in the history
  • Loading branch information
BenMorel committed Feb 26, 2021
1 parent 8574511 commit 213d02b
Show file tree
Hide file tree
Showing 31 changed files with 531 additions and 1,621 deletions.
38 changes: 19 additions & 19 deletions tests/AbstractTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ abstract class AbstractTestCase extends TestCase
* @param string $expectedString The expected string representation.
* @param object $object The object to test.
*/
protected function assertIs(string $className, string $expectedString, $object)
protected function assertIs(string $className, string $expectedString, $object): void
{
$this->assertInstanceOf($className, $object);
$this->assertSame($expectedString, (string) $object);
Expand All @@ -44,7 +44,7 @@ protected function assertIs(string $className, string $expectedString, $object)
* @param int $nano The expected nanosecond adjustment.
* @param Instant $instant The instant to test.
*/
protected function assertInstantIs(int $epochSecond, int $nano, Instant $instant)
protected function assertInstantIs(int $epochSecond, int $nano, Instant $instant): void
{
$this->compare([$epochSecond, $nano], [
$instant->getEpochSecond(),
Expand All @@ -58,7 +58,7 @@ protected function assertInstantIs(int $epochSecond, int $nano, Instant $instant
* @param int $day The expected day.
* @param LocalDate $date The local date to test.
*/
protected function assertLocalDateIs(int $year, int $month, int $day, LocalDate $date)
protected function assertLocalDateIs(int $year, int $month, int $day, LocalDate $date): void
{
$this->compare([$year, $month, $day], [
$date->getYear(),
Expand All @@ -74,7 +74,7 @@ protected function assertLocalDateIs(int $year, int $month, int $day, LocalDate
* @param int $nano The expected nano-of-second.
* @param LocalTime $time The local time to test.
*/
protected function assertLocalTimeIs(int $hour, int $minute, int $second, int $nano, LocalTime $time)
protected function assertLocalTimeIs(int $hour, int $minute, int $second, int $nano, LocalTime $time): void
{
$this->compare([$hour, $minute, $second, $nano], [
$time->getHour(),
Expand All @@ -94,7 +94,7 @@ protected function assertLocalTimeIs(int $hour, int $minute, int $second, int $n
* @param int $n The expected nano-of-second.
* @param LocalDateTime $dateTime The local date-time to test.
*/
protected function assertLocalDateTimeIs(int $y, int $m, int $d, int $h, int $i, int $s, int $n, LocalDateTime $dateTime)
protected function assertLocalDateTimeIs(int $y, int $m, int $d, int $h, int $i, int $s, int $n, LocalDateTime $dateTime): void
{
$this->compare([$y, $m, $d, $h, $i, $s, $n], [
$dateTime->getYear(),
Expand All @@ -111,7 +111,7 @@ protected function assertLocalDateTimeIs(int $y, int $m, int $d, int $h, int $i,
* @param LocalDateTime $expected The expected local date-time.
* @param LocalDateTime $actual The actual local date-time.
*/
protected function assertLocalDateTimeEquals(LocalDateTime $expected, LocalDateTime $actual)
protected function assertLocalDateTimeEquals(LocalDateTime $expected, LocalDateTime $actual): void
{
$this->assertTrue($actual->isEqualTo($expected), "$actual != $expected");
}
Expand All @@ -120,7 +120,7 @@ protected function assertLocalDateTimeEquals(LocalDateTime $expected, LocalDateT
* @param int $yearValue
* @param Year $year
*/
protected function assertYearIs(int $yearValue, Year $year)
protected function assertYearIs(int $yearValue, Year $year): void
{
$this->compare([$yearValue], [
$year->getValue()
Expand All @@ -132,7 +132,7 @@ protected function assertYearIs(int $yearValue, Year $year)
* @param int $month The expected month.
* @param YearMonth $yearMonth The year-month to test.
*/
protected function assertYearMonthIs(int $year, int $month, YearMonth $yearMonth)
protected function assertYearMonthIs(int $year, int $month, YearMonth $yearMonth): void
{
$this->compare([$year, $month], [
$yearMonth->getYear(),
Expand All @@ -145,7 +145,7 @@ protected function assertYearMonthIs(int $year, int $month, YearMonth $yearMonth
* @param int $week The expected week.
* @param YearWeek $yearWeek The year-week to test.
*/
protected function assertYearWeekIs(int $year, int $week, YearWeek $yearWeek)
protected function assertYearWeekIs(int $year, int $week, YearWeek $yearWeek): void
{
$this->compare([$year, $week], [
$yearWeek->getYear(),
Expand All @@ -158,7 +158,7 @@ protected function assertYearWeekIs(int $year, int $week, YearWeek $yearWeek)
* @param int $day The expected day.
* @param MonthDay $monthDay The month-day to test.
*/
protected function assertMonthDayIs(int $month, int $day, MonthDay $monthDay)
protected function assertMonthDayIs(int $month, int $day, MonthDay $monthDay): void
{
$this->compare([$month, $day], [
$monthDay->getMonth(),
Expand All @@ -170,7 +170,7 @@ protected function assertMonthDayIs(int $month, int $day, MonthDay $monthDay)
* @param int $monthValue The expected month-of-year value, from 1 to 12.
* @param Month $month The Month instance to test.
*/
protected function assertMonthIs(int $monthValue, Month $month)
protected function assertMonthIs(int $monthValue, Month $month): void
{
$this->compare([$monthValue], [
$month->getValue()
Expand All @@ -181,7 +181,7 @@ protected function assertMonthIs(int $monthValue, Month $month)
* @param int $dayOfWeekValue The expected day-of-week value, from 1 to 7.
* @param DayOfWeek $dayOfWeek The DayOfWeek instance to test.
*/
protected function assertDayOfWeekIs(int $dayOfWeekValue, DayOfWeek $dayOfWeek)
protected function assertDayOfWeekIs(int $dayOfWeekValue, DayOfWeek $dayOfWeek): void
{
$this->compare([$dayOfWeekValue], [
$dayOfWeek->getValue()
Expand All @@ -193,7 +193,7 @@ protected function assertDayOfWeekIs(int $dayOfWeekValue, DayOfWeek $dayOfWeek)
* @param int $nanos The expected nanos.
* @param Duration $duration The duration to test.
*/
protected function assertDurationIs(int $seconds, int $nanos, Duration $duration)
protected function assertDurationIs(int $seconds, int $nanos, Duration $duration): void
{
$this->compare([$seconds, $nanos], [
$duration->getSeconds(),
Expand All @@ -207,7 +207,7 @@ protected function assertDurationIs(int $seconds, int $nanos, Duration $duration
* @param int $days The expected number of days in the period.
* @param Period $period The period to test.
*/
protected function assertPeriodIs(int $years, int $months, int $days, Period $period)
protected function assertPeriodIs(int $years, int $months, int $days, Period $period): void
{
$this->compare([$years, $months, $days], [
$period->getYears(),
Expand All @@ -225,7 +225,7 @@ protected function assertPeriodIs(int $years, int $months, int $days, Period $pe
* @param int $d2 The expected day-of-month of the end date.
* @param LocalDateRange $range The LocalDateRange instance to test.
*/
protected function assertLocalDateRangeIs(int $y1, int $m1, int $d1, int $y2, int $m2, int $d2, LocalDateRange $range)
protected function assertLocalDateRangeIs(int $y1, int $m1, int $d1, int $y2, int $m2, int $d2, LocalDateRange $range): void
{
$this->assertLocalDateIs($y1, $m1, $d1, $range->getStart());
$this->assertLocalDateIs($y2, $m2, $d2, $range->getEnd());
Expand All @@ -238,7 +238,7 @@ protected function assertLocalDateRangeIs(int $y1, int $m1, int $d1, int $y2, in
* @param int $m2 The expected month-of-year of the end year-month.
* @param YearMonthRange $range The YearMonthRange instance to test.
*/
protected function assertYearMonthRangeIs(int $y1, int $m1, int $y2, int $m2, YearMonthRange $range)
protected function assertYearMonthRangeIs(int $y1, int $m1, int $y2, int $m2, YearMonthRange $range): void
{
$this->assertYearMonthIs($y1, $m1, $range->getStart());
$this->assertYearMonthIs($y2, $m2, $range->getEnd());
Expand All @@ -248,7 +248,7 @@ protected function assertYearMonthRangeIs(int $y1, int $m1, int $y2, int $m2, Ye
* @param TimeZone $expected The expected time-zone.
* @param TimeZone $actual The actual time-zone.
*/
protected function assertTimeZoneEquals(TimeZone $expected, TimeZone $actual)
protected function assertTimeZoneEquals(TimeZone $expected, TimeZone $actual): void
{
$this->assertTrue($actual->isEqualTo($expected), "$actual != $expected");
}
Expand All @@ -257,7 +257,7 @@ protected function assertTimeZoneEquals(TimeZone $expected, TimeZone $actual)
* @param int $totalSeconds The expected total offset in seconds.
* @param TimeZoneOffset $timeZoneOffset The time-zone offset to test.
*/
protected function assertTimeZoneOffsetIs(int $totalSeconds, TimeZoneOffset $timeZoneOffset)
protected function assertTimeZoneOffsetIs(int $totalSeconds, TimeZoneOffset $timeZoneOffset): void
{
$this->compare([$totalSeconds], [
$timeZoneOffset->getTotalSeconds()
Expand All @@ -268,7 +268,7 @@ protected function assertTimeZoneOffsetIs(int $totalSeconds, TimeZoneOffset $tim
* @param array $expected The expected values.
* @param array $actual The actual values, count & keys matching expected values.
*/
private function compare(array $expected, array $actual)
private function compare(array $expected, array $actual): void
{
$message = $this->export($actual) . ' !== ' . $this->export($expected);

Expand Down
2 changes: 1 addition & 1 deletion tests/Clock/FixedClockTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/
class FixedClockTest extends AbstractTestCase
{
public function testFixedClock()
public function testFixedClock(): void
{
$clock = new FixedClock(Instant::of(123456789, 987654321));
$this->assertInstantIs(123456789, 987654321, $clock->getTime());
Expand Down
5 changes: 1 addition & 4 deletions tests/Clock/OffsetClockTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,14 @@ class OffsetClockTest extends AbstractTestCase
* @param int $expectedSecond The expected epoch second returned by the clock.
* @param int $expectedNano The expected nano returned by the clock.
*/
public function testOffsetClock(int $second, int $nano, string $duration, int $expectedSecond, int $expectedNano)
public function testOffsetClock(int $second, int $nano, string $duration, int $expectedSecond, int $expectedNano): void
{
$baseClock = new FixedClock(Instant::of($second, $nano));
$clock = new OffsetClock($baseClock, Duration::parse($duration));

$this->assertInstantIs($expectedSecond, $expectedNano, $clock->getTime());
}

/**
* @return array
*/
public function providerOffsetClock() : array
{
return [
Expand Down
5 changes: 1 addition & 4 deletions tests/Clock/ScaleClockTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ScaleClockTest extends AbstractTestCase
* @param int $scale The time scale.
* @param string $expectedInstant The expected epoch second returned by the clock.
*/
public function testScaleClock(int $second, int $nano, string $duration, int $scale, string $expectedInstant)
public function testScaleClock(int $second, int $nano, string $duration, int $scale, string $expectedInstant): void
{
$baseInstant = Instant::of($second, $nano);

Expand All @@ -39,9 +39,6 @@ public function testScaleClock(int $second, int $nano, string $duration, int $sc
$this->assertSame($expectedInstant, $actualTime->toDecimal());
}

/**
* @return array
*/
public function providerScaleClock() : array
{
return [
Expand Down
6 changes: 2 additions & 4 deletions tests/Clock/SystemClockTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
/**
* Re-declare microtime() in the namespace of the SystemClock,
* to trick it into thinking it's the native PHP function.
*
* @return string
*/
function microtime() {
function microtime(): string {
return '0.55527600 14079491701';
}
}
Expand All @@ -25,7 +23,7 @@ function microtime() {
*/
class SystemClockTest extends AbstractTestCase
{
public function testSystemClock()
public function testSystemClock(): void
{
$clock = new SystemClock();

Expand Down
Loading

0 comments on commit 213d02b

Please sign in to comment.