diff --git a/tests/AbstractTestCase.php b/tests/AbstractTestCase.php index 17f15dc..3ba6440 100644 --- a/tests/AbstractTestCase.php +++ b/tests/AbstractTestCase.php @@ -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); @@ -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(), @@ -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(), @@ -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(), @@ -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(), @@ -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"); } @@ -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() @@ -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(), @@ -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(), @@ -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(), @@ -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() @@ -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() @@ -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(), @@ -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(), @@ -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()); @@ -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()); @@ -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"); } @@ -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() @@ -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); diff --git a/tests/Clock/FixedClockTest.php b/tests/Clock/FixedClockTest.php index 2e5e6d0..352f21b 100644 --- a/tests/Clock/FixedClockTest.php +++ b/tests/Clock/FixedClockTest.php @@ -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()); diff --git a/tests/Clock/OffsetClockTest.php b/tests/Clock/OffsetClockTest.php index 0baa497..f5ab38e 100644 --- a/tests/Clock/OffsetClockTest.php +++ b/tests/Clock/OffsetClockTest.php @@ -24,7 +24,7 @@ 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)); @@ -32,9 +32,6 @@ public function testOffsetClock(int $second, int $nano, string $duration, int $e $this->assertInstantIs($expectedSecond, $expectedNano, $clock->getTime()); } - /** - * @return array - */ public function providerOffsetClock() : array { return [ diff --git a/tests/Clock/ScaleClockTest.php b/tests/Clock/ScaleClockTest.php index dd2d1a6..6c0abe5 100644 --- a/tests/Clock/ScaleClockTest.php +++ b/tests/Clock/ScaleClockTest.php @@ -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); @@ -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 [ diff --git a/tests/Clock/SystemClockTest.php b/tests/Clock/SystemClockTest.php index 8945e51..5cec704 100644 --- a/tests/Clock/SystemClockTest.php +++ b/tests/Clock/SystemClockTest.php @@ -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'; } } @@ -25,7 +23,7 @@ function microtime() { */ class SystemClockTest extends AbstractTestCase { - public function testSystemClock() + public function testSystemClock(): void { $clock = new SystemClock(); diff --git a/tests/DayOfWeekTest.php b/tests/DayOfWeekTest.php index 8f331b7..3d5e48b 100644 --- a/tests/DayOfWeekTest.php +++ b/tests/DayOfWeekTest.php @@ -22,14 +22,11 @@ class DayOfWeekTest extends AbstractTestCase * @param int $expectedValue The expected value of the constant. * @param int $dayOfWeekConstant The day-of-week constant. */ - public function testConstants(int $expectedValue, int $dayOfWeekConstant) + public function testConstants(int $expectedValue, int $dayOfWeekConstant): void { $this->assertSame($expectedValue, $dayOfWeekConstant); } - /** - * @return array - */ public function providerConstants() : array { return [ @@ -43,25 +40,20 @@ public function providerConstants() : array ]; } - public function testOf() + public function testOf(): void { $this->assertDayOfWeekIs(5, DayOfWeek::of(5)); } /** * @dataProvider providerOfInvalidDayOfWeekThrowsException - * - * @param int $dayOfWeek */ - public function testOfInvalidDayOfWeekThrowsException(int $dayOfWeek) + public function testOfInvalidDayOfWeekThrowsException(int $dayOfWeek): void { $this->expectException(DateTimeException::class); DayOfWeek::of($dayOfWeek); } - /** - * @return array - */ public function providerOfInvalidDayOfWeekThrowsException() : array { return [ @@ -78,15 +70,12 @@ public function providerOfInvalidDayOfWeekThrowsException() : array * @param string $timeZone The time-zone to get the current day-of-week in. * @param int $expectedDayOfWeek The expected day-of-week, from 1 to 7. */ - public function testNow(int $epochSecond, string $timeZone, int $expectedDayOfWeek) + public function testNow(int $epochSecond, string $timeZone, int $expectedDayOfWeek): void { $clock = new FixedClock(Instant::of($epochSecond)); $this->assertDayOfWeekIs($expectedDayOfWeek, DayOfWeek::now(TimeZone::parse($timeZone), $clock)); } - /** - * @return array - */ public function providerNow() : array { return [ @@ -99,7 +88,7 @@ public function providerNow() : array ]; } - public function testAll() + public function testAll(): void { for ($day = DayOfWeek::MONDAY; $day <= DayOfWeek::SUNDAY; $day++) { $dayOfWeek = DayOfWeek::of($day); @@ -111,42 +100,42 @@ public function testAll() } } - public function testMonday() + public function testMonday(): void { $this->assertDayOfWeekIs(DayOfWeek::MONDAY, DayOfWeek::monday()); } - public function testTuesday() + public function testTuesday(): void { $this->assertDayOfWeekIs(DayOfWeek::TUESDAY, DayOfWeek::tuesday()); } - public function testWednesday() + public function testWednesday(): void { $this->assertDayOfWeekIs(DayOfWeek::WEDNESDAY, DayOfWeek::wednesday()); } - public function testThursday() + public function testThursday(): void { $this->assertDayOfWeekIs(DayOfWeek::THURSDAY, DayOfWeek::thursday()); } - public function testFriday() + public function testFriday(): void { $this->assertDayOfWeekIs(DayOfWeek::FRIDAY, DayOfWeek::friday()); } - public function testSaturday() + public function testSaturday(): void { $this->assertDayOfWeekIs(DayOfWeek::SATURDAY, DayOfWeek::saturday()); } - public function testSunday() + public function testSunday(): void { $this->assertDayOfWeekIs(DayOfWeek::SUNDAY, DayOfWeek::sunday()); } - public function testIs() + public function testIs(): void { for ($i = DayOfWeek::MONDAY; $i <= DayOfWeek::SUNDAY; $i++) { for ($j = DayOfWeek::MONDAY; $j <= DayOfWeek::SUNDAY; $j++) { @@ -155,7 +144,7 @@ public function testIs() } } - public function testIsEqualTo() + public function testIsEqualTo(): void { for ($i = DayOfWeek::MONDAY; $i <= DayOfWeek::SUNDAY; $i++) { for ($j = DayOfWeek::MONDAY; $j <= DayOfWeek::SUNDAY; $j++) { @@ -171,7 +160,7 @@ public function testIsEqualTo() * @param int $plusDays The number of days to add. * @param int $expectedDayOfWeek The expected day-of-week value, from 1 to 7. */ - public function testPlus(int $dayOfWeek, int $plusDays, int $expectedDayOfWeek) + public function testPlus(int $dayOfWeek, int $plusDays, int $expectedDayOfWeek): void { $this->assertDayOfWeekIs($expectedDayOfWeek, DayOfWeek::of($dayOfWeek)->plus($plusDays)); } @@ -183,14 +172,11 @@ public function testPlus(int $dayOfWeek, int $plusDays, int $expectedDayOfWeek) * @param int $plusDays The number of days to add. * @param int $expectedDayOfWeek The expected day-of-week value, from 1 to 7. */ - public function testMinus(int $dayOfWeek, int $plusDays, int $expectedDayOfWeek) + public function testMinus(int $dayOfWeek, int $plusDays, int $expectedDayOfWeek): void { $this->assertDayOfWeekIs($expectedDayOfWeek, DayOfWeek::of($dayOfWeek)->minus(-$plusDays)); } - /** - * @return \Generator - */ public function providerPlus() : \Generator { for ($dayOfWeek = DayOfWeek::MONDAY; $dayOfWeek <= DayOfWeek::SUNDAY; $dayOfWeek++) { @@ -217,7 +203,7 @@ public function providerPlus() : \Generator * @param string $localDate The local date to test, as a string. * @param int $dayOfWeek The day-of-week number that matches the local date. */ - public function testGetDayOfWeekFromLocalDate(string $localDate, int $dayOfWeek) + public function testGetDayOfWeekFromLocalDate(string $localDate, int $dayOfWeek): void { $localDate = LocalDate::parse($localDate); $dayOfWeek = DayOfWeek::of($dayOfWeek); @@ -225,9 +211,6 @@ public function testGetDayOfWeekFromLocalDate(string $localDate, int $dayOfWeek) $this->assertTrue($localDate->getDayOfWeek()->isEqualTo($dayOfWeek)); } - /** - * @return array - */ public function providerGetDayOfWeekFromLocalDate() : array { return [ @@ -253,7 +236,7 @@ public function providerGetDayOfWeekFromLocalDate() : array * @param int $dayOfWeek The day-of-week value, from 1 to 7. * @param string $expectedName The expected name. */ - public function testJsonSerialize(int $dayOfWeek, string $expectedName) + public function testJsonSerialize(int $dayOfWeek, string $expectedName): void { $this->assertSame(json_encode($expectedName), json_encode(DayOfWeek::of($dayOfWeek))); } @@ -264,7 +247,7 @@ public function testJsonSerialize(int $dayOfWeek, string $expectedName) * @param int $dayOfWeek The day-of-week value, from 1 to 7. * @param string $expectedName The expected name. */ - public function testToString(int $dayOfWeek, string $expectedName) + public function testToString(int $dayOfWeek, string $expectedName): void { $this->assertSame($expectedName, (string) DayOfWeek::of($dayOfWeek)); } @@ -284,5 +267,4 @@ public function providerToString() : array [DayOfWeek::SUNDAY, 'Sunday'] ]; } - } diff --git a/tests/DefaultClockTest.php b/tests/DefaultClockTest.php index 4e8b483..b524a82 100644 --- a/tests/DefaultClockTest.php +++ b/tests/DefaultClockTest.php @@ -18,13 +18,13 @@ public function tearDown(): void DefaultClock::reset(); } - public function testFreeze() + public function testFreeze(): void { DefaultClock::freeze(Instant::of(123456, 5000)); $this->assertInstantIs(123456, 5000, Instant::now()); } - public function testTravel() + public function testTravel(): void { $fixedClock = new FixedClock(Instant::of(1000, 0)); DefaultClock::set($fixedClock); @@ -37,7 +37,7 @@ public function testTravel() $this->assertInstantIs(-998, 0, Instant::now()); } - public function testScale() + public function testScale(): void { $fixedClock = new FixedClock(Instant::of(1000, 0)); DefaultClock::set($fixedClock); diff --git a/tests/DurationTest.php b/tests/DurationTest.php index 9697b47..4bbea3d 100644 --- a/tests/DurationTest.php +++ b/tests/DurationTest.php @@ -15,7 +15,7 @@ */ class DurationTest extends AbstractTestCase { - public function testZero() + public function testZero(): void { $this->assertDurationIs(0, 0, Duration::zero()); } @@ -24,19 +24,16 @@ public function testZero() * @dataProvider providerOfSeconds * * @param int $seconds The duration in seconds. - * @param int $nanoAdjustment The nanoseconds adjustement to the duration. + * @param int $nanoAdjustment The nanoseconds adjustment to the duration. * @param int $expectedSeconds The expected adjusted duration seconds. * @param int $expectedNanos The expected adjusted duration nanoseconds. */ - public function testOfSeconds(int $seconds, int $nanoAdjustment, int $expectedSeconds, int $expectedNanos) + public function testOfSeconds(int $seconds, int $nanoAdjustment, int $expectedSeconds, int $expectedNanos): void { $duration = Duration::ofSeconds($seconds, $nanoAdjustment); $this->assertDurationIs($expectedSeconds, $expectedNanos, $duration); } - /** - * @return array - */ public function providerOfSeconds() : array { return [ @@ -52,19 +49,15 @@ public function providerOfSeconds() : array } /** - * @param int $millis * @dataProvider providerOfMillis */ - public function testOfMillis(int $millis) + public function testOfMillis(int $millis): void { $duration = Duration::ofMillis($millis); $this->assertSame($millis, $duration->getTotalMillis()); } - /** - * @return array - */ - public function providerOfMillis() + public function providerOfMillis(): array { return [ [1000], @@ -77,20 +70,13 @@ public function providerOfMillis() /** * @dataProvider providerOfNanos - * - * @param int $nanos - * @param int $expectedSeconds - * @param int $expectedNanos */ - public function testOfNanos(int $nanos, int $expectedSeconds, int $expectedNanos) + public function testOfNanos(int $nanos, int $expectedSeconds, int $expectedNanos): void { $duration = Duration::ofNanos($nanos); $this->assertDurationIs($expectedSeconds, $expectedNanos, $duration); } - /** - * @return array - */ public function providerOfNanos() : array { return [ @@ -102,21 +88,21 @@ public function providerOfNanos() : array ]; } - public function testOfMinutes() + public function testOfMinutes(): void { for ($i = -2; $i <= 2; $i++) { $this->assertSame($i * 60, Duration::ofMinutes($i)->getSeconds()); } } - public function testOfHours() + public function testOfHours(): void { for ($i = -2; $i <= 2; $i++) { $this->assertSame($i * 3600, Duration::ofHours($i)->getSeconds()); } } - public function testOfDays() + public function testOfDays(): void { for ($i = -2; $i <= 2; $i++) { $this->assertSame($i * 86400, Duration::ofDays($i)->getSeconds()); @@ -125,15 +111,8 @@ public function testOfDays() /** * @dataProvider providerBetween - * - * @param int $seconds1 - * @param int $nanos1 - * @param int $seconds2 - * @param int $nanos2 - * @param int $seconds - * @param int $nanos */ - public function testBetween(int $seconds1, int $nanos1, int $seconds2, int $nanos2, int $seconds, int $nanos) + public function testBetween(int $seconds1, int $nanos1, int $seconds2, int $nanos2, int $seconds, int $nanos): void { $i1 = Instant::of($seconds1, $nanos1); $i2 = Instant::of($seconds2, $nanos2); @@ -141,9 +120,6 @@ public function testBetween(int $seconds1, int $nanos1, int $seconds2, int $nano $this->assertDurationIs($seconds, $nanos, Duration::between($i1, $i2)); } - /** - * @return array - */ public function providerBetween() : array { return [ @@ -172,14 +148,11 @@ public function providerBetween() : array * @param int $seconds The expected seconds. * @param int $nanos The expected nanos. */ - public function testParse(string $text, int $seconds, int $nanos) + public function testParse(string $text, int $seconds, int $nanos): void { $this->assertDurationIs($seconds, $nanos, Duration::parse($text)); } - /** - * @return array - */ public function providerParse() : array { return [ @@ -273,15 +246,12 @@ public function providerParse() : array * * @param string $text The string to test. */ - public function testParseFailureThrowsException(string $text) + public function testParseFailureThrowsException(string $text): void { $this->expectException(DateTimeParseException::class); Duration::parse($text); } - /** - * @return array - */ public function providerParseFailureThrowsException() : array { return [ @@ -328,7 +298,7 @@ public function providerParseFailureThrowsException() : array * @param int $nanos The nanos of the duration. * @param int $cmp The comparison value. */ - public function testIsZero(int $seconds, int $nanos, int $cmp) + public function testIsZero(int $seconds, int $nanos, int $cmp): void { $this->assertSame($cmp === 0, Duration::ofSeconds($seconds, $nanos)->isZero()); } @@ -340,7 +310,7 @@ public function testIsZero(int $seconds, int $nanos, int $cmp) * @param int $nanos The nanos of the duration. * @param int $cmp The comparison value. */ - public function testIsPositive(int $seconds, int $nanos, int $cmp) + public function testIsPositive(int $seconds, int $nanos, int $cmp): void { $this->assertSame($cmp > 0, Duration::ofSeconds($seconds, $nanos)->isPositive()); } @@ -352,7 +322,7 @@ public function testIsPositive(int $seconds, int $nanos, int $cmp) * @param int $nanos The nanos of the duration. * @param int $cmp The comparison value. */ - public function testIsPositiveOrZero(int $seconds, int $nanos, int $cmp) + public function testIsPositiveOrZero(int $seconds, int $nanos, int $cmp): void { $this->assertSame($cmp >= 0, Duration::ofSeconds($seconds, $nanos)->isPositiveOrZero()); } @@ -364,7 +334,7 @@ public function testIsPositiveOrZero(int $seconds, int $nanos, int $cmp) * @param int $nanos The nanos of the duration. * @param int $cmp The comparison value. */ - public function testIsNegative(int $seconds, int $nanos, int $cmp) + public function testIsNegative(int $seconds, int $nanos, int $cmp): void { $this->assertSame($cmp < 0, Duration::ofSeconds($seconds, $nanos)->isNegative()); } @@ -376,14 +346,11 @@ public function testIsNegative(int $seconds, int $nanos, int $cmp) * @param int $nanos The nanos of the duration. * @param int $cmp The comparison value. */ - public function testIsNegativeOrZero(int $seconds, int $nanos, int $cmp) + public function testIsNegativeOrZero(int $seconds, int $nanos, int $cmp): void { $this->assertSame($cmp <= 0, Duration::ofSeconds($seconds, $nanos)->isNegativeOrZero()); } - /** - * @return array - */ public function providerCompareToZero() : array { return [ @@ -408,7 +375,7 @@ public function providerCompareToZero() : array * @param int $nanos2 The nanoseconds of the 2nd duration. * @param int $expected The expected return value. */ - public function testCompareTo(int $seconds1, int $nanos1, int $seconds2, int $nanos2, int $expected) + public function testCompareTo(int $seconds1, int $nanos1, int $seconds2, int $nanos2, int $expected): void { $duration1 = Duration::ofSeconds($seconds1, $nanos1); $duration2 = Duration::ofSeconds($seconds2, $nanos2); @@ -416,9 +383,6 @@ public function testCompareTo(int $seconds1, int $nanos1, int $seconds2, int $na $this->assertSame($expected, $duration1->compareTo($duration2)); } - /** - * @return array - */ public function providerCompareTo() : array { return [ @@ -484,7 +448,7 @@ public function providerCompareTo() : array * @param int $s The expected seconds. * @param int $n The expected nanoseconds. */ - public function testPlus(int $s1, int $n1, int $s2, int $n2, int $s, int $n) + public function testPlus(int $s1, int $n1, int $s2, int $n2, int $s, int $n): void { $duration1 = Duration::ofSeconds($s1, $n1); $duration2 = Duration::ofSeconds($s2, $n2); @@ -502,7 +466,7 @@ public function testPlus(int $s1, int $n1, int $s2, int $n2, int $s, int $n) * @param int $s The expected seconds. * @param int $n The expected nanoseconds. */ - public function testMinus(int $s1, int $n1, int $s2, int $n2, int $s, int $n) + public function testMinus(int $s1, int $n1, int $s2, int $n2, int $s, int $n): void { $duration1 = Duration::ofSeconds($s1, $n1); $duration2 = Duration::ofSeconds(-$s2, -$n2); @@ -510,9 +474,6 @@ public function testMinus(int $s1, int $n1, int $s2, int $n2, int $s, int $n) $this->assertDurationIs($s, $n, $duration1->minus($duration2)); } - /** - * @return array - */ public function providerPlus() : array { return [ @@ -575,22 +536,13 @@ public function providerPlus() : array /** * @dataProvider providerPlusSeconds - * - * @param int $seconds - * @param int $nanos - * @param int $secondsToAdd - * @param int $expectedSeconds - * @param int $expectedNanos */ - public function testPlusSeconds(int $seconds, int $nanos, int $secondsToAdd, int $expectedSeconds, int $expectedNanos) + public function testPlusSeconds(int $seconds, int $nanos, int $secondsToAdd, int $expectedSeconds, int $expectedNanos): void { $duration = Duration::ofSeconds($seconds, $nanos)->plusSeconds($secondsToAdd); $this->assertDurationIs($expectedSeconds, $expectedNanos, $duration); } - /** - * @return array - */ public function providerPlusSeconds() : array { return [ @@ -630,9 +582,6 @@ public function testPlusMinutes(int $seconds, int $minutesToAdd, int $expectedSe $this->assertDurationIs($expectedSeconds, 0, $duration); } - /** - * @return array - */ public function providerPlusMinutes() : array { return [ @@ -654,20 +603,13 @@ public function providerPlusMinutes() : array /** * @dataProvider providerPlusHours - * - * @param int $seconds - * @param int $hoursToAdd - * @param int $expectedSeconds */ - public function testPlusHours(int $seconds, int $hoursToAdd, int $expectedSeconds) + public function testPlusHours(int $seconds, int $hoursToAdd, int $expectedSeconds): void { $duration = Duration::ofSeconds($seconds)->plusHours($hoursToAdd); $this->assertDurationIs($expectedSeconds, 0, $duration); } - /** - * @return array - */ public function providerPlusHours() : array { return [ @@ -689,20 +631,13 @@ public function providerPlusHours() : array /** * @dataProvider providerPlusDays - * - * @param int $seconds - * @param int $daysToAdd - * @param int $expectedSeconds */ - public function testPlusDays(int $seconds, int $daysToAdd, int $expectedSeconds) + public function testPlusDays(int $seconds, int $daysToAdd, int $expectedSeconds): void { $duration = Duration::ofSeconds($seconds)->plusDays($daysToAdd); $this->assertDurationIs($expectedSeconds, 0, $duration); } - /** - * @return array - */ public function providerPlusDays() : array { return [ @@ -724,20 +659,13 @@ public function providerPlusDays() : array /** * @dataProvider providerMinusSeconds - * - * @param int $seconds - * @param int $secondsToSubtract - * @param int $expectedSeconds */ - public function testMinusSeconds(int $seconds, int $secondsToSubtract, int $expectedSeconds) + public function testMinusSeconds(int $seconds, int $secondsToSubtract, int $expectedSeconds): void { $duration = Duration::ofSeconds($seconds)->minusSeconds($secondsToSubtract); $this->assertDurationIs($expectedSeconds, 0, $duration); } - /** - * @return array - */ public function providerMinusSeconds() : array { return [ @@ -762,20 +690,13 @@ public function providerMinusSeconds() : array /** * @dataProvider providerMinusMinutes - * - * @param int $seconds - * @param int $minutesToSubtract - * @param int $expectedSeconds */ - public function testMinusMinutes(int $seconds, int $minutesToSubtract, int $expectedSeconds) + public function testMinusMinutes(int $seconds, int $minutesToSubtract, int $expectedSeconds): void { $duration = Duration::ofSeconds($seconds)->minusMinutes($minutesToSubtract); $this->assertDurationIs($expectedSeconds, 0, $duration); } - /** - * @return array - */ public function providerMinusMinutes() : array { return [ @@ -797,20 +718,13 @@ public function providerMinusMinutes() : array /** * @dataProvider providerMinusHours - * - * @param int $seconds - * @param int $hoursToSubtract - * @param int $expectedSeconds */ - public function testMinusHours(int $seconds, int $hoursToSubtract, int $expectedSeconds) + public function testMinusHours(int $seconds, int $hoursToSubtract, int $expectedSeconds): void { $duration = Duration::ofSeconds($seconds)->minusHours($hoursToSubtract); $this->assertDurationIs($expectedSeconds, 0, $duration); } - /** - * @return array - */ public function providerMinusHours() : array { return [ @@ -832,20 +746,13 @@ public function providerMinusHours() : array /** * @dataProvider providerMinusDays - * - * @param int $seconds - * @param int $daysToSubtract - * @param int $expectedSeconds */ - public function testMinusDays(int $seconds, int $daysToSubtract, int $expectedSeconds) + public function testMinusDays(int $seconds, int $daysToSubtract, int $expectedSeconds): void { $duration = Duration::ofSeconds($seconds)->minusDays($daysToSubtract); $this->assertDurationIs($expectedSeconds, 0, $duration); } - /** - * @return array - */ public function providerMinusDays() : array { return [ @@ -867,14 +774,8 @@ public function providerMinusDays() : array /** * @dataProvider providerMultipliedBy - * - * @param int $second - * @param int $nano - * @param int $multiplicand - * @param int $expectedSecond - * @param int $expectedNano */ - public function testMultipliedBy(int $second, int $nano, int $multiplicand, int $expectedSecond, int $expectedNano) + public function testMultipliedBy(int $second, int $nano, int $multiplicand, int $expectedSecond, int $expectedNano): void { $duration = Duration::ofSeconds($second, $nano); $duration = $duration->multipliedBy($multiplicand); @@ -882,9 +783,6 @@ public function testMultipliedBy(int $second, int $nano, int $multiplicand, int $this->assertDurationIs($expectedSecond, $expectedNano, $duration); } - /** - * @return array - */ public function providerMultipliedBy() : array { return [ @@ -970,22 +868,13 @@ public function providerMultipliedBy() : array /** * @dataProvider providerDividedBy - * - * @param int $seconds - * @param int $nanos - * @param int $divisor - * @param int $expectedSeconds - * @param int $expectedNanos */ - public function testDividedBy(int $seconds, int $nanos, int $divisor, int $expectedSeconds, int $expectedNanos) + public function testDividedBy(int $seconds, int $nanos, int $divisor, int $expectedSeconds, int $expectedNanos): void { $duration = Duration::ofSeconds($seconds, $nanos)->dividedBy($divisor); $this->assertDurationIs($expectedSeconds, $expectedNanos, $duration); } - /** - * @return array - */ public function providerDividedBy() : array { return [ @@ -1042,7 +931,7 @@ public function providerDividedBy() : array ]; } - public function testDividedByZeroThrowsException() + public function testDividedByZeroThrowsException(): void { $this->expectException(DateTimeException::class); Duration::zero()->dividedBy(0); @@ -1052,19 +941,16 @@ public function testDividedByZeroThrowsException() * @dataProvider providerNegated * * @param int $seconds The duration in seconds. - * @param int $nanos The nanoseconds adjustement to the duration. + * @param int $nanos The nanoseconds adjustment to the duration. * @param int $expectedSeconds The expected seconds of the negated duration. * @param int $expectedNanos The expected nanoseconds adjustment of the negated duration. */ - public function testNegated(int $seconds, int $nanos, int $expectedSeconds, int $expectedNanos) + public function testNegated(int $seconds, int $nanos, int $expectedSeconds, int $expectedNanos): void { $duration = Duration::ofSeconds($seconds, $nanos); $this->assertDurationIs($expectedSeconds, $expectedNanos, $duration->negated()); } - /** - * @return array - */ public function providerNegated() : array { return [ @@ -1078,7 +964,7 @@ public function providerNegated() : array ]; } - public function testAbs() + public function testAbs(): void { for ($seconds = -3; $seconds <= 3; $seconds++) { $duration = Duration::ofSeconds($seconds)->abs(); @@ -1086,7 +972,7 @@ public function testAbs() } } - public function testComparisons() + public function testComparisons(): void { $this->doTestComparisons([ Duration::ofDays(-1), @@ -1110,7 +996,7 @@ public function testComparisons() /** * @param Duration[] $durations */ - private function doTestComparisons(array $durations) + private function doTestComparisons(array $durations): void { $count = \count($durations); @@ -1149,7 +1035,7 @@ private function doTestComparisons(array $durations) } } - public function testEquals() + public function testEquals(): void { $test5a = Duration::ofSeconds(5); $test5b = Duration::ofSeconds(5); @@ -1184,15 +1070,12 @@ public function testEquals() * @param int $nanos The nanoseconds adjustment to the duration. * @param int $expectedMillis The expected total number of milliseconds. */ - public function testGetTotalMillis(int $seconds, int $nanos, int $expectedMillis) + public function testGetTotalMillis(int $seconds, int $nanos, int $expectedMillis): void { $duration = Duration::ofSeconds($seconds, $nanos); $this->assertSame($expectedMillis, $duration->getTotalMillis()); } - /** - * @return array - */ public function providerGetTotalMillis() : array { return [ @@ -1210,15 +1093,12 @@ public function providerGetTotalMillis() : array * @param int $nanos The nanoseconds adjustment to the duration. * @param int $expectedMicros The expected total number of microseconds. */ - public function testGetTotalMicros(int $seconds, int $nanos, int $expectedMicros) + public function testGetTotalMicros(int $seconds, int $nanos, int $expectedMicros): void { $duration = Duration::ofSeconds($seconds, $nanos); $this->assertSame($expectedMicros, $duration->getTotalMicros()); } - /** - * @return array - */ public function providerGetTotalMicros() : array { return [ @@ -1236,15 +1116,12 @@ public function providerGetTotalMicros() : array * @param int $nanos The nanoseconds adjustment to the duration. * @param int $expectedNanos The expected total number of nanoseconds. */ - public function testGetTotalNanos(int $seconds, int $nanos, int $expectedNanos) + public function testGetTotalNanos(int $seconds, int $nanos, int $expectedNanos): void { $duration = Duration::ofSeconds($seconds, $nanos); $this->assertSame($expectedNanos, $duration->getTotalNanos()); } - /** - * @return array - */ public function providerGetTotalNanos() : array { return [ @@ -1257,18 +1134,12 @@ public function providerGetTotalNanos() : array /** * @dataProvider providerToDaysPart - * - * @param Duration $duration - * @param int $days */ - public function testToDaysPart(Duration $duration, int $days) + public function testToDaysPart(Duration $duration, int $days): void { $this->assertSame($days, $duration->toDaysPart()); } - /** - * @return array - */ public function providerToDaysPart() : array { return [ @@ -1283,18 +1154,12 @@ public function providerToDaysPart() : array /** * @dataProvider providerToHoursPart - * - * @param Duration $duration - * @param int $hours */ - public function testToHoursPart(Duration $duration, int $hours) + public function testToHoursPart(Duration $duration, int $hours): void { $this->assertSame($hours, $duration->toHoursPart()); } - /** - * @return array - */ public function providerToHoursPart() : array { return [ @@ -1308,18 +1173,12 @@ public function providerToHoursPart() : array /** * @dataProvider providerToMinutesPart - * - * @param Duration $duration - * @param int $minutes */ - public function testToMinutesPart(Duration $duration, int $minutes) + public function testToMinutesPart(Duration $duration, int $minutes): void { $this->assertSame($minutes, $duration->toMinutesPart()); } - /** - * @return array - */ public function providerToMinutesPart() : array { return [ @@ -1333,18 +1192,12 @@ public function providerToMinutesPart() : array /** * @dataProvider providerToSecondsPart - * - * @param Duration $duration - * @param int $seconds */ - public function testToSecondsPart(Duration $duration, int $seconds) + public function testToSecondsPart(Duration $duration, int $seconds): void { $this->assertSame($seconds, $duration->toSecondsPart()); } - /** - * @return array - */ public function providerToSecondsPart() : array { return [ @@ -1359,18 +1212,12 @@ public function providerToSecondsPart() : array /** * @dataProvider providerToMillis - * - * @param Duration $duration - * @param int $millis */ - public function testToMillis(Duration $duration, int $millis) + public function testToMillis(Duration $duration, int $millis): void { $this->assertSame($millis, $duration->toMillis()); } - /** - * @return array - */ public function providerToMillis() : array { return [ @@ -1384,18 +1231,13 @@ public function providerToMillis() : array /** * @dataProvider providerToMillisOutOfRange - * - * @param Duration $duration */ - public function testToMillisOutOfRange(Duration $duration) + public function testToMillisOutOfRange(Duration $duration): void { $this->expectException(ArithmeticError::class); $duration->toMillis(); } - /** - * @return array - */ public function providerToMillisOutOfRange() : array { return [ @@ -1406,18 +1248,12 @@ public function providerToMillisOutOfRange() : array /** * @dataProvider providerToMillisPart - * - * @param Duration $duration - * @param int $millis */ - public function testToMillisPart(Duration $duration, int $millis) + public function testToMillisPart(Duration $duration, int $millis): void { $this->assertSame($millis, $duration->toMillisPart()); } - /** - * @return array - */ public function providerToMillisPart() : array { return [ @@ -1432,18 +1268,12 @@ public function providerToMillisPart() : array /** * @dataProvider providerToNanos - * - * @param Duration $duration - * @param int $nanos */ - public function testToNanos(Duration $duration, int $nanos) + public function testToNanos(Duration $duration, int $nanos): void { $this->assertSame($nanos, $duration->toNanos()); } - /** - * @return array - */ public function providerToNanos() : array { return [ @@ -1456,18 +1286,12 @@ public function providerToNanos() : array /** * @dataProvider providerToNanosPart - * - * @param Duration $duration - * @param int $nanos */ - public function testToNanosPart(Duration $duration, int $nanos) + public function testToNanosPart(Duration $duration, int $nanos): void { $this->assertSame($nanos, $duration->toNanosPart()); } - /** - * @return array - */ public function providerToNanosPart() : array { return [ @@ -1482,31 +1306,20 @@ public function providerToNanosPart() : array /** * @dataProvider providerToString - * - * @param int $seconds - * @param int $nanos - * @param string $expected */ - public function testJsonSerialize(int $seconds, int $nanos, string $expected) + public function testJsonSerialize(int $seconds, int $nanos, string $expected): void { $this->assertSame(json_encode($expected), json_encode(Duration::ofSeconds($seconds, $nanos))); } /** * @dataProvider providerToString - * - * @param int $seconds - * @param int $nanos - * @param string $expected */ - public function testToString(int $seconds, int $nanos, string $expected) + public function testToString(int $seconds, int $nanos, string $expected): void { $this->assertSame($expected, (string) Duration::ofSeconds($seconds, $nanos)); } - /** - * @return array - */ public function providerToString() : array { return [ diff --git a/tests/Field/DayOfMonthTest.php b/tests/Field/DayOfMonthTest.php index 7110607..9b6f66d 100644 --- a/tests/Field/DayOfMonthTest.php +++ b/tests/Field/DayOfMonthTest.php @@ -15,7 +15,7 @@ class DayOfMonthTest extends AbstractTestCase /** * @doesNotPerformAssertions */ - public function testCheckWithNullMonthOfYear() + public function testCheckWithNullMonthOfYear(): void { DayOfMonth::check(31); } diff --git a/tests/Field/WeekOfYearTest.php b/tests/Field/WeekOfYearTest.php index 293e82b..cfe3f8f 100644 --- a/tests/Field/WeekOfYearTest.php +++ b/tests/Field/WeekOfYearTest.php @@ -13,7 +13,7 @@ */ class WeekOfYearTest extends AbstractTestCase { - public function testCheckShouldThrowDateTimeExceptionWithFieldNotInRange() + public function testCheckShouldThrowDateTimeExceptionWithFieldNotInRange(): void { $this->expectException(DateTimeException::class); $this->expectExceptionMessage('Invalid week-of-year: -1 is not in the range 1 to 53.'); @@ -21,7 +21,7 @@ public function testCheckShouldThrowDateTimeExceptionWithFieldNotInRange() WeekOfYear::check(-1); } - public function testCheckShouldThrowDateTimeExceptionWith52WeekYear() + public function testCheckShouldThrowDateTimeExceptionWith52WeekYear(): void { $this->expectException(DateTimeException::class); $this->expectExceptionMessage('Year 2000 does not have 53 weeks'); diff --git a/tests/InstantTest.php b/tests/InstantTest.php index 1dde255..8418c9c 100644 --- a/tests/InstantTest.php +++ b/tests/InstantTest.php @@ -19,11 +19,11 @@ class InstantTest extends AbstractTestCase * @dataProvider providerOf * * @param int $seconds The duration in seconds. - * @param int $nanoAdjustment The nanoseconds adjustement to the duration. + * @param int $nanoAdjustment The nanoseconds adjustment to the duration. * @param int $expectedSeconds The expected adjusted duration seconds. * @param int $expectedNanos The expected adjusted duration nanoseconds. */ - public function testOf(int $seconds, int $nanoAdjustment, int $expectedSeconds, int $expectedNanos) + public function testOf(int $seconds, int $nanoAdjustment, int $expectedSeconds, int $expectedNanos): void { $duration = Instant::of($seconds, $nanoAdjustment); @@ -31,9 +31,6 @@ public function testOf(int $seconds, int $nanoAdjustment, int $expectedSeconds, $this->assertSame($expectedNanos, $duration->getNano()); } - /** - * @return array - */ public function providerOf() : array { return [ @@ -48,23 +45,23 @@ public function providerOf() : array ]; } - public function testEpoch() + public function testEpoch(): void { $this->assertInstantIs(0, 0, Instant::epoch()); } - public function testNow() + public function testNow(): void { $clock = new FixedClock(Instant::of(123456789, 987654321)); $this->assertInstantIs(123456789, 987654321, Instant::now($clock)); } - public function testMin() + public function testMin(): void { $this->assertInstantIs(~\PHP_INT_MAX, 0, Instant::min()); } - public function testMax() + public function testMax(): void { $this->assertInstantIs(\PHP_INT_MAX, 999999999, Instant::max()); } @@ -79,7 +76,7 @@ public function testMax() * @param int $expectedSecond The expected second of the result. * @param int $expectedNano The expected nano of the result. */ - public function testPlus(int $second, int $nano, int $plusSeconds, int $plusNanos, int $expectedSecond, int $expectedNano) + public function testPlus(int $second, int $nano, int $plusSeconds, int $plusNanos, int $expectedSecond, int $expectedNano): void { $result = Instant::of($second, $nano)->plus(Duration::ofSeconds($plusSeconds, $plusNanos)); $this->assertInstantIs($expectedSecond, $expectedNano, $result); @@ -95,15 +92,12 @@ public function testPlus(int $second, int $nano, int $plusSeconds, int $plusNano * @param int $expectedSecond The expected second of the result. * @param int $expectedNano The expected nano of the result. */ - public function testMinus(int $second, int $nano, int $plusSeconds, int $plusNanos, int $expectedSecond, int $expectedNano) + public function testMinus(int $second, int $nano, int $plusSeconds, int $plusNanos, int $expectedSecond, int $expectedNano): void { $result = Instant::of($second, $nano)->minus(Duration::ofSeconds(-$plusSeconds, -$plusNanos)); $this->assertInstantIs($expectedSecond, $expectedNano, $result); } - /** - * @return array - */ public function providerPlus() : array { return [ @@ -123,7 +117,7 @@ public function providerPlus() : array * @param int $plusSeconds The number of seconds to add. * @param int $expectedSecond The expected second of the result. */ - public function testPlusSeconds(int $second, int $nano, int $plusSeconds, int $expectedSecond) + public function testPlusSeconds(int $second, int $nano, int $plusSeconds, int $expectedSecond): void { $result = Instant::of($second, $nano)->plusSeconds($plusSeconds); $this->assertInstantIs($expectedSecond, $nano, $result); @@ -137,15 +131,12 @@ public function testPlusSeconds(int $second, int $nano, int $plusSeconds, int $e * @param int $plusSeconds The number of seconds to add. * @param int $expectedSecond The expected second of the result. */ - public function testMinusSeconds(int $second, int $nano, int $plusSeconds, int $expectedSecond) + public function testMinusSeconds(int $second, int $nano, int $plusSeconds, int $expectedSecond): void { $result = Instant::of($second, $nano)->minusSeconds(-$plusSeconds); $this->assertInstantIs($expectedSecond, $nano, $result); } - /** - * @return array - */ public function providerPlusSeconds() : array { return [ @@ -167,7 +158,7 @@ public function providerPlusSeconds() : array * @param int $plusMinutes The number of minutes to add. * @param int $expectedSecond The expected second of the result. */ - public function testPlusMinutes(int $second, int $nano, int $plusMinutes, int $expectedSecond) + public function testPlusMinutes(int $second, int $nano, int $plusMinutes, int $expectedSecond): void { $result = Instant::of($second, $nano)->plusMinutes($plusMinutes); $this->assertInstantIs($expectedSecond, $nano, $result); @@ -181,15 +172,12 @@ public function testPlusMinutes(int $second, int $nano, int $plusMinutes, int $e * @param int $plusMinutes The number of minutes to add. * @param int $expectedSecond The expected second of the result. */ - public function testMinusMinutes(int $second, int $nano, int $plusMinutes, int $expectedSecond) + public function testMinusMinutes(int $second, int $nano, int $plusMinutes, int $expectedSecond): void { $result = Instant::of($second, $nano)->minusMinutes(-$plusMinutes); $this->assertInstantIs($expectedSecond, $nano, $result); } - /** - * @return array - */ public function providerPlusMinutes() : array { return [ @@ -225,15 +213,12 @@ public function testPlusHours(int $second, int $nano, int $plusHours, int $expec * @param int $plusHours The number of hours to add. * @param int $expectedSecond The expected second of the result. */ - public function testMinusHours(int $second, int $nano, int $plusHours, int $expectedSecond) + public function testMinusHours(int $second, int $nano, int $plusHours, int $expectedSecond): void { $result = Instant::of($second, $nano)->minusHours(-$plusHours); $this->assertInstantIs($expectedSecond, $nano, $result); } - /** - * @return array - */ public function providerPlusHours() : array { return [ @@ -255,7 +240,7 @@ public function providerPlusHours() : array * @param int $plusDays The number of days to add. * @param int $expectedSecond The expected second of the result. */ - public function testPlusDays(int $second, int $nano, int $plusDays, int $expectedSecond) + public function testPlusDays(int $second, int $nano, int $plusDays, int $expectedSecond): void { $result = Instant::of($second, $nano)->plusDays($plusDays); $this->assertInstantIs($expectedSecond, $nano, $result); @@ -269,15 +254,12 @@ public function testPlusDays(int $second, int $nano, int $plusDays, int $expecte * @param int $plusDays The number of days to add. * @param int $expectedSecond The expected second of the result. */ - public function testMinusDays(int $second, int $nano, int $plusDays, int $expectedSecond) + public function testMinusDays(int $second, int $nano, int $plusDays, int $expectedSecond): void { $result = Instant::of($second, $nano)->minusDays(-$plusDays); $this->assertInstantIs($expectedSecond, $nano, $result); } - /** - * @return array - */ public function providerPlusDays() : array { return [ @@ -291,13 +273,13 @@ public function providerPlusDays() : array ]; } - public function testWithEpochSecond() + public function testWithEpochSecond(): void { $instant = Instant::of(1234567890, 987654321); $this->assertInstantIs(2345678901, 987654321, $instant->withEpochSecond(2345678901)); } - public function testWithNano() + public function testWithNano(): void { $instant = Instant::of(1234567890, 987654321); $this->assertInstantIs(1234567890, 123456789, $instant->withNano(123456789)); @@ -305,10 +287,8 @@ public function testWithNano() /** * @dataProvider providerWithInvalidNanoThrowsException - * - * @param int $nano */ - public function testWithInvalidNanoThrowsException(int $nano) + public function testWithInvalidNanoThrowsException(int $nano): void { $instant = Instant::of(1234567890, 987654321); @@ -316,9 +296,6 @@ public function testWithInvalidNanoThrowsException(int $nano) $instant->withNano($nano); } - /** - * @return array - */ public function providerWithInvalidNanoThrowsException() : array { return [ @@ -336,7 +313,7 @@ public function providerWithInvalidNanoThrowsException() : array * @param int $n2 The nanosecond adjustment of the 2nd instant. * @param int $cmp The expected comparison value. */ - public function testCompareTo(int $s1, int $n1, int $s2, int $n2, int $cmp) + public function testCompareTo(int $s1, int $n1, int $s2, int $n2, int $cmp): void { $this->assertSame($cmp, Instant::of($s1, $n1)->compareTo(Instant::of($s2, $n2))); } @@ -350,7 +327,7 @@ public function testCompareTo(int $s1, int $n1, int $s2, int $n2, int $cmp) * @param int $n2 The nanosecond adjustment of the 2nd instant. * @param int $cmp The comparison value. */ - public function testIsEqualTo(int $s1, int $n1, int $s2, int $n2, int $cmp) + public function testIsEqualTo(int $s1, int $n1, int $s2, int $n2, int $cmp): void { $this->assertSame($cmp === 0, Instant::of($s1, $n1)->isEqualTo(Instant::of($s2, $n2))); } @@ -364,7 +341,7 @@ public function testIsEqualTo(int $s1, int $n1, int $s2, int $n2, int $cmp) * @param int $n2 The nanosecond adjustment of the 2nd instant. * @param int $cmp The comparison value. */ - public function testIsAfter(int $s1, int $n1, int $s2, int $n2, int $cmp) + public function testIsAfter(int $s1, int $n1, int $s2, int $n2, int $cmp): void { $this->assertSame($cmp === 1, Instant::of($s1, $n1)->isAfter(Instant::of($s2, $n2))); } @@ -378,7 +355,7 @@ public function testIsAfter(int $s1, int $n1, int $s2, int $n2, int $cmp) * @param int $n2 The nanosecond adjustment of the 2nd instant. * @param int $cmp The comparison value. */ - public function testIsAfterOrEqualTo(int $s1, int $n1, int $s2, int $n2, int $cmp) + public function testIsAfterOrEqualTo(int $s1, int $n1, int $s2, int $n2, int $cmp): void { $this->assertSame($cmp >= 0, Instant::of($s1, $n1)->isAfterOrEqualTo(Instant::of($s2, $n2))); } @@ -392,7 +369,7 @@ public function testIsAfterOrEqualTo(int $s1, int $n1, int $s2, int $n2, int $cm * @param int $n2 The nanosecond adjustment of the 2nd instant. * @param int $cmp The comparison value. */ - public function testIsBefore(int $s1, int $n1, int $s2, int $n2, int $cmp) + public function testIsBefore(int $s1, int $n1, int $s2, int $n2, int $cmp): void { $this->assertSame($cmp === -1, Instant::of($s1, $n1)->isBefore(Instant::of($s2, $n2))); } @@ -406,7 +383,7 @@ public function testIsBefore(int $s1, int $n1, int $s2, int $n2, int $cmp) * @param int $n2 The nanosecond adjustment of the 2nd instant. * @param int $cmp The comparison value. */ - public function testIsBeforeOrEqualTo(int $s1, int $n1, int $s2, int $n2, int $cmp) + public function testIsBeforeOrEqualTo(int $s1, int $n1, int $s2, int $n2, int $cmp): void { $this->assertSame($cmp <= 0, Instant::of($s1, $n1)->isBeforeOrEqualTo(Instant::of($s2, $n2))); } @@ -420,7 +397,7 @@ public function testIsBeforeOrEqualTo(int $s1, int $n1, int $s2, int $n2, int $c * @param int $nowNano The nanosecond adjustment to the current time. * @param int $cmp The comparison value. */ - public function testIsFuture(int $testSecond, int $testNano, int $nowSecond, int $nowNano, int $cmp) + public function testIsFuture(int $testSecond, int $testNano, int $nowSecond, int $nowNano, int $cmp): void { $clock = new FixedClock(Instant::of($nowSecond, $nowNano)); $this->assertSame($cmp === 1, Instant::of($testSecond, $testNano)->isFuture($clock)); @@ -435,15 +412,12 @@ public function testIsFuture(int $testSecond, int $testNano, int $nowSecond, int * @param int $nowNano The nanosecond adjustment to the current time. * @param int $cmp The comparison value. */ - public function testIsPast(int $testSecond, int $testNano, int $nowSecond, int $nowNano, int $cmp) + public function testIsPast(int $testSecond, int $testNano, int $nowSecond, int $nowNano, int $cmp): void { $clock = new FixedClock(Instant::of($nowSecond, $nowNano)); $this->assertSame($cmp === -1, Instant::of($testSecond, $testNano)->isPast($clock)); } - /** - * @return array - */ public function providerCompareTo() : array { return [ @@ -538,7 +512,7 @@ public function providerCompareTo() : array * @param int $nanos The nano seconds value. * @param bool $isBetween Check the secs and nanos are between. */ - public function testIsBetweenInclusive(int $seconds, int $nanos, $isBetween) + public function testIsBetweenInclusive(int $seconds, int $nanos, $isBetween): void { $this->assertSame($isBetween, Instant::of($seconds, $nanos)->isBetweenInclusive( Instant::of(-1, -1), @@ -553,7 +527,7 @@ public function testIsBetweenInclusive(int $seconds, int $nanos, $isBetween) * @param int $nanos The nano seconds value. * @param bool $isBetween Check the secs and nanos are between. */ - public function testIsBetweenExclusive(int $seconds, int $nanos, $isBetween) + public function testIsBetweenExclusive(int $seconds, int $nanos, $isBetween): void { $this->assertSame($isBetween, Instant::of($seconds, $nanos)->isBetweenExclusive( Instant::of(-1, -1), @@ -561,9 +535,6 @@ public function testIsBetweenExclusive(int $seconds, int $nanos, $isBetween) )); } - /** - * @return array - */ public function providerIsBetweenExclusive() : array { return [ @@ -608,14 +579,11 @@ public function providerIsBetweenInclusive() : array * @param int $nano The nano adjustment. * @param string $expected The expected decimal output. */ - public function testToDecimal(int $second, int $nano, string $expected) + public function testToDecimal(int $second, int $nano, string $expected): void { $this->assertSame($expected, Instant::of($second, $nano)->toDecimal()); } - /** - * @return array - */ public function providerToDecimal() { return [ @@ -640,7 +608,7 @@ public function providerToDecimal() * @param int $nano The nano adjustment to the epoch second. * @param string $expectedString The expected string output. */ - public function testJsonSerialize(int $epochSecond, int $nano, string $expectedString) + public function testJsonSerialize(int $epochSecond, int $nano, string $expectedString): void { $this->assertSame(json_encode($expectedString), json_encode(Instant::of($epochSecond, $nano))); } @@ -652,14 +620,11 @@ public function testJsonSerialize(int $epochSecond, int $nano, string $expectedS * @param int $nano The nano adjustment to the epoch second. * @param string $expectedString The expected string output. */ - public function testToString(int $epochSecond, int $nano, string $expectedString) + public function testToString(int $epochSecond, int $nano, string $expectedString): void { $this->assertSame($expectedString, (string) Instant::of($epochSecond, $nano)); } - /** - * @return array - */ public function providerToString() : array { return [ @@ -674,7 +639,7 @@ public function providerToString() : array ]; } - public function testAtTimeZone() + public function testAtTimeZone(): void { $timeZone = TimeZone::utc(); $instant = Instant::of(1000000000); diff --git a/tests/IntervalTest.php b/tests/IntervalTest.php index e57e218..25ed868 100644 --- a/tests/IntervalTest.php +++ b/tests/IntervalTest.php @@ -13,7 +13,7 @@ */ class IntervalTest extends AbstractTestCase { - public function testEndInstantIsNotBeforeStartInstant() + public function testEndInstantIsNotBeforeStartInstant(): void { $start = Instant::of(2000000000, 987654321); $end = Instant::of(2000000009, 123456789); @@ -24,7 +24,7 @@ public function testEndInstantIsNotBeforeStartInstant() new Interval($end, $start); } - public function testGetStartEnd() + public function testGetStartEnd(): void { $start = Instant::of(2000000000, 987654321); $end = Instant::of(2000000009, 123456789); @@ -38,7 +38,7 @@ public function testGetStartEnd() /** * @depends testGetStartEnd */ - public function testWithStart() + public function testWithStart(): void { $interval = new Interval( Instant::of(2000000000), @@ -61,7 +61,7 @@ public function testWithStart() /** * @depends testGetStartEnd */ - public function testWithEnd() + public function testWithEnd(): void { $interval = new Interval( Instant::of(2000000000), @@ -81,7 +81,7 @@ public function testWithEnd() $this->assertInstantIs(2000000002, 222222222, $newInterval->getEnd()); } - public function testGetDuration() + public function testGetDuration(): void { $interval = new Interval( Instant::of(1999999999, 555555), @@ -93,7 +93,7 @@ public function testGetDuration() $this->assertDurationIs(1, 999444556, $duration); } - public function testJsonSerialize() + public function testJsonSerialize(): void { $interval = new Interval( Instant::of(1000000000), @@ -103,7 +103,7 @@ public function testJsonSerialize() $this->assertSame(json_encode('2001-09-09T01:46:40Z/2033-05-18T03:33:20Z'), json_encode($interval)); } - public function testToString() + public function testToString(): void { $interval = new Interval( Instant::of(1000000000), diff --git a/tests/LocalDateRangeTest.php b/tests/LocalDateRangeTest.php index bf61aec..01f93e7 100644 --- a/tests/LocalDateRangeTest.php +++ b/tests/LocalDateRangeTest.php @@ -14,7 +14,7 @@ */ class LocalDateRangeTest extends AbstractTestCase { - public function testOf() + public function testOf(): void { $this->assertLocalDateRangeIs(2001, 2, 3, 2004, 5, 6, LocalDateRange::of( LocalDate::of(2001, 2, 3), @@ -22,7 +22,7 @@ public function testOf() )); } - public function testOfInvalidRangeThrowsException() + public function testOfInvalidRangeThrowsException(): void { $this->expectException(DateTimeException::class); @@ -43,14 +43,11 @@ public function testOfInvalidRangeThrowsException() * @param int $m2 The expected end month. * @param int $d2 The expected end day. */ - public function testParse(string $text, int $y1, int $m1, int $d1, int $y2, int $m2, int $d2) + public function testParse(string $text, int $y1, int $m1, int $d1, int $y2, int $m2, int $d2): void { $this->assertLocalDateRangeIs($y1, $m1, $d1, $y2, $m2, $d2, LocalDateRange::parse($text)); } - /** - * @return array - */ public function providerParse() : array { return [ @@ -65,15 +62,12 @@ public function providerParse() : array * * @param string $text The invalid text to parse. */ - public function testParseInvalidRangeThrowsException(string $text) + public function testParseInvalidRangeThrowsException(string $text): void { $this->expectException(DateTimeParseException::class); LocalDateRange::parse($text); } - /** - * @return array - */ public function providerParseInvalidRangeThrowsException() : array { return [ @@ -96,7 +90,7 @@ public function providerParseInvalidRangeThrowsException() : array * @param string $testRange The string representation of the range to test. * @param bool $isEqual Whether this range is expected to be equal to our range. */ - public function testIsEqualTo(string $testRange, bool $isEqual) + public function testIsEqualTo(string $testRange, bool $isEqual): void { $this->assertSame($isEqual, LocalDateRange::of( LocalDate::of(2001, 2, 3), @@ -104,9 +98,6 @@ public function testIsEqualTo(string $testRange, bool $isEqual) )->isEqualTo(LocalDateRange::parse($testRange))); } - /** - * @return array - */ public function providerIsEqualTo() : array { return [ @@ -122,19 +113,12 @@ public function providerIsEqualTo() : array /** * @dataProvider providerContains - * - * @param string $range - * @param string $date - * @param bool $contains */ - public function testContains(string $range, string $date, bool $contains) + public function testContains(string $range, string $date, bool $contains): void { $this->assertSame($contains, LocalDateRange::parse($range)->contains(LocalDate::parse($date))); } - /** - * @return array - */ public function providerContains() : array { return [ @@ -150,7 +134,7 @@ public function providerContains() : array ]; } - public function testIterator() + public function testIterator(): void { $start = LocalDate::of(2013, 12, 29); $end = LocalDate::of(2014, 1, 3); @@ -183,14 +167,11 @@ public function testIterator() * @param string $range The date range string representation. * @param int $count The expected day count. */ - public function testCount(string $range, int $count) + public function testCount(string $range, int $count): void { $this->assertCount($count, LocalDateRange::parse($range)); } - /** - * @return array - */ public function providerCount() : array { return [ @@ -203,7 +184,7 @@ public function providerCount() : array ]; } - public function testJsonSerialize() + public function testJsonSerialize(): void { $this->assertSame(json_encode('2008-12-31/2011-01-01'), json_encode(LocalDateRange::of( LocalDate::of(2008, 12, 31), @@ -211,7 +192,7 @@ public function testJsonSerialize() ))); } - public function testToString() + public function testToString(): void { $this->assertSame('2008-12-31/2011-01-01', (string) LocalDateRange::of( LocalDate::of(2008, 12, 31), @@ -222,11 +203,11 @@ public function testToString() /** * @dataProvider providerToDatePeriod * - * @param string $range The date-time string that will be parse()d by LocalDateRange. + * @param string $range The date-time string that will be parse()d by LocalDateRange. * @param string $expectedStart The expected output from the native DateTime object. - * @param string $expectedEnd The expected output from the native DateTime object. + * @param string $expectedEnd The expected output from the native DateTime object. */ - public function testToDatePeriod(string $range, string $expectedStart, string $expectedEnd) + public function testToDatePeriod(string $range, string $expectedStart, string $expectedEnd): void { $range = LocalDateRange::parse($range); @@ -235,6 +216,7 @@ public function testToDatePeriod(string $range, string $expectedStart, string $e $rangeArray = iterator_to_array($range); $periodArray = iterator_to_array($period); $zip = array_map(null, $rangeArray, $periodArray); + foreach ($zip as [$date, $dateTime]) { $this->assertTrue($date->isEqualTo(LocalDate::fromDateTime($dateTime))); } @@ -244,9 +226,6 @@ public function testToDatePeriod(string $range, string $expectedStart, string $e $this->assertSame($expectedEnd, $period->end->format('Y-m-d\TH:i:s.uO')); } - /** - * @return array - */ public function providerToDatePeriod(): array { return [ @@ -258,12 +237,8 @@ public function providerToDatePeriod(): array /** * @dataProvider providerIntersectsWith - * - * @param string $a - * @param string $b - * @param bool $expectedResult */ - public function testIntersectsWith(string $a, string $b, bool $expectedResult) + public function testIntersectsWith(string $a, string $b, bool $expectedResult): void { $aRange = LocalDateRange::parse($a); $bRange = LocalDateRange::parse($b); @@ -289,12 +264,8 @@ public function providerIntersectsWith() : array /** * @dataProvider providerGetIntersectionWith - * - * @param string $a - * @param string $b - * @param string $expectedIntersection */ - public function testGetIntersectionWith(string $a, string $b, string $expectedIntersection) + public function testGetIntersectionWith(string $a, string $b, string $expectedIntersection): void { $aRange = LocalDateRange::parse($a); $bRange = LocalDateRange::parse($b); @@ -315,7 +286,7 @@ public function providerGetIntersectionWith() : array ]; } - public function testGetIntersectionInvalidParams() + public function testGetIntersectionInvalidParams(): void { $aRange = LocalDateRange::parse('2010-01-01/2010-03-01'); $bRange = LocalDateRange::parse('2033-01-02/2033-01-02'); diff --git a/tests/LocalDateTest.php b/tests/LocalDateTest.php index fd5c401..73e5040 100644 --- a/tests/LocalDateTest.php +++ b/tests/LocalDateTest.php @@ -18,7 +18,7 @@ */ class LocalDateTest extends AbstractTestCase { - public function testOf() + public function testOf(): void { $this->assertLocalDateIs(2007, 7, 15, LocalDate::of(2007, 7, 15)); } @@ -30,15 +30,12 @@ public function testOf() * @param int $month The month of the invalid date. * @param int $day The day of the invalid date. */ - public function testOfInvalidDateThrowsException(int $year, int $month, int $day) + public function testOfInvalidDateThrowsException(int $year, int $month, int $day): void { $this->expectException(DateTimeException::class); LocalDate::of($year, $month, $day); } - /** - * @return array - */ public function providerOfInvalidDateThrowsException() : array { return [ @@ -59,15 +56,12 @@ public function providerOfInvalidDateThrowsException() : array * @param int $year The year. * @param int $dayOfYear The day-of-year. */ - public function testOfInvalidYearDayThrowsException(int $year, int $dayOfYear) + public function testOfInvalidYearDayThrowsException(int $year, int $dayOfYear): void { $this->expectException(DateTimeException::class); LocalDate::ofYearDay($year, $dayOfYear); } - /** - * @return array - */ public function providerOfInvalidYearDayThrowsException() : array { return [ @@ -87,12 +81,12 @@ public function providerOfInvalidYearDayThrowsException() : array * @param int $month The expected month. * @param int $day The expected day. */ - public function testOfEpochDay(int $epochDay, int $year, int $month, int $day) + public function testOfEpochDay(int $epochDay, int $year, int $month, int $day): void { $this->assertLocalDateIs($year, $month, $day, LocalDate::ofEpochDay($epochDay)); } - public function testOfEpochDayOutOfRangeThrowsException() + public function testOfEpochDayOutOfRangeThrowsException(): void { $this->expectException(DateTimeException::class); LocalDate::ofEpochDay(500000000); @@ -106,14 +100,11 @@ public function testOfEpochDayOutOfRangeThrowsException() * @param int $month The month. * @param int $day The day. */ - public function testToEpochDay(int $epochDay, int $year, int $month, int $day) + public function testToEpochDay(int $epochDay, int $year, int $month, int $day): void { $this->assertSame($epochDay, LocalDate::of($year, $month, $day)->toEpochDay()); } - /** - * @return array - */ public function providerEpochDay() : array { return [ @@ -135,7 +126,7 @@ public function providerEpochDay() : array ]; } - public function testFromDateTime() + public function testFromDateTime(): void { $dateTime = new \DateTime('2018-07-21'); $this->assertLocalDateIs(2018, 7, 21, LocalDate::fromDateTime($dateTime)); @@ -150,15 +141,12 @@ public function testFromDateTime() * @param int $month The expected month. * @param int $day The expected day. */ - public function testNow(int $epochSecond, string $timeZone, int $year, int $month, int $day) + public function testNow(int $epochSecond, string $timeZone, int $year, int $month, int $day): void { $clock = new FixedClock(Instant::of($epochSecond)); $this->assertLocalDateIs($year, $month, $day, LocalDate::now(TimeZone::parse($timeZone), $clock)); } - /** - * @return array - */ public function providerNow() : array { return [ @@ -169,31 +157,24 @@ public function providerNow() : array ]; } - public function testMin() + public function testMin(): void { $this->assertLocalDateIs(Year::MIN_VALUE, 1, 1, LocalDate::min()); } - public function testMax() + public function testMax(): void { $this->assertLocalDateIs(Year::MAX_VALUE, 12, 31, LocalDate::max()); } /** * @dataProvider providerGetYearMonth - * - * @param int $year - * @param int $month - * @param int $day */ - public function testGetYearMonth(int $year, int $month, int $day) + public function testGetYearMonth(int $year, int $month, int $day): void { $this->assertYearMonthIs($year, $month, LocalDate::of($year, $month, $day)->getYearMonth()); } - /** - * @return array - */ public function providerGetYearMonth() : array { return [ @@ -211,14 +192,11 @@ public function providerGetYearMonth() : array * @param int $day The day-of-month to test. * @param int $dayOfWeek The expected day-of-week number. */ - public function testGetDayOfWeek(int $year, int $month, int $day, int $dayOfWeek) + public function testGetDayOfWeek(int $year, int $month, int $day, int $dayOfWeek): void { $this->assertDayOfWeekIs($dayOfWeek, LocalDate::of($year, $month, $day)->getDayOfWeek()); } - /** - * @return array - */ public function providerDayOfWeek() : array { return [ @@ -257,7 +235,7 @@ public function providerDayOfWeek() : array * @param int $day The expected day. * @param int $dayOfYear The day-of-year. */ - public function testOfYearDay(int $year, int $month, int $day, int $dayOfYear) + public function testOfYearDay(int $year, int $month, int $day, int $dayOfYear): void { $this->assertLocalDateIs($year, $month, $day, LocalDate::ofYearDay($year, $dayOfYear)); } @@ -270,14 +248,11 @@ public function testOfYearDay(int $year, int $month, int $day, int $dayOfYear) * @param int $day The day-of-month to test. * @param int $dayOfYear The expected day-of-year number. */ - public function testGetDayOfYear(int $year, int $month, int $day, int $dayOfYear) + public function testGetDayOfYear(int $year, int $month, int $day, int $dayOfYear): void { $this->assertSame($dayOfYear, LocalDate::of($year, $month, $day)->getDayOfYear()); } - /** - * @return array - */ public function providerDayOfYear() : array { return [ @@ -332,9 +307,6 @@ public function providerDayOfYear() : array ]; } - /** - * @return array - */ public function providerGetYearWeek() : array { return [ @@ -479,14 +451,8 @@ public function providerGetYearWeek() : array /** * @dataProvider providerGetYearWeek - * - * @param int $year - * @param int $month - * @param int $day - * @param int $expectedYear - * @param int $expectedWeek */ - public function testGetYearWeek(int $year, int $month, int $day, int $expectedYear, int $expectedWeek) + public function testGetYearWeek(int $year, int $month, int $day, int $expectedYear, int $expectedWeek): void { $yearWeek = LocalDate::of($year, $month, $day)->getYearWeek(); $this->assertYearWeekIs($expectedYear, $expectedWeek, $yearWeek); @@ -501,15 +467,12 @@ public function testGetYearWeek(int $year, int $month, int $day, int $expectedYe * @param int $newYear The new year. * @param int $expectedDay The expected day-of-month of the resulting date. */ - public function testWithYear(int $year, int $month, int $day, int $newYear, int $expectedDay) + public function testWithYear(int $year, int $month, int $day, int $newYear, int $expectedDay): void { $localDate = LocalDate::of($year, $month, $day)->withYear($newYear); $this->assertLocalDateIs($newYear, $month, $expectedDay, $localDate); } - /** - * @return array - */ public function providerWithYear() : array { return [ @@ -527,15 +490,12 @@ public function providerWithYear() : array * * @param int $invalidYear The year to test. */ - public function testWithInvalidYearThrowsException(int $invalidYear) + public function testWithInvalidYearThrowsException(int $invalidYear): void { $this->expectException(DateTimeException::class); LocalDate::of(2001, 2, 3)->withYear($invalidYear); } - /** - * @return array - */ public function providerWithInvalidYearThrowsException() : array { return [ @@ -553,15 +513,12 @@ public function providerWithInvalidYearThrowsException() : array * @param int $newMonth The new month. * @param int $expectedDay The expected day-of-month of the resulting date. */ - public function testWithMonth(int $year, int $month, int $day, int $newMonth, int $expectedDay) + public function testWithMonth(int $year, int $month, int $day, int $newMonth, int $expectedDay): void { $localDate = LocalDate::of($year, $month, $day)->withMonth($newMonth); $this->assertLocalDateIs($year, $newMonth, $expectedDay, $localDate); } - /** - * @return array - */ public function providerWithMonth() : array { return [ @@ -587,15 +544,12 @@ public function providerWithMonth() : array * * @param int $invalidMonth The month to test. */ - public function testWithInvalidMonthThrowsException(int $invalidMonth) + public function testWithInvalidMonthThrowsException(int $invalidMonth): void { $this->expectException(DateTimeException::class); LocalDate::of(2001, 2, 3)->atTime(LocalTime::of(4, 5, 6))->withMonth($invalidMonth); } - /** - * @return array - */ public function providerWithInvalidMonthThrowsException() : array { return [ @@ -612,15 +566,12 @@ public function providerWithInvalidMonthThrowsException() : array * @param int $day The base day-of-month. * @param int $newDay The new day-of-month. */ - public function testWithDay(int $year, int $month, int $day, int $newDay) + public function testWithDay(int $year, int $month, int $day, int $newDay): void { $localDate = LocalDate::of($year, $month, $day)->withDay($newDay); $this->assertLocalDateIs($year, $month, $newDay, $localDate); } - /** - * @return array - */ public function providerWithDay() : array { return [ @@ -639,15 +590,12 @@ public function providerWithDay() : array * @param int $day The base day-of-month. * @param int $newDay The new day-of-month. */ - public function testWithInvalidDayThrowsException(int $year, int $month, int $day, int $newDay) + public function testWithInvalidDayThrowsException(int $year, int $month, int $day, int $newDay): void { $this->expectException(DateTimeException::class); LocalDate::of($year, $month, $day)->withDay($newDay); } - /** - * @return array - */ public function providerWithInvalidDayThrowsException() : array { return [ @@ -672,7 +620,7 @@ public function providerWithInvalidDayThrowsException() : array * @param int $em The expected month of the result date. * @param int $ed The expected day of the result date. */ - public function testPlusPeriod(int $y, int $m, int $d, int $py, int $pm, int $pd, int $ey, int $em, int $ed) + public function testPlusPeriod(int $y, int $m, int $d, int $py, int $pm, int $pd, int $ey, int $em, int $ed): void { $date = LocalDate::of($y, $m, $d); $period = Period::of($py, $pm, $pd); @@ -693,7 +641,7 @@ public function testPlusPeriod(int $y, int $m, int $d, int $py, int $pm, int $pd * @param int $em The expected month of the result date. * @param int $ed The expected day of the result date. */ - public function testMinusPeriod(int $y, int $m, int $d, int $py, int $pm, int $pd, int $ey, int $em, int $ed) + public function testMinusPeriod(int $y, int $m, int $d, int $py, int $pm, int $pd, int $ey, int $em, int $ed): void { $date = LocalDate::of($y, $m, $d); $period = Period::of(-$py, -$pm, -$pd); @@ -701,9 +649,6 @@ public function testMinusPeriod(int $y, int $m, int $d, int $py, int $pm, int $p $this->assertLocalDateIs($ey, $em, $ed, $date->minusPeriod($period)); } - /** - * @return array - */ public function providerPeriod() : array { return [ @@ -732,14 +677,11 @@ public function providerPeriod() : array * @param int $em The expected resulting month. * @param int $ed The expected resulting day. */ - public function testPlusYears(int $y, int $m, int $d, int $ay, int $ey, int $em, int $ed) + public function testPlusYears(int $y, int $m, int $d, int $ay, int $ey, int $em, int $ed): void { $this->assertLocalDateIs($ey, $em, $ed, LocalDate::of($y, $m, $d)->plusYears($ay)); } - /** - * @return array - */ public function providerPlusYears() : array { return [ @@ -762,14 +704,11 @@ public function providerPlusYears() : array * @param int $em The expected resulting month. * @param int $ed The expected resulting day. */ - public function testPlusMonths(int $y, int $m, int $d, int $am, int $ey, int $em, int $ed) + public function testPlusMonths(int $y, int $m, int $d, int $am, int $ey, int $em, int $ed): void { $this->assertLocalDateIs($ey, $em, $ed, LocalDate::of($y, $m, $d)->plusMonths($am)); } - /** - * @return array - */ public function providerPlusMonths() : array { return [ @@ -801,14 +740,11 @@ public function providerPlusMonths() : array * @param int $em The expected resulting month. * @param int $ed The expected resulting day. */ - public function testPlusWeeks(int $y, int $m, int $d, int $aw, int $ey, int $em, int $ed) + public function testPlusWeeks(int $y, int $m, int $d, int $aw, int $ey, int $em, int $ed): void { $this->assertLocalDateIs($ey, $em, $ed, LocalDate::of($y, $m, $d)->plusWeeks($aw)); } - /** - * @return array - */ public function providerPlusWeeks() : array { return [ @@ -833,14 +769,11 @@ public function providerPlusWeeks() : array * @param int $em The expected resulting month. * @param int $ed The expected resulting day. */ - public function testPlusDays(int $y, int $m, int $d, int $ad, int $ey, int $em, int $ed) + public function testPlusDays(int $y, int $m, int $d, int $ad, int $ey, int $em, int $ed): void { $this->assertLocalDateIs($ey, $em, $ed, LocalDate::of($y, $m, $d)->plusDays($ad)); } - /** - * @return array - */ public function providerPlusDays() : array { return [ @@ -866,14 +799,11 @@ public function providerPlusDays() : array * @param int $em The expected resulting month. * @param int $ed The expected resulting day. */ - public function tesMinusYears(int $y, int $m, int $d, int $sy, int $ey, int $em, int $ed) + public function tesMinusYears(int $y, int $m, int $d, int $sy, int $ey, int $em, int $ed): void { $this->assertLocalDateIs($ey, $em, $ed, LocalDate::of($y, $m, $d)->minusYears($sy)); } - /** - * @return array - */ public function providerMinusYears() : array { return [ @@ -896,14 +826,11 @@ public function providerMinusYears() : array * @param int $em The expected resulting month. * @param int $ed The expected resulting day. */ - public function testMinusMonths(int $y, int $m, int $d, int $sm, int $ey, int $em, int $ed) + public function testMinusMonths(int $y, int $m, int $d, int $sm, int $ey, int $em, int $ed): void { $this->assertLocalDateIs($ey, $em, $ed, LocalDate::of($y, $m, $d)->minusMonths($sm)); } - /** - * @return array - */ public function providerMinusMonths() : array { return [ @@ -935,14 +862,11 @@ public function providerMinusMonths() : array * @param int $em The expected resulting month. * @param int $ed The expected resulting day. */ - public function testMinusWeeks(int $y, int $m, int $d, int $sw, int $ey, int $em, int $ed) + public function testMinusWeeks(int $y, int $m, int $d, int $sw, int $ey, int $em, int $ed): void { $this->assertLocalDateIs($ey, $em, $ed, LocalDate::of($y, $m, $d)->minusWeeks($sw)); } - /** - * @return array - */ public function providerMinusWeeks() : array { return [ @@ -967,14 +891,11 @@ public function providerMinusWeeks() : array * @param int $em The expected resulting month. * @param int $ed The expected resulting day. */ - public function testMinusDays(int $y, int $m, int $d, int $sd, int $ey, int $em, int $ed) + public function testMinusDays(int $y, int $m, int $d, int $sd, int $ey, int $em, int $ed): void { $this->assertLocalDateIs($ey, $em, $ed, LocalDate::of($y, $m, $d)->minusDays($sd)); } - /** - * @return array - */ public function providerMinusDays() : array { return [ @@ -1002,7 +923,7 @@ public function providerMinusDays() : array * @param int $m The expected number of months in the period. * @param int $d The expected number of days in the period. */ - public function testUntil(int $y1, int $m1, int $d1, int $y2, int $m2, int $d2, int $y, int $m, int $d) + public function testUntil(int $y1, int $m1, int $d1, int $y2, int $m2, int $d2, int $y, int $m, int $d): void { $date1 = LocalDate::of($y1, $m1, $d1); $date2 = LocalDate::of($y2, $m2, $d2); @@ -1010,9 +931,6 @@ public function testUntil(int $y1, int $m1, int $d1, int $y2, int $m2, int $d2, $this->assertPeriodIs($y, $m, $d, $date1->until($date2)); } - /** - * @return array - */ public function providerUntil() : array { return [ @@ -1111,12 +1029,8 @@ public function providerUntil() : array /** * @dataProvider providerDaysUntil - * - * @param string $date1 - * @param string $date2 - * @param int $expectedDays */ - public function testDaysUntil(string $date1, string $date2, int $expectedDays) + public function testDaysUntil(string $date1, string $date2, int $expectedDays): void { $date1 = LocalDate::parse($date1); $date2 = LocalDate::parse($date2); @@ -1124,9 +1038,6 @@ public function testDaysUntil(string $date1, string $date2, int $expectedDays) $this->assertSame($expectedDays, $date1->daysUntil($date2)); } - /** - * @return array - */ public function providerDaysUntil() : array { return [ @@ -1138,7 +1049,7 @@ public function providerDaysUntil() : array ]; } - public function testAtTime() + public function testAtTime(): void { $localDateTime = LocalDate::of(1, 2, 3)->atTime(LocalTime::of(4, 5, 6, 7)); $this->assertLocalDateTimeIs(1, 2, 3, 4, 5, 6, 7, $localDateTime); @@ -1152,7 +1063,7 @@ public function testAtTime() * @param int $d The day of the date to test (should not matter). * @param bool $isLeap Whether the year is a leap year. */ - public function testIsLeapYear(int $y, int $m, int $d, bool $isLeap) + public function testIsLeapYear(int $y, int $m, int $d, bool $isLeap): void { $this->assertSame($isLeap, LocalDate::of($y, $m, $d)->isLeapYear()); } @@ -1165,14 +1076,11 @@ public function testIsLeapYear(int $y, int $m, int $d, bool $isLeap) * @param int $d The day of the date to test (should not matter). * @param bool $isLeap Whether the year is a leap year. */ - public function testGetLengthOfYear(int $y, int $m, int $d, bool $isLeap) + public function testGetLengthOfYear(int $y, int $m, int $d, bool $isLeap): void { $this->assertSame($isLeap ? 366 : 365, LocalDate::of($y, $m, $d)->getLengthOfYear()); } - /** - * @return array - */ public function providerIsLeapYear() : array { return [ @@ -1196,14 +1104,11 @@ public function providerIsLeapYear() : array * @param int $d The day of the date to test (should not matter). * @param int $length The length of the month. */ - public function testGetLengthOfMonth(int $y, int $m, int $d, int $length) + public function testGetLengthOfMonth(int $y, int $m, int $d, int $length): void { $this->assertSame($length, LocalDate::of($y, $m, $d)->getLengthOfMonth()); } - /** - * @return array - */ public function providerGetLengthOfMonth() : array { return [ @@ -1230,7 +1135,7 @@ public function providerGetLengthOfMonth() : array * @param string $date2 The second date. * @param int $cmp The comparison value. */ - public function testCompareTo(string $date1, string $date2, int $cmp) + public function testCompareTo(string $date1, string $date2, int $cmp): void { $date1 = LocalDate::parse($date1); $date2 = LocalDate::parse($date2); @@ -1243,9 +1148,6 @@ public function testCompareTo(string $date1, string $date2, int $cmp) $this->assertSame($cmp >= 0, $date1->isAfterOrEqualTo($date2)); } - /** - * @return array - */ public function providerCompareTo() : array { return [ @@ -1269,7 +1171,7 @@ public function providerCompareTo() : array * @param int $day The day-of-month. * @param string $expected The expected result string. */ - public function testJsonSerialize(int $year, int $month, int $day, string $expected) + public function testJsonSerialize(int $year, int $month, int $day, string $expected): void { $this->assertSame(json_encode($expected), json_encode(LocalDate::of($year, $month, $day))); } @@ -1282,14 +1184,11 @@ public function testJsonSerialize(int $year, int $month, int $day, string $expec * @param int $day The day-of-month. * @param string $expected The expected result string. */ - public function testToString(int $year, int $month, int $day, string $expected) + public function testToString(int $year, int $month, int $day, string $expected): void { $this->assertSame($expected, (string) LocalDate::of($year, $month, $day)); } - /** - * @return array - */ public function providerToString() : array { return [ @@ -1298,7 +1197,7 @@ public function providerToString() : array ]; } - public function testMinMaxOf() + public function testMinMaxOf(): void { $a = LocalDate::of(2015, 9, 30); $b = LocalDate::of(2016, 7, 31); @@ -1308,13 +1207,13 @@ public function testMinMaxOf() $this->assertSame($c, LocalDate::maxOf($a, $b, $c)); } - public function testMinOfZeroElementsThrowsException() + public function testMinOfZeroElementsThrowsException(): void { $this->expectException(DateTimeException::class); LocalDate::minOf(); } - public function testMaxOfZeroElementsThrowsException() + public function testMaxOfZeroElementsThrowsException(): void { $this->expectException(DateTimeException::class); LocalDate::maxOf(); @@ -1326,7 +1225,7 @@ public function testMaxOfZeroElementsThrowsException() * @param string $dateTime The date-time string that will be parse()d by LocalDate. * @param string $expected The expected output from the native DateTime object. */ - public function testToDateTime(string $dateTime, string $expected) + public function testToDateTime(string $dateTime, string $expected): void { $zonedDateTime = LocalDate::parse($dateTime); $dateTime = $zonedDateTime->toDateTime(); @@ -1341,7 +1240,7 @@ public function testToDateTime(string $dateTime, string $expected) * @param string $dateTime The date-time string that will be parse()d by LocalDate. * @param string $expected The expected output from the native DateTime object. */ - public function testToDateTimeImmutable(string $dateTime, string $expected) + public function testToDateTimeImmutable(string $dateTime, string $expected): void { $zonedDateTime = LocalDate::parse($dateTime); $dateTime = $zonedDateTime->toDateTimeImmutable(); @@ -1350,10 +1249,7 @@ public function testToDateTimeImmutable(string $dateTime, string $expected) $this->assertSame($expected, $dateTime->format('Y-m-d\TH:i:s.uO')); } - /** - * @return array - */ - public function providerToDateTime() + public function providerToDateTime(): array { return [ ['2011-07-31', '2011-07-31T00:00:00.000000+0000'], diff --git a/tests/LocalDateTimeTest.php b/tests/LocalDateTimeTest.php index 007c508..cb9caef 100644 --- a/tests/LocalDateTimeTest.php +++ b/tests/LocalDateTimeTest.php @@ -16,14 +16,13 @@ use Brick\DateTime\Period; use Brick\DateTime\TimeZone; use Brick\DateTime\TimeZoneOffset; -use Brick\DateTime\ZonedDateTime; /** * Unit tests for class LocalDateTime. */ class LocalDateTimeTest extends AbstractTestCase { - public function testOf() + public function testOf(): void { $date = LocalDate::of(2001, 12, 23); $time = LocalTime::of(12, 34, 56, 987654321); @@ -31,7 +30,7 @@ public function testOf() $this->assertLocalDateTimeIs(2001, 12, 23, 12, 34, 56, 987654321, new LocalDateTime($date, $time)); } - public function testFromDateTime() + public function testFromDateTime(): void { $dateTime = new \DateTime('2018-07-21 14:09:10.23456'); $this->assertLocalDateTimeIs(2018, 7, 21, 14, 9, 10, 234560000, LocalDateTime::fromDateTime($dateTime)); @@ -51,16 +50,13 @@ public function testFromDateTime() * @param int $s The expected second. * @param int $n The expected nano. */ - public function testNow(int $second, int $nano, int $offset, int $y, int $m, int $d, int $h, int $i, int $s, int $n) + public function testNow(int $second, int $nano, int $offset, int $y, int $m, int $d, int $h, int $i, int $s, int $n): void { $clock = new FixedClock(Instant::of($second, $nano)); $timeZone = TimeZoneOffset::ofTotalSeconds($offset); $this->assertLocalDateTimeIs($y, $m, $d, $h, $i, $s, $n, LocalDateTime::now($timeZone, $clock)); } - /** - * @return array - */ public function providerNow() : array { return [ @@ -83,14 +79,11 @@ public function providerNow() : array * @param int $s The expected second. * @param int $n The expected nano-of-second. */ - public function testParse(string $t, int $y, int $m, int $d, int $h, int $i, int $s, int $n) + public function testParse(string $t, int $y, int $m, int $d, int $h, int $i, int $s, int $n): void { $this->assertLocalDateTimeIs($y, $m, $d, $h, $i, $s, $n, LocalDateTime::parse($t)); } - /** - * @return array - */ public function providerParse() : array { return [ @@ -103,18 +96,13 @@ public function providerParse() : array /** * @dataProvider providerParseInvalidStringThrowsException - * - * @param string $text */ - public function testParseInvalidStringThrowsException(string $text) + public function testParseInvalidStringThrowsException(string $text): void { $this->expectException(DateTimeParseException::class); LocalDateTime::parse($text); } - /** - * @return array - */ public function providerParseInvalidStringThrowsException() : array { return [ @@ -144,18 +132,13 @@ public function providerParseInvalidStringThrowsException() : array /** * @dataProvider providerParseInvalidDateTimeThrowsException - * - * @param string $text */ - public function testParseInvalidDateTimeThrowsException(string $text) + public function testParseInvalidDateTimeThrowsException(string $text): void { $this->expectException(DateTimeException::class); LocalDateTime::parse($text); } - /** - * @return array - */ public function providerParseInvalidDateTimeThrowsException() : array { return [ @@ -170,17 +153,17 @@ public function providerParseInvalidDateTimeThrowsException() : array ]; } - public function testMin() + public function testMin(): void { $this->assertLocalDateTimeIs(Year::MIN_VALUE, 1, 1, 0, 0, 0, 0, LocalDateTime::min()); } - public function testMax() + public function testMax(): void { $this->assertLocalDateTimeIs(Year::MAX_VALUE, 12, 31, 23, 59, 59, 999999999, LocalDateTime::max()); } - public function testMinMaxOf() + public function testMinMaxOf(): void { $a = LocalDateTime::parse('2003-12-31T12:30:00'); $b = LocalDateTime::parse('2005-12-31T23:59:59.999999999'); @@ -190,13 +173,13 @@ public function testMinMaxOf() $this->assertSame($c, LocalDateTime::maxOf($a, $b, $c)); } - public function testMinOfZeroElementsThrowsException() + public function testMinOfZeroElementsThrowsException(): void { $this->expectException(DateTimeException::class); LocalDateTime::minOf(); } - public function testMaxOfZeroElementsThrowsException() + public function testMaxOfZeroElementsThrowsException(): void { $this->expectException(DateTimeException::class); LocalDateTime::maxOf(); @@ -210,15 +193,12 @@ public function testMaxOfZeroElementsThrowsException() * @param int $day The day-of-month to test. * @param int $dayOfWeek The expected day-of-week number. */ - public function testGetDayOfWeek(int $year, int $month, int $day, int $dayOfWeek) + public function testGetDayOfWeek(int $year, int $month, int $day, int $dayOfWeek): void { $dateTime = LocalDateTime::of($year, $month, $day, 15, 30, 45); $this->assertDayOfWeekIs($dayOfWeek, $dateTime->getDayOfWeek()); } - /** - * @return array - */ public function providerGetDayOfWeek() : array { return [ @@ -247,15 +227,12 @@ public function providerGetDayOfWeek() : array * @param int $day The day-of-month to test. * @param int $dayOfYear The expected day-of-year number. */ - public function testGetDayOfYear(int $year, int $month, int $day, int $dayOfYear) + public function testGetDayOfYear(int $year, int $month, int $day, int $dayOfYear): void { $dateTime = LocalDate::of($year, $month, $day)->atTime(LocalTime::midnight()); $this->assertSame($dayOfYear, $dateTime->getDayOfYear()); } - /** - * @return array - */ public function providerGetDayOfYear() : array { return [ @@ -270,20 +247,17 @@ public function providerGetDayOfYear() : array /** * @dataProvider providerWithDate * - * @param int $y The new year. - * @param int $m The new month. - * @param int $d The new day. + * @param int $y The new year. + * @param int $m The new month. + * @param int $d The new day. */ - public function testWithDate(int $y, int $m, int $d) + public function testWithDate(int $y, int $m, int $d): void { $dateTime = LocalDate::of(2001, 2, 3)->atTime(LocalTime::of(4, 5, 6, 789)); $newDate = LocalDate::of($y, $m, $d); $this->assertLocalDateTimeIs($y, $m, $d, 4, 5, 6, 789, $dateTime->withDate($newDate)); } - /** - * @return array - */ public function providerWithDate() : array { return [ @@ -300,16 +274,13 @@ public function providerWithDate() : array * @param int $s The new second. * @param int $n The new nano. */ - public function testWithTime(int $h, int $m, int $s, int $n) + public function testWithTime(int $h, int $m, int $s, int $n): void { $dateTime = LocalDate::of(2001, 2, 3)->atTime(LocalTime::of(4, 5, 6, 789)); $newTime = LocalTime::of($h, $m, $s, $n); $this->assertLocalDateTimeIs(2001, 2, 3, $h, $m, $s, $n, $dateTime->withTime($newTime)); } - /** - * @return array - */ public function providerWithTime() : array { return [ @@ -327,7 +298,7 @@ public function providerWithTime() : array * @param int $newYear The new year. * @param int $expectedDay The expected day-of-month of the resulting date. */ - public function testWithYear(int $year, int $month, int $day, int $newYear, int $expectedDay) + public function testWithYear(int $year, int $month, int $day, int $newYear, int $expectedDay): void { $date = LocalDate::of($year, $month, $day); $time = LocalTime::of(1, 2, 3, 123456789); @@ -335,9 +306,6 @@ public function testWithYear(int $year, int $month, int $day, int $newYear, int $this->assertLocalDateTimeIs($newYear, $month, $expectedDay, 1, 2, 3, 123456789, $localDateTime); } - /** - * @return array - */ public function providerWithYear() : array { return [ @@ -355,15 +323,12 @@ public function providerWithYear() : array * * @param int $invalidYear The year to test. */ - public function testWithInvalidYearThrowsException(int $invalidYear) + public function testWithInvalidYearThrowsException(int $invalidYear): void { $this->expectException(DateTimeException::class); LocalDate::of(2001, 2, 3)->atTime(LocalTime::of(4, 5, 6))->withYear($invalidYear); } - /** - * @return array - */ public function providerWithInvalidYearThrowsException() : array { return [ @@ -381,7 +346,7 @@ public function providerWithInvalidYearThrowsException() : array * @param int $newMonth The new month. * @param int $expectedDay The expected day-of-month of the resulting date. */ - public function testWithMonth(int $year, int $month, int $day, int $newMonth, int $expectedDay) + public function testWithMonth(int $year, int $month, int $day, int $newMonth, int $expectedDay): void { $date = LocalDate::of($year, $month, $day); $time = LocalTime::of(1, 2, 3, 123456789); @@ -389,9 +354,6 @@ public function testWithMonth(int $year, int $month, int $day, int $newMonth, in $this->assertLocalDateTimeIs($year, $newMonth, $expectedDay, 1, 2, 3, 123456789, $localDateTime); } - /** - * @return array - */ public function providerWithMonth() : array { return [ @@ -417,15 +379,12 @@ public function providerWithMonth() : array * * @param int $invalidMonth The month to test. */ - public function testWithInvalidMonthThrowsException(int $invalidMonth) + public function testWithInvalidMonthThrowsException(int $invalidMonth): void { $this->expectException(DateTimeException::class); LocalDate::of(2001, 2, 3)->atTime(LocalTime::of(4, 5, 6))->withMonth($invalidMonth); } - /** - * @return array - */ public function providerWithInvalidMonthThrowsException() : array { return [ @@ -442,7 +401,7 @@ public function providerWithInvalidMonthThrowsException() : array * @param int $day The base day-of-month. * @param int $newDay The new day-of-month. */ - public function testWithDay(int $year, int $month, int $day, int $newDay) + public function testWithDay(int $year, int $month, int $day, int $newDay): void { $date = LocalDate::of($year, $month, $day); $time = LocalTime::of(1, 2, 3, 123456789); @@ -450,9 +409,6 @@ public function testWithDay(int $year, int $month, int $day, int $newDay) $this->assertLocalDateTimeIs($year, $month, $newDay, 1, 2, 3, 123456789, $localDateTime); } - /** - * @return array - */ public function providerWithDay() : array { return [ @@ -471,15 +427,12 @@ public function providerWithDay() : array * @param int $day The base day-of-month. * @param int $newDay The new day-of-month. */ - public function testWithInvalidDayThrowsException(int $year, int $month, int $day, int $newDay) + public function testWithInvalidDayThrowsException(int $year, int $month, int $day, int $newDay): void { $this->expectException(DateTimeException::class); LocalDate::of($year, $month, $day)->atTime(LocalTime::midnight())->withDay($newDay); } - /** - * @return array - */ public function providerWithInvalidDayThrowsException() : array { return [ @@ -496,15 +449,12 @@ public function providerWithInvalidDayThrowsException() : array * * @param int $hour The new hour. */ - public function testWithHour(int $hour) + public function testWithHour(int $hour): void { $localDateTime = LocalDate::of(2001, 2, 3)->atTime(LocalTime::of(12, 34, 56, 123456789)); $this->assertLocalDateTimeIs(2001, 2, 3, $hour, 34, 56, 123456789, $localDateTime->withHour($hour)); } - /** - * @return array - */ public function providerWithHour() : array { return [ @@ -518,15 +468,12 @@ public function providerWithHour() : array * * @param int $invalidHour */ - public function testWithInvalidHourThrowsException(int $invalidHour) + public function testWithInvalidHourThrowsException(int $invalidHour): void { $this->expectException(DateTimeException::class); LocalDate::of(2001, 2, 3)->atTime(LocalTime::of(4, 5, 6))->withHour($invalidHour); } - /** - * @return array - */ public function providerWithInvalidHourThrowsException() : array { return [ @@ -540,15 +487,12 @@ public function providerWithInvalidHourThrowsException() : array * * @param int $minute The new minute. */ - public function testWithMinute(int $minute) + public function testWithMinute(int $minute): void { $localDateTime = LocalDate::of(2001, 2, 3)->atTime(LocalTime::of(12, 34, 56, 123456789)); $this->assertLocalDateTimeIs(2001, 2, 3, 12, $minute, 56, 123456789, $localDateTime->withMinute($minute)); } - /** - * @return array - */ public function providerWithMinute() : array { return [ @@ -559,18 +503,13 @@ public function providerWithMinute() : array /** * @dataProvider providerWithInvalidMinuteThrowsException - * - * @param int $invalidMinute */ - public function testWithInvalidMinuteThrowsException(int $invalidMinute) + public function testWithInvalidMinuteThrowsException(int $invalidMinute): void { $this->expectException(DateTimeException::class); LocalDate::of(2001, 2, 3)->atTime(LocalTime::of(4, 5, 6))->withMinute($invalidMinute); } - /** - * @return array - */ public function providerWithInvalidMinuteThrowsException() : array { return [ @@ -584,15 +523,12 @@ public function providerWithInvalidMinuteThrowsException() : array * * @param int $second The new second. */ - public function testWithSecond(int $second) + public function testWithSecond(int $second): void { $localDateTime = LocalDate::of(2001, 2, 3)->atTime(LocalTime::of(12, 34, 56, 123456789)); $this->assertLocalDateTimeIs(2001, 2, 3, 12, 34, $second, 123456789, $localDateTime->withSecond($second)); } - /** - * @return array - */ public function providerWithSecond() : array { return [ @@ -603,18 +539,13 @@ public function providerWithSecond() : array /** * @dataProvider providerWithInvalidSecondThrowsException - * - * @param int $invalidSecond */ - public function testWithInvalidSecondThrowsException(int $invalidSecond) + public function testWithInvalidSecondThrowsException(int $invalidSecond): void { $this->expectException(DateTimeException::class); LocalDate::of(2001, 2, 3)->atTime(LocalTime::of(4, 5, 6))->withSecond($invalidSecond); } - /** - * @return array - */ public function providerWithInvalidSecondThrowsException() : array { return [ @@ -628,15 +559,12 @@ public function providerWithInvalidSecondThrowsException() : array * * @param int $nano The new nano. */ - public function testWithNano(int $nano) + public function testWithNano(int $nano): void { $localDateTime = LocalDate::of(2001, 2, 3)->atTime(LocalTime::of(12, 34, 56, 123456789)); $this->assertLocalDateTimeIs(2001, 2, 3, 12, 34, 56, $nano, $localDateTime->withNano($nano)); } - /** - * @return array - */ public function providerWithNano() : array { return [ @@ -647,18 +575,13 @@ public function providerWithNano() : array /** * @dataProvider providerWithInvalidNanoThrowsException - * - * @param int $invalidNano */ - public function testWithInvalidNanoThrowsException(int $invalidNano) + public function testWithInvalidNanoThrowsException(int $invalidNano): void { $this->expectException(DateTimeException::class); LocalDate::of(2001, 2, 3)->atTime(LocalTime::of(4, 5, 6))->withNano($invalidNano); } - /** - * @return array - */ public function providerWithInvalidNanoThrowsException() : array { return [ @@ -680,7 +603,7 @@ public function providerWithInvalidNanoThrowsException() : array * @param int $em The expected month of the result date. * @param int $ed The expected day of the result date. */ - public function testPlusPeriod(int $y, int $m, int $d, int $py, int $pm, int $pd, int $ey, int $em, int $ed) + public function testPlusPeriod(int $y, int $m, int $d, int $py, int $pm, int $pd, int $ey, int $em, int $ed): void { $dateTime = LocalDate::of($y, $m, $d)->atTime(LocalTime::of(12, 34, 56, 123456789)); $period = Period::of($py, $pm, $pd); @@ -701,7 +624,7 @@ public function testPlusPeriod(int $y, int $m, int $d, int $py, int $pm, int $pd * @param int $em The expected month of the result date. * @param int $ed The expected day of the result date. */ - public function testMinusPeriod(int $y, int $m, int $d, int $py, int $pm, int $pd, int $ey, int $em, int $ed) + public function testMinusPeriod(int $y, int $m, int $d, int $py, int $pm, int $pd, int $ey, int $em, int $ed): void { $dateTime = LocalDate::of($y, $m, $d)->atTime(LocalTime::of(12, 34, 56, 123456789)); $period = Period::of($py, $pm, $pd); @@ -709,9 +632,6 @@ public function testMinusPeriod(int $y, int $m, int $d, int $py, int $pm, int $p $this->assertLocalDateTimeIs($ey, $em, $ed, 12, 34, 56, 123456789, $dateTime->minusPeriod($period->negated())); } - /** - * @return array - */ public function providerPeriod() : array { return [ @@ -742,7 +662,7 @@ public function providerPeriod() : array * @param int $s The expected second. * @param int $n The expected nano. */ - public function testPlusDuration(int $ds, int $dn, int $y, int $m, int $d, int $h, int $i, int $s, int $n) + public function testPlusDuration(int $ds, int $dn, int $y, int $m, int $d, int $h, int $i, int $s, int $n): void { $localDateTime = LocalDate::of(2001, 2, 3)->atTime(LocalTime::of(4, 5, 6, 123456789)); $duration = Duration::ofSeconds($ds, $dn); @@ -762,16 +682,13 @@ public function testPlusDuration(int $ds, int $dn, int $y, int $m, int $d, int $ * @param int $s The expected second. * @param int $n The expected nano. */ - public function testMinusDuration(int $ds, int $dn, int $y, int $m, int $d, int $h, int $i, int $s, int $n) + public function testMinusDuration(int $ds, int $dn, int $y, int $m, int $d, int $h, int $i, int $s, int $n): void { $localDateTime = LocalDate::of(2001, 2, 3)->atTime(LocalTime::of(4, 5, 6, 123456789)); $duration = Duration::ofSeconds(-$ds, -$dn); $this->assertLocalDateTimeIs($y, $m, $d, $h, $i, $s, $n, $localDateTime->minusDuration($duration)); } - /** - * @return array - */ public function providerDuration() : array { return [ @@ -790,15 +707,12 @@ public function providerDuration() : array * @param int $years The number of years to add. * @param string $expectedDateTime The expected resulting date-time string. */ - public function testPlusYears(string $dateTime, int $years, string $expectedDateTime) + public function testPlusYears(string $dateTime, int $years, string $expectedDateTime): void { $actualDateTime = LocalDateTime::parse($dateTime)->plusYears($years); $this->assertSame($expectedDateTime, (string) $actualDateTime); } - /** - * @return array - */ public function providerPlusYears() : array { return [ @@ -815,15 +729,12 @@ public function providerPlusYears() : array * @param int $months The number of months to add. * @param string $expectedDateTime The expected resulting date-time string. */ - public function testPlusMonths(string $dateTime, int $months, string $expectedDateTime) + public function testPlusMonths(string $dateTime, int $months, string $expectedDateTime): void { $actualDateTime = LocalDateTime::parse($dateTime)->plusMonths($months); $this->assertSame($expectedDateTime, (string) $actualDateTime); } - /** - * @return array - */ public function providerPlusMonths() : array { return [ @@ -840,15 +751,12 @@ public function providerPlusMonths() : array * @param int $weeks The number of weeks to add. * @param string $expectedDateTime The expected resulting date-time string. */ - public function testPlusWeeks(string $dateTime, int $weeks, string $expectedDateTime) + public function testPlusWeeks(string $dateTime, int $weeks, string $expectedDateTime): void { $actualDateTime = LocalDateTime::parse($dateTime)->plusWeeks($weeks); $this->assertSame($expectedDateTime, (string) $actualDateTime); } - /** - * @return array - */ public function providerPlusWeeks() : array { return [ @@ -865,15 +773,12 @@ public function providerPlusWeeks() : array * @param int $days The number of days to add. * @param string $expectedDateTime The expected resulting date-time string. */ - public function testPlusDays(string $dateTime, int $days, string $expectedDateTime) + public function testPlusDays(string $dateTime, int $days, string $expectedDateTime): void { $actualDateTime = LocalDateTime::parse($dateTime)->plusDays($days); $this->assertSame($expectedDateTime, (string) $actualDateTime); } - /** - * @return array - */ public function providerPlusDays() : array { return [ @@ -890,15 +795,12 @@ public function providerPlusDays() : array * @param int $hours The number of hours to add. * @param string $expectedDateTime The expected resulting date-time string. */ - public function testPlusHours(string $dateTime, int $hours, string $expectedDateTime) + public function testPlusHours(string $dateTime, int $hours, string $expectedDateTime): void { $actualDateTime = LocalDateTime::parse($dateTime)->plusHours($hours); $this->assertSame($expectedDateTime, (string) $actualDateTime); } - /** - * @return array - */ public function providerPlusHours() : array { return [ @@ -940,15 +842,12 @@ public function providerPlusMinutes() : array * @param int $seconds The number of seconds to add. * @param string $expectedDateTime The expected resulting date-time string. */ - public function testPlusSeconds(string $dateTime, int $seconds, string $expectedDateTime) + public function testPlusSeconds(string $dateTime, int $seconds, string $expectedDateTime): void { $actualDateTime = LocalDateTime::parse($dateTime)->plusSeconds($seconds); $this->assertSame($expectedDateTime, (string) $actualDateTime); } - /** - * @return array - */ public function providerPlusSeconds() : array { return [ @@ -965,15 +864,12 @@ public function providerPlusSeconds() : array * @param int $nanosToAdd The nanoseconds to add. * @param string $expectedDateTime The expected resulting date-time string. */ - public function testPlusNanos(string $dateTime, int $nanosToAdd, string $expectedDateTime) + public function testPlusNanos(string $dateTime, int $nanosToAdd, string $expectedDateTime): void { $actualDateTime = LocalDateTime::parse($dateTime)->plusNanos($nanosToAdd); $this->assertSame($expectedDateTime, (string) $actualDateTime); } - /** - * @return array - */ public function providerPlusNanos() : array { return [ @@ -991,15 +887,12 @@ public function providerPlusNanos() : array * @param int $years The number of years to subtract. * @param string $expectedDateTime The expected resulting date-time string. */ - public function testMinusYears(string $dateTime, int $years, string $expectedDateTime) + public function testMinusYears(string $dateTime, int $years, string $expectedDateTime): void { $actualDateTime = LocalDateTime::parse($dateTime)->minusYears($years); $this->assertSame($expectedDateTime, (string) $actualDateTime); } - /** - * @return array - */ public function providerMinusYears() : array { return [ @@ -1016,15 +909,12 @@ public function providerMinusYears() : array * @param int $months The number of months to subtract. * @param string $expectedDateTime The expected resulting date-time string. */ - public function testMinusMonths(string $dateTime, int $months, string $expectedDateTime) + public function testMinusMonths(string $dateTime, int $months, string $expectedDateTime): void { $actualDateTime = LocalDateTime::parse($dateTime)->minusMonths($months); $this->assertSame($expectedDateTime, (string) $actualDateTime); } - /** - * @return array - */ public function providerMinusMonths() : array { return [ @@ -1041,15 +931,12 @@ public function providerMinusMonths() : array * @param int $weeks The number of weeks to subtract. * @param string $expectedDateTime The expected resulting date-time string. */ - public function testMinusWeeks(string $dateTime, int $weeks, string $expectedDateTime) + public function testMinusWeeks(string $dateTime, int $weeks, string $expectedDateTime): void { $actualDateTime = LocalDateTime::parse($dateTime)->minusWeeks($weeks); $this->assertSame($expectedDateTime, (string) $actualDateTime); } - /** - * @return array - */ public function providerMinusWeeks() : array { return [ @@ -1066,15 +953,12 @@ public function providerMinusWeeks() : array * @param int $days The number of days to subtract. * @param string $expectedDateTime The expected resulting date-time string. */ - public function testMinusDays(string $dateTime, int $days, string $expectedDateTime) + public function testMinusDays(string $dateTime, int $days, string $expectedDateTime): void { $actualDateTime = LocalDateTime::parse($dateTime)->minusDays($days); $this->assertSame($expectedDateTime, (string) $actualDateTime); } - /** - * @return array - */ public function providerMinusDays() : array { return [ @@ -1091,15 +975,12 @@ public function providerMinusDays() : array * @param int $hours The number of hours to subtract. * @param string $expectedDateTime The expected resulting date-time string. */ - public function testMinusHours(string $dateTime, int $hours, string $expectedDateTime) + public function testMinusHours(string $dateTime, int $hours, string $expectedDateTime): void { $actualDateTime = LocalDateTime::parse($dateTime)->minusHours($hours); $this->assertSame($expectedDateTime, (string) $actualDateTime); } - /** - * @return array - */ public function providerMinusHours() : array { return [ @@ -1116,15 +997,12 @@ public function providerMinusHours() : array * @param int $minutes The number of minutes to subtract. * @param string $expectedDateTime The expected resulting date-time string. */ - public function testMinusMinutes(string $dateTime, int $minutes, string $expectedDateTime) + public function testMinusMinutes(string $dateTime, int $minutes, string $expectedDateTime): void { $actualDateTime = LocalDateTime::parse($dateTime)->minusMinutes($minutes); $this->assertSame($expectedDateTime, (string) $actualDateTime); } - /** - * @return array - */ public function providerMinusMinutes() : array { return [ @@ -1141,15 +1019,12 @@ public function providerMinusMinutes() : array * @param int $seconds The number of seconds to subtract. * @param string $expectedDateTime The expected resulting date-time string. */ - public function testMinusSeconds(string $dateTime, int $seconds, string $expectedDateTime) + public function testMinusSeconds(string $dateTime, int $seconds, string $expectedDateTime): void { $actualDateTime = LocalDateTime::parse($dateTime)->minusSeconds($seconds); $this->assertSame($expectedDateTime, (string) $actualDateTime); } - /** - * @return array - */ public function providerMinusSeconds() : array { return [ @@ -1166,15 +1041,12 @@ public function providerMinusSeconds() : array * @param int $nanosToSubtract The nanoseconds to subtract. * @param string $expectedDateTime The expected resulting date-time string. */ - public function testMinusNanos(string $dateTime, int $nanosToSubtract, string $expectedDateTime) + public function testMinusNanos(string $dateTime, int $nanosToSubtract, string $expectedDateTime): void { $actualDateTime = LocalDateTime::parse($dateTime)->minusNanos($nanosToSubtract); $this->assertSame($expectedDateTime, (string) $actualDateTime); } - /** - * @return array - */ public function providerMinusNanos() : array { return [ @@ -1190,18 +1062,15 @@ public function providerMinusNanos() : array * * @param string $dateTime The date-time. * @param string $timeZone The time-zone. - * @param int $epochSeconds The expected epoch second of the resulting instant. - * @param int $nanos The expected nano-of-second of the resulting instant. + * @param int $epochSeconds The expected epoch second of the resulting instant. + * @param int $nanos The expected nano-of-second of the resulting instant. */ - public function testAtTimeZone(string $dateTime, string $timeZone, int $epochSeconds, int $nanos) + public function testAtTimeZone(string $dateTime, string $timeZone, int $epochSeconds, int $nanos): void { $zonedDateTime = LocalDateTime::parse($dateTime)->atTimeZone(TimeZone::parse($timeZone)); $this->assertInstantIs($epochSeconds, $nanos, $zonedDateTime->getInstant()); } - /** - * @return array - */ public function providerAtTimeZone() : array { return [ @@ -1219,7 +1088,7 @@ public function providerAtTimeZone() : array * @param string $dateTime2 The date-time to compare to. * @param int $result The expected result. */ - public function testCompareTo(string $dateTime1, string $dateTime2, int $result) + public function testCompareTo(string $dateTime1, string $dateTime2, int $result): void { $dateTime1 = LocalDateTime::parse($dateTime1); $dateTime2 = LocalDateTime::parse($dateTime2); @@ -1233,9 +1102,6 @@ public function testCompareTo(string $dateTime1, string $dateTime2, int $result) $this->assertSame($result <= 0, $dateTime1->isBeforeOrEqualTo($dateTime2)); } - /** - * @return array - */ public function providerCompareTo() : array { return [ @@ -1260,7 +1126,7 @@ public function providerCompareTo() : array /** * @dataProvider providerForPastFuture */ - public function testIsFuture(int $clockTimestamp, string $localDateTime, string $offset, bool $isFuture) + public function testIsFuture(int $clockTimestamp, string $localDateTime, string $offset, bool $isFuture): void { $clock = new FixedClock(Instant::of($clockTimestamp)); $localDateTime = LocalDateTime::parse($localDateTime); @@ -1271,7 +1137,7 @@ public function testIsFuture(int $clockTimestamp, string $localDateTime, string /** * @dataProvider providerForPastFuture */ - public function testIsPast(int $clockTimestamp, string $localDateTime, string $offset, bool $isFuture) + public function testIsPast(int $clockTimestamp, string $localDateTime, string $offset, bool $isFuture): void { $clock = new FixedClock(Instant::of($clockTimestamp)); $localDateTime = LocalDateTime::parse($localDateTime); @@ -1279,10 +1145,7 @@ public function testIsPast(int $clockTimestamp, string $localDateTime, string $o $this->assertSame(! $isFuture, $localDateTime->isPast($timeZone, $clock)); } - /** - * @return array - */ - public function providerForPastFuture() + public function providerForPastFuture(): array { return [ [1234567890, '2009-02-14T00:31:29', '+01:00', false], @@ -1298,7 +1161,7 @@ public function providerForPastFuture() * @param string $dateTime The date-time string that will be parse()d by LocalDateTime. * @param string $expected The expected output from the native DateTime object. */ - public function testToDateTime(string $dateTime, string $expected) + public function testToDateTime(string $dateTime, string $expected): void { $zonedDateTime = LocalDateTime::parse($dateTime); $dateTime = $zonedDateTime->toDateTime(); @@ -1313,7 +1176,7 @@ public function testToDateTime(string $dateTime, string $expected) * @param string $dateTime The date-time string that will be parse()d by LocalDateTime. * @param string $expected The expected output from the native DateTime object. */ - public function testToDateTimeImmutable(string $dateTime, string $expected) + public function testToDateTimeImmutable(string $dateTime, string $expected): void { $zonedDateTime = LocalDateTime::parse($dateTime); $dateTime = $zonedDateTime->toDateTimeImmutable(); @@ -1322,10 +1185,7 @@ public function testToDateTimeImmutable(string $dateTime, string $expected) $this->assertSame($expected, $dateTime->format('Y-m-d\TH:i:s.uO')); } - /** - * @return array - */ - public function providerToDateTime() + public function providerToDateTime(): array { return [ ['2018-10-18T12:34', '2018-10-18T12:34:00.000000+0000'], @@ -1350,7 +1210,7 @@ public function providerToDateTime() * @param int $nano The nano-of-second. * @param string $expected The expected result string. */ - public function testJsonSerialize(int $year, int $month, int $day, int $hour, int $minute, int $second, int $nano, string $expected) + public function testJsonSerialize(int $year, int $month, int $day, int $hour, int $minute, int $second, int $nano, string $expected): void { $this->assertSame(json_encode($expected), json_encode(LocalDateTime::of($year, $month, $day, $hour, $minute, $second, $nano))); } @@ -1367,14 +1227,11 @@ public function testJsonSerialize(int $year, int $month, int $day, int $hour, in * @param int $nano The nano-of-second. * @param string $expected The expected result string. */ - public function testToString(int $year, int $month, int $day, int $hour, int $minute, int $second, int $nano, string $expected) + public function testToString(int $year, int $month, int $day, int $hour, int $minute, int $second, int $nano, string $expected): void { $this->assertSame($expected, (string) LocalDateTime::of($year, $month, $day, $hour, $minute, $second, $nano)); } - /** - * @return array - */ public function providerToString() : array { return [ diff --git a/tests/LocalTimeTest.php b/tests/LocalTimeTest.php index cb61256..f4dafb2 100644 --- a/tests/LocalTimeTest.php +++ b/tests/LocalTimeTest.php @@ -18,27 +18,20 @@ */ class LocalTimeTest extends AbstractTestCase { - public function testOf() + public function testOf(): void { $this->assertLocalTimeIs(12, 34, 56, 123456789, LocalTime::of(12, 34, 56, 123456789)); } /** * @dataProvider providerOfInvalidTimeThrowsException - * - * @param int $hour - * @param int $minute - * @param int $second */ - public function testOfInvalidTimeThrowsException(int $hour, int $minute, int $second) + public function testOfInvalidTimeThrowsException(int $hour, int $minute, int $second): void { $this->expectException(DateTimeException::class); LocalTime::of($hour, $minute, $second); } - /** - * @return array - */ public function providerOfInvalidTimeThrowsException() : array { return [ @@ -59,15 +52,12 @@ public function providerOfInvalidTimeThrowsException() : array * @param int $minute The expected resulting minute. * @param int $second The expected resulting second. */ - public function testOfSecondOfDay(int $secondOfDay, int $hour, int $minute, int $second) + public function testOfSecondOfDay(int $secondOfDay, int $hour, int $minute, int $second): void { $localTime = LocalTime::ofSecondOfDay($secondOfDay, 123); $this->assertLocalTimeIs($hour, $minute, $second, 123, $localTime); } - /** - * @return array - */ public function providerOfSecondOfDay() : array { return [ @@ -91,19 +81,13 @@ public function providerOfSecondOfDay() : array /** * @dataProvider providerOfInvalidSecondOfDayThrowsException - * - * @param int $secondOfDay - * @param int $nanoOfSecond */ - public function testOfInvalidSecondOfDayThrowsException(int $secondOfDay, int $nanoOfSecond) + public function testOfInvalidSecondOfDayThrowsException(int $secondOfDay, int $nanoOfSecond): void { $this->expectException(DateTimeException::class); LocalTime::ofSecondOfDay($secondOfDay, $nanoOfSecond); } - /** - * @return array - */ public function providerOfInvalidSecondOfDayThrowsException() : array { return [ @@ -116,14 +100,8 @@ public function providerOfInvalidSecondOfDayThrowsException() : array /** * @dataProvider providerParse - * - * @param string $text - * @param int $hour - * @param int $minute - * @param int $second - * @param int $nano */ - public function testParse(string $text, int $hour, int $minute, int $second, int $nano) + public function testParse(string $text, int $hour, int $minute, int $second, int $nano): void { $time = LocalTime::parse($text); @@ -133,9 +111,6 @@ public function testParse(string $text, int $hour, int $minute, int $second, int $this->assertSame($nano, $time->getNano()); } - /** - * @return array - */ public function providerParse() : array { return [ @@ -148,18 +123,13 @@ public function providerParse() : array /** * @dataProvider providerParseInvalidStringThrowsException - * - * @param string $text */ - public function testParseInvalidStringThrowsException(string $text) + public function testParseInvalidStringThrowsException(string $text): void { $this->expectException(DateTimeParseException::class); LocalTime::parse($text); } - /** - * @return array - */ public function providerParseInvalidStringThrowsException() : array { return [ @@ -178,7 +148,7 @@ public function providerParseInvalidStringThrowsException() : array ]; } - public function testFromDateTime() + public function testFromDateTime(): void { $dateTime = new \DateTime('2018-07-21 14:09:10.23456'); $this->assertLocalTimeIs(14, 9, 10, 234560000, LocalTime::fromDateTime($dateTime)); @@ -195,16 +165,13 @@ public function testFromDateTime() * @param int $s The expected second. * @param int $n The expected nano. */ - public function testNow(int $second, int $nano, int $offset, int $h, int $m, int $s, int $n) + public function testNow(int $second, int $nano, int $offset, int $h, int $m, int $s, int $n): void { $clock = new FixedClock(Instant::of($second, $nano)); $timeZone = TimeZoneOffset::ofTotalSeconds($offset); $this->assertLocalTimeIs($h, $m, $s, $n, LocalTime::now($timeZone, $clock)); } - /** - * @return array - */ public function providerNow() : array { return [ @@ -215,22 +182,22 @@ public function providerNow() : array ]; } - public function testMidnight() + public function testMidnight(): void { $this->assertLocalTimeIs(0, 0, 0, 0, LocalTime::midnight()); } - public function testNoon() + public function testNoon(): void { $this->assertLocalTimeIs(12, 0, 0, 0, LocalTime::noon()); } - public function testMin() + public function testMin(): void { $this->assertLocalTimeIs(0, 0, 0, 0, LocalTime::min()); } - public function testMax() + public function testMax(): void { $this->assertLocalTimeIs(23, 59, 59, 999999999, LocalTime::max()); } @@ -240,14 +207,11 @@ public function testMax() * * @param int $hour The new hour. */ - public function testWithHour(int $hour) + public function testWithHour(int $hour): void { $this->assertLocalTimeIs($hour, 34, 56, 789, LocalTime::of(12, 34, 56, 789)->withHour($hour)); } - /** - * @return array - */ public function providerWithHour() : array { return [ @@ -258,18 +222,13 @@ public function providerWithHour() : array /** * @dataProvider providerWithInvalidHourThrowsException - * - * @param int $invalidHour */ - public function testWithInvalidHourThrowsException(int $invalidHour) + public function testWithInvalidHourThrowsException(int $invalidHour): void { $this->expectException(DateTimeException::class); LocalTime::of(12, 34, 56)->withHour($invalidHour); } - /** - * @return array - */ public function providerWithInvalidHourThrowsException() : array { return [ @@ -283,14 +242,11 @@ public function providerWithInvalidHourThrowsException() : array * * @param int $minute The new minute. */ - public function testWithMinute(int $minute) + public function testWithMinute(int $minute): void { $this->assertLocalTimeIs(12, $minute, 56, 789, LocalTime::of(12, 34, 56, 789)->withMinute($minute)); } - /** - * @return array - */ public function providerWithMinute() : array { return [ @@ -301,18 +257,13 @@ public function providerWithMinute() : array /** * @dataProvider providerWithInvalidMinuteThrowsException - * - * @param int $invalidMinute */ - public function testWithInvalidMinuteThrowsException(int $invalidMinute) + public function testWithInvalidMinuteThrowsException(int $invalidMinute): void { $this->expectException(DateTimeException::class); LocalTime::of(12, 34, 56)->withMinute($invalidMinute); } - /** - * @return array - */ public function providerWithInvalidMinuteThrowsException() : array { return [ @@ -326,14 +277,11 @@ public function providerWithInvalidMinuteThrowsException() : array * * @param int $second The new second. */ - public function testWithSecond(int $second) + public function testWithSecond(int $second): void { $this->assertLocalTimeIs(12, 34, $second, 789, LocalTime::of(12, 34, 56, 789)->withSecond($second)); } - /** - * @return array - */ public function providerWithSecond() : array { return [ @@ -344,18 +292,13 @@ public function providerWithSecond() : array /** * @dataProvider providerWithInvalidSecondThrowsException - * - * @param int $invalidSecond */ - public function testWithInvalidSecondThrowsException(int $invalidSecond) + public function testWithInvalidSecondThrowsException(int $invalidSecond): void { $this->expectException(DateTimeException::class); LocalTime::of(12, 34, 56)->withSecond($invalidSecond); } - /** - * @return array - */ public function providerWithInvalidSecondThrowsException() : array { return [ @@ -369,14 +312,11 @@ public function providerWithInvalidSecondThrowsException() : array * * @param int $nano The new nano. */ - public function testWithNano(int $nano) + public function testWithNano(int $nano): void { $this->assertLocalTimeIs(12, 34, 56, $nano, LocalTime::of(12, 34, 56, 789)->withNano($nano)); } - /** - * @return array - */ public function providerWithNano() : array { return [ @@ -387,18 +327,13 @@ public function providerWithNano() : array /** * @dataProvider providerWithInvalidNanoThrowsException - * - * @param int $invalidNano */ - public function testWithInvalidNanoThrowsException(int $invalidNano) + public function testWithInvalidNanoThrowsException(int $invalidNano): void { $this->expectException(DateTimeException::class); LocalTime::of(12, 34, 56)->withNano($invalidNano); } - /** - * @return array - */ public function providerWithInvalidNanoThrowsException() : array { return [ @@ -421,7 +356,7 @@ public function providerWithInvalidNanoThrowsException() : array * @param int $es The expected second of the result time. * @param int $en The expected nano of the result time. */ - public function testPlusDuration(int $h, int $m, int $s, int $n, int $ds, int $dn, int $eh, int $em, int $es, int $en) + public function testPlusDuration(int $h, int $m, int $s, int $n, int $ds, int $dn, int $eh, int $em, int $es, int $en): void { $localTime = LocalTime::of($h, $m, $s, $n); $duration = Duration::ofSeconds($ds, $dn); @@ -442,16 +377,13 @@ public function testPlusDuration(int $h, int $m, int $s, int $n, int $ds, int $d * @param int $es The expected second of the result time. * @param int $en The expected nano of the result time. */ - public function testMinusDuration(int $h, int $m, int $s, int $n, int $ds, int $dn, int $eh, int $em, int $es, int $en) + public function testMinusDuration(int $h, int $m, int $s, int $n, int $ds, int $dn, int $eh, int $em, int $es, int $en): void { $localTime = LocalTime::of($h, $m, $s, $n); $duration = Duration::ofSeconds(-$ds, -$dn); $this->assertLocalTimeIs($eh, $em, $es, $en, $localTime->minusDuration($duration)); } - /** - * @return array - */ public function providerDuration() : array { return [ @@ -469,7 +401,7 @@ public function providerDuration() : array * @param int $d The number of hours to add. * @param int $eh The expected result hour. */ - public function testPlusHours(int $h, int $d, int $eh) + public function testPlusHours(int $h, int $d, int $eh): void { $result = LocalTime::of($h, 34, 56, 789)->plusHours($d); $this->assertLocalTimeIs($eh, 34, 56, 789, $result); @@ -482,15 +414,12 @@ public function testPlusHours(int $h, int $d, int $eh) * @param int $d The number of hours to add. * @param int $eh The expected result hour. */ - public function testMinusHours(int $h, int $d, int $eh) + public function testMinusHours(int $h, int $d, int $eh): void { $result = LocalTime::of($h, 34, 56, 789)->minusHours(-$d); $this->assertLocalTimeIs($eh, 34, 56, 789, $result); } - /** - * @return array - */ public function providerPlusHours() : array { return [ @@ -533,7 +462,7 @@ public function providerPlusHours() : array * @param int $eh The expected result hour. * @param int $em The expected result minute. */ - public function testPlusMinutes(int $h, int $m, int $d, int $eh, int $em) + public function testPlusMinutes(int $h, int $m, int $d, int $eh, int $em): void { $result = LocalTime::of($h, $m, 56, 789)->plusMinutes($d); $this->assertLocalTimeIs($eh, $em, 56, 789, $result); @@ -548,15 +477,12 @@ public function testPlusMinutes(int $h, int $m, int $d, int $eh, int $em) * @param int $eh The expected result hour. * @param int $em The expected result minute. */ - public function testMinusMinutes(int $h, int $m, int $d, int $eh, int $em) + public function testMinusMinutes(int $h, int $m, int $d, int $eh, int $em): void { $result = LocalTime::of($h, $m, 56, 789)->minusMinutes(-$d); $this->assertLocalTimeIs($eh, $em, 56, 789, $result); } - /** - * @return array - */ public function providerPlusMinutes() : array { return [ @@ -619,7 +545,7 @@ public function providerPlusMinutes() : array * @param int $em The expected result minute. * @param int $es The expected result second. */ - public function testPlusSeconds(int $h, int $m, int $s, int $d, int $eh, int $em, int $es) + public function testPlusSeconds(int $h, int $m, int $s, int $d, int $eh, int $em, int $es): void { $result = LocalTime::of($h, $m, $s, 123456789)->plusSeconds($d); $this->assertLocalTimeIs($eh, $em, $es, 123456789, $result); @@ -636,15 +562,12 @@ public function testPlusSeconds(int $h, int $m, int $s, int $d, int $eh, int $em * @param int $em The expected result minute. * @param int $es The expected result second. */ - public function testMinusSeconds(int $h, int $m, int $s, int $d, int $eh, int $em, int $es) + public function testMinusSeconds(int $h, int $m, int $s, int $d, int $eh, int $em, int $es): void { $result = LocalTime::of($h, $m, $s, 123456789)->minusSeconds(-$d); $this->assertLocalTimeIs($eh, $em, $es, 123456789, $result); } - /** - * @return array - */ public function providerPlusSeconds() : array { return [ @@ -721,7 +644,7 @@ public function providerPlusSeconds() : array * @param int $es The expected result second. * @param int $en The expected result nanosecond. */ - public function testPlusNanos(int $h, int $m, int $s, int $n, int $d, int $eh, int $em, int $es, int $en) + public function testPlusNanos(int $h, int $m, int $s, int $n, int $d, int $eh, int $em, int $es, int $en): void { $result = LocalTime::of($h, $m, $s, $n)->plusNanos($d); $this->assertLocalTimeIs($eh, $em, $es, $en, $result); @@ -740,15 +663,12 @@ public function testPlusNanos(int $h, int $m, int $s, int $n, int $d, int $eh, i * @param int $es The expected result second. * @param int $en The expected result nanosecond. */ - public function testMinusNanos(int $h, int $m, int $s, int $n, int $d, int $eh, int $em, int $es, int $en) + public function testMinusNanos(int $h, int $m, int $s, int $n, int $d, int $eh, int $em, int $es, int $en): void { $result = LocalTime::of($h, $m, $s, $n)->minusNanos(-$d); $this->assertLocalTimeIs($eh, $em, $es, $en, $result); } - /** - * @return array - */ public function providerPlusNanos() : array { return [ @@ -789,7 +709,7 @@ public function providerPlusNanos() : array * @param int $n2 The nano of the 2nd time. * @param int $cmp The comparison value. */ - public function testCompareTo(int $h1, int $m1, int $s1, int $n1, int $h2, int $m2, int $s2, int $n2, int $cmp) + public function testCompareTo(int $h1, int $m1, int $s1, int $n1, int $h2, int $m2, int $s2, int $n2, int $cmp): void { $t1 = LocalTime::of($h1, $m1, $s1, $n1); $t2 = LocalTime::of($h2, $m2, $s2, $n2); @@ -802,9 +722,6 @@ public function testCompareTo(int $h1, int $m1, int $s1, int $n1, int $h2, int $ $this->assertSame($cmp >= 0, $t1->isAfterOrEqualTo($t2)); } - /** - * @return array - */ public function providerCompareTo() : array { return [ @@ -1067,7 +984,7 @@ public function providerCompareTo() : array ]; } - public function testAtDate() + public function testAtDate(): void { $time = LocalTime::of(12, 34, 56, 789); $date = LocalDate::of(2014, 11, 30); @@ -1077,13 +994,8 @@ public function testAtDate() /** * @dataProvider providerToSecondOfDay - * - * @param int $hour - * @param int $minute - * @param int $second - * @param int $result */ - public function testToSecondOfDay(int $hour, int $minute, int $second, int $result) + public function testToSecondOfDay(int $hour, int $minute, int $second, int $result): void { $time = LocalTime::of($hour, $minute, $second); @@ -1091,9 +1003,6 @@ public function testToSecondOfDay(int $hour, int $minute, int $second, int $resu $this->assertSame($result, $time->withNano(123)->toSecondOfDay()); } - /** - * @return array - */ public function providerToSecondOfDay() : array { return [ @@ -1115,7 +1024,7 @@ public function providerToSecondOfDay() : array * @param int $n The nanosecond. * @param string $r The expected result. */ - public function testJsonSerialize(int $h, int $m, int $s, int $n, string $r) + public function testJsonSerialize(int $h, int $m, int $s, int $n, string $r): void { $this->assertSame(json_encode($r), json_encode(LocalTime::of($h, $m, $s, $n))); } @@ -1129,14 +1038,11 @@ public function testJsonSerialize(int $h, int $m, int $s, int $n, string $r) * @param int $n The nanosecond. * @param string $r The expected result. */ - public function testToString(int $h, int $m, int $s, int $n, string $r) + public function testToString(int $h, int $m, int $s, int $n, string $r): void { $this->assertSame($r, (string) LocalTime::of($h, $m, $s, $n)); } - /** - * @return array - */ public function providerToString() : array { return [ @@ -1149,7 +1055,7 @@ public function providerToString() : array ]; } - public function testMinMaxOf() + public function testMinMaxOf(): void { $a = LocalTime::of(11, 45); $b = LocalTime::of(14, 30); @@ -1159,13 +1065,13 @@ public function testMinMaxOf() $this->assertSame($c, LocalTime::maxOf($a, $b, $c)); } - public function testMinOfZeroElementsThrowsException() + public function testMinOfZeroElementsThrowsException(): void { $this->expectException(DateTimeException::class); LocalTime::minOf(); } - public function testMaxOfZeroElementsThrowsException() + public function testMaxOfZeroElementsThrowsException(): void { $this->expectException(DateTimeException::class); LocalTime::maxOf(); @@ -1177,7 +1083,7 @@ public function testMaxOfZeroElementsThrowsException() * @param string $dateTime The date-time string that will be parse()d by LocalTime. * @param string $expected The expected output from the native DateTime object. */ - public function testToDateTime(string $dateTime, string $expected) + public function testToDateTime(string $dateTime, string $expected): void { $zonedDateTime = LocalTime::parse($dateTime); $dateTime = $zonedDateTime->toDateTime(); @@ -1192,7 +1098,7 @@ public function testToDateTime(string $dateTime, string $expected) * @param string $dateTime The date-time string that will be parse()d by LocalTime. * @param string $expected The expected output from the native DateTime object. */ - public function testToDateTimeImmutable(string $dateTime, string $expected) + public function testToDateTimeImmutable(string $dateTime, string $expected): void { $zonedDateTime = LocalTime::parse($dateTime); $dateTime = $zonedDateTime->toDateTimeImmutable(); @@ -1201,9 +1107,6 @@ public function testToDateTimeImmutable(string $dateTime, string $expected) $this->assertSame($expected, $dateTime->format('Y-m-d\TH:i:s.uO')); } - /** - * @return array - */ public function providerToDateTime() { return [ diff --git a/tests/MonthDayTest.php b/tests/MonthDayTest.php index ba5209d..43bc941 100644 --- a/tests/MonthDayTest.php +++ b/tests/MonthDayTest.php @@ -18,18 +18,12 @@ class MonthDayTest extends AbstractTestCase { /** * @dataProvider providerOf - * - * @param int $month - * @param int $day */ - public function testOf(int $month, int $day) + public function testOf(int $month, int $day): void { $this->assertMonthDayIs($month, $day, MonthDay::of($month, $day)); } - /** - * @return array - */ public function providerOf() : array { return [ @@ -51,19 +45,13 @@ public function providerOf() : array /** * @dataProvider providerOfThrowsExceptionOnInvalidMonthDay - * - * @param int $month - * @param int $day */ - public function testOfThrowsExceptionOnInvalidMonthDay(int $month, int $day) + public function testOfThrowsExceptionOnInvalidMonthDay(int $month, int $day): void { $this->expectException(DateTimeException::class); MonthDay::of($month, $day); } - /** - * @return array - */ public function providerOfThrowsExceptionOnInvalidMonthDay() : array { return [ @@ -92,14 +80,11 @@ public function providerOfThrowsExceptionOnInvalidMonthDay() : array * @param int $month The expected month. * @param int $day The expected day. */ - public function testParse(string $text, int $month, int $day) + public function testParse(string $text, int $month, int $day): void { $this->assertMonthDayIs($month, $day, MonthDay::parse($text)); } - /** - * @return array - */ public function providerParse() : array { return [ @@ -111,18 +96,13 @@ public function providerParse() : array /** * @dataProvider providerParseInvalidStringThrowsException - * - * @param string $text */ - public function testParseInvalidStringThrowsException(string $text) + public function testParseInvalidStringThrowsException(string $text): void { $this->expectException(DateTimeParseException::class); MonthDay::parse($text); } - /** - * @return array - */ public function providerParseInvalidStringThrowsException() : array { return [ @@ -143,18 +123,13 @@ public function providerParseInvalidStringThrowsException() : array /** * @dataProvider providerParseInvalidDateThrowsException - * - * @param string $text */ - public function testParseInvalidDateThrowsException(string $text) + public function testParseInvalidDateThrowsException(string $text): void { $this->expectException(DateTimeException::class); MonthDay::parse($text); } - /** - * @return array - */ public function providerParseInvalidDateThrowsException() : array { return [ @@ -173,15 +148,12 @@ public function providerParseInvalidDateThrowsException() : array * @param int $month The expected month. * @param int $day The expected day. */ - public function testNow(int $epochSecond, string $timeZone, int $month, int $day) + public function testNow(int $epochSecond, string $timeZone, int $month, int $day): void { $clock = new FixedClock(Instant::of($epochSecond)); $this->assertMonthDayIs($month, $day, MonthDay::now(TimeZone::parse($timeZone), $clock)); } - /** - * @return array - */ public function providerNow() : array { return [ @@ -201,7 +173,7 @@ public function providerNow() : array * @param int $d2 The day of the month-day to compare to. * @param int $result The expected result. */ - public function testCompareTo(int $m1, int $d1, int $m2, int $d2, int $result) + public function testCompareTo(int $m1, int $d1, int $m2, int $d2, int $result): void { $this->assertSame($result, MonthDay::of($m1, $d1)->compareTo(MonthDay::of($m2, $d2))); } @@ -215,7 +187,7 @@ public function testCompareTo(int $m1, int $d1, int $m2, int $d2, int $result) * @param int $d2 The day of the month-day to compare to. * @param int $result The expected result. */ - public function testIsEqualTo(int $m1, int $d1, int $m2, int $d2, int $result) + public function testIsEqualTo(int $m1, int $d1, int $m2, int $d2, int $result): void { $this->assertSame($result == 0, MonthDay::of($m1, $d1)->isEqualTo(MonthDay::of($m2, $d2))); } @@ -229,7 +201,7 @@ public function testIsEqualTo(int $m1, int $d1, int $m2, int $d2, int $result) * @param int $d2 The day of the month-day to compare to. * @param int $result The expected result. */ - public function testIsBefore(int $m1, int $d1, int $m2, int $d2, int $result) + public function testIsBefore(int $m1, int $d1, int $m2, int $d2, int $result): void { $this->assertSame($result == -1, MonthDay::of($m1, $d1)->isBefore(MonthDay::of($m2, $d2))); } @@ -243,14 +215,11 @@ public function testIsBefore(int $m1, int $d1, int $m2, int $d2, int $result) * @param int $d2 The day of the month-day to compare to. * @param int $result The expected result. */ - public function testIsAfter(int $m1, int $d1, int $m2, int $d2, int $result) + public function testIsAfter(int $m1, int $d1, int $m2, int $d2, int $result): void { $this->assertSame($result == 1, MonthDay::of($m1, $d1)->isAfter(MonthDay::of($m2, $d2))); } - /** - * @return array - */ public function providerCompareTo() : array { return [ @@ -281,14 +250,11 @@ public function providerCompareTo() : array * @param int $year The year to test against. * @param bool $isValid The expected result. */ - public function testIsValidYear(int $month, int $day, int $year, bool $isValid) + public function testIsValidYear(int $month, int $day, int $year, bool $isValid): void { $this->assertSame($isValid, MonthDay::of($month, $day)->isValidYear($year)); } - /** - * @return array - */ public function providerIsValidYear() : array { return [ @@ -320,7 +286,7 @@ public function providerIsValidYear() : array * @param int $newMonth The new month to apply. * @param int $expectedDay The expected day of the resulting month-day. */ - public function testWithMonth(int $month, int $day, int $newMonth, int $expectedDay) + public function testWithMonth(int $month, int $day, int $newMonth, int $expectedDay): void { $monthDay = MonthDay::of($month, $day); $newMonthDay = $monthDay->withMonth($newMonth); @@ -329,9 +295,6 @@ public function testWithMonth(int $month, int $day, int $newMonth, int $expected $this->assertMonthDayIs($newMonth, $expectedDay, $newMonthDay); } - /** - * @return array - */ public function providerWithMonth() : array { return [ @@ -361,15 +324,12 @@ public function providerWithMonth() : array * @param int $day The day of base the month-day to test. * @param int $newMonth The new month to apply. */ - public function testWithInvalidMonthThrowsException(int $month, int $day, int $newMonth) + public function testWithInvalidMonthThrowsException(int $month, int $day, int $newMonth): void { $this->expectException(DateTimeException::class); MonthDay::of($month, $day)->withMonth($newMonth); } - /** - * @return array - */ public function providerWithInvalidMonthThrowsException() : array { return [ @@ -378,7 +338,7 @@ public function providerWithInvalidMonthThrowsException() : array ]; } - public function testWithDayWithSameDay() + public function testWithDayWithSameDay(): void { $month = 1; $day = 20; @@ -396,7 +356,7 @@ public function testWithDayWithSameDay() * @param int $day The day of base the month-day to test. * @param int $newDay The new day to apply. */ - public function testWithDay(int $month, int $day, int $newDay) + public function testWithDay(int $month, int $day, int $newDay): void { $monthDay = MonthDay::of($month, $day); $newMonthDay = $monthDay->withDay($newDay); @@ -405,9 +365,6 @@ public function testWithDay(int $month, int $day, int $newDay) $this->assertMonthDayIs($month, $newDay, $newMonthDay); } - /** - * @return array - */ public function providerWithDay() : array { return [ @@ -427,15 +384,12 @@ public function providerWithDay() : array * @param int $day The day of base the month-day to test. * @param int $newDay The new day to apply. */ - public function testWithInvalidDayThrowsException(int $month, int $day, int $newDay) + public function testWithInvalidDayThrowsException(int $month, int $day, int $newDay): void { $this->expectException(DateTimeException::class); MonthDay::of($month, $day)->withDay($newDay); } - /** - * @return array - */ public function providerWithInvalidDayThrowsException() : array { return [ @@ -474,14 +428,11 @@ public function providerWithInvalidDayThrowsException() : array * @param int $year The year to combine with the month-day. * @param int $expectedDay The expected day of the resulting date. */ - public function testAtYear(int $month, int $day, int $year, int $expectedDay) + public function testAtYear(int $month, int $day, int $year, int $expectedDay): void { $this->assertLocalDateIs($year, $month, $expectedDay, MonthDay::of($month, $day)->atYear($year)); } - /** - * @return array - */ public function providerAtYear() : array { return [ @@ -496,18 +447,13 @@ public function providerAtYear() : array /** * @dataProvider providerAtInvalidYearThrowsException - * - * @param int $year */ - public function testAtInvalidYearThrowsException(int $year) + public function testAtInvalidYearThrowsException(int $year): void { $this->expectException(DateTimeException::class); MonthDay::of(1, 1)->atYear($year); } - /** - * @return array - */ public function providerAtInvalidYearThrowsException() : array { return [ @@ -523,7 +469,7 @@ public function providerAtInvalidYearThrowsException() : array * @param int $day The day of the month-day to test. * @param string $string The expected result string. */ - public function testJsonSerialize(int $month, int $day, string $string) + public function testJsonSerialize(int $month, int $day, string $string): void { $this->assertSame(json_encode($string), json_encode(MonthDay::of($month, $day))); } @@ -535,14 +481,11 @@ public function testJsonSerialize(int $month, int $day, string $string) * @param int $day The day of the month-day to test. * @param string $string The expected result string. */ - public function testToString(int $month, int $day, string $string) + public function testToString(int $month, int $day, string $string): void { $this->assertSame($string, (string) MonthDay::of($month, $day)); } - /** - * @return array - */ public function providerToString() : array { return [ diff --git a/tests/MonthTest.php b/tests/MonthTest.php index e623fca..bd13505 100644 --- a/tests/MonthTest.php +++ b/tests/MonthTest.php @@ -18,14 +18,11 @@ class MonthTest extends AbstractTestCase * @param int $expectedValue The expected value of the constant. * @param int $monthConstant The month constant. */ - public function testConstants(int $expectedValue, int $monthConstant) + public function testConstants(int $expectedValue, int $monthConstant): void { $this->assertSame($expectedValue, $monthConstant); } - /** - * @return array - */ public function providerConstants() : array { return [ @@ -44,25 +41,20 @@ public function providerConstants() : array ]; } - public function testOf() + public function testOf(): void { $this->assertMonthIs(8, Month::of(8)); } /** * @dataProvider providerOfInvalidMonthThrowsException - * - * @param int $invalidMonth */ - public function testOfInvalidMonthThrowsException(int $invalidMonth) + public function testOfInvalidMonthThrowsException(int $invalidMonth): void { $this->expectException(DateTimeException::class); Month::of($invalidMonth); } - /** - * @return array - */ public function providerOfInvalidMonthThrowsException() : array { return [ @@ -72,7 +64,7 @@ public function providerOfInvalidMonthThrowsException() : array ]; } - public function testGetAll() + public function testGetAll(): void { $currentMonth = Month::JANUARY; @@ -82,7 +74,7 @@ public function testGetAll() } } - public function testIs() + public function testIs(): void { for ($i = Month::JANUARY; $i <= Month::DECEMBER; $i++) { for ($j = Month::JANUARY; $j <= Month::DECEMBER; $j++) { @@ -91,7 +83,7 @@ public function testIs() } } - public function testIsEqualTo() + public function testIsEqualTo(): void { for ($i = Month::JANUARY; $i <= Month::DECEMBER; $i++) { for ($j = Month::JANUARY; $j <= Month::DECEMBER; $j++) { @@ -106,14 +98,11 @@ public function testIsEqualTo() * @param int $month The month value. * @param int $minLength The expected min length. */ - public function testGetMinLength(int $month, int $minLength) + public function testGetMinLength(int $month, int $minLength): void { $this->assertSame($minLength, Month::of($month)->getMinLength()); } - /** - * @return array - */ public function minLengthProvider() : array { return [ @@ -138,14 +127,11 @@ public function minLengthProvider() : array * @param int $month The month value. * @param int $minLength The expected min length. */ - public function testGetMaxLength(int $month, int $minLength) + public function testGetMaxLength(int $month, int $minLength): void { $this->assertSame($minLength, Month::of($month)->getMaxLength()); } - /** - * @return array - */ public function maxLengthProvider() : array { return [ @@ -171,14 +157,11 @@ public function maxLengthProvider() : array * @param bool $leapYear Whether to test on a leap year. * @param int $firstDayOfYear The expected first day of year. */ - public function testFirstDayOfYear(int $month, bool $leapYear, int $firstDayOfYear) + public function testFirstDayOfYear(int $month, bool $leapYear, int $firstDayOfYear): void { $this->assertSame($firstDayOfYear, Month::of($month)->getFirstDayOfYear($leapYear)); } - /** - * @return array - */ public function providerFirstDayOfYear() : array { return [ @@ -217,14 +200,11 @@ public function providerFirstDayOfYear() : array * @param bool $leapYear Whether to test on a leap year. * @param int $expectedLength The expected month length. */ - public function testGetLength(int $month, bool $leapYear, int $expectedLength) + public function testGetLength(int $month, bool $leapYear, int $expectedLength): void { $this->assertSame($expectedLength, Month::of($month)->getLength($leapYear)); } - /** - * @return array - */ public function providerGetLength() { return [ @@ -256,7 +236,7 @@ public function providerGetLength() ]; } - public function testPlusMinusEntireYears() + public function testPlusMinusEntireYears(): void { foreach (Month::getAll() as $month) { foreach ([-24, -12, 0, 12, 24] as $monthsToAdd) { @@ -273,7 +253,7 @@ public function testPlusMinusEntireYears() * @param int $plusMonths The number of months to add. * @param int $expectedMonth The expected month number. */ - public function testPlus(int $month, int $plusMonths, int $expectedMonth) + public function testPlus(int $month, int $plusMonths, int $expectedMonth): void { $this->assertMonthIs($expectedMonth, Month::of($month)->plus($plusMonths)); } @@ -285,14 +265,11 @@ public function testPlus(int $month, int $plusMonths, int $expectedMonth) * @param int $plusMonths The number of months to add. * @param int $expectedMonth The expected month number. */ - public function testMinus(int $month, int $plusMonths, int $expectedMonth) + public function testMinus(int $month, int $plusMonths, int $expectedMonth): void { $this->assertMonthIs($expectedMonth, Month::of($month)->minus(-$plusMonths)); } - /** - * @return \Generator - */ public function providerPlus() : \Generator { for ($month = Month::JANUARY; $month <= Month::DECEMBER; $month++) { @@ -317,7 +294,7 @@ public function providerPlus() : \Generator * @param int $month The month number. * @param string $expectedName The expected month name. */ - public function testJsonSerialize(int $month, string $expectedName) + public function testJsonSerialize(int $month, string $expectedName): void { $this->assertSame(json_encode($expectedName), json_encode(Month::of($month))); } @@ -328,14 +305,11 @@ public function testJsonSerialize(int $month, string $expectedName) * @param int $month The month number. * @param string $expectedName The expected month name. */ - public function testToString(int $month, string $expectedName) + public function testToString(int $month, string $expectedName): void { $this->assertSame($expectedName, (string) Month::of($month)); } - /** - * @return array - */ public function providerToString() : array { return [ diff --git a/tests/Parser/DateTimeParseResultTest.php b/tests/Parser/DateTimeParseResultTest.php index 2759230..d54dcfd 100644 --- a/tests/Parser/DateTimeParseResultTest.php +++ b/tests/Parser/DateTimeParseResultTest.php @@ -13,7 +13,7 @@ */ class DateTimeParseResultTest extends AbstractTestCase { - public function testGetFieldWithInvalidFieldStringName() + public function testGetFieldWithInvalidFieldStringName(): void { $dateTimeParseResult = new DateTimeParseResult(); diff --git a/tests/Parser/PatternParserBuilderTest.php b/tests/Parser/PatternParserBuilderTest.php index c85f862..4fcbafe 100644 --- a/tests/Parser/PatternParserBuilderTest.php +++ b/tests/Parser/PatternParserBuilderTest.php @@ -13,7 +13,7 @@ */ class PatternParserBuilderTest extends AbstractTestCase { - public function testEndOptionalShouldThrowRuntimeException() + public function testEndOptionalShouldThrowRuntimeException(): void { $patternParserBuilder = new PatternParserBuilder(); @@ -23,7 +23,7 @@ public function testEndOptionalShouldThrowRuntimeException() $patternParserBuilder->endOptional(); } - public function testEndGroupShouldThrowRuntimeException() + public function testEndGroupShouldThrowRuntimeException(): void { $patternParserBuilder = new PatternParserBuilder(); @@ -33,7 +33,7 @@ public function testEndGroupShouldThrowRuntimeException() $patternParserBuilder->endGroup(); } - public function testToParserWithNonEmptyStack() + public function testToParserWithNonEmptyStack(): void { $patternParserBuilder = new PatternParserBuilder(); $patternParserBuilder->startGroup(); diff --git a/tests/PeriodTest.php b/tests/PeriodTest.php index baad93d..297df67 100644 --- a/tests/PeriodTest.php +++ b/tests/PeriodTest.php @@ -13,32 +13,32 @@ */ class PeriodTest extends AbstractTestCase { - public function testOf() + public function testOf(): void { $this->assertPeriodIs(1, 2, 3, Period::of(1, 2, 3)); } - public function testOfYears() + public function testOfYears(): void { $this->assertPeriodIs(11, 0, 0, Period::ofYears(11)); } - public function testOfMonths() + public function testOfMonths(): void { $this->assertPeriodIs(0, 11, 0, Period::ofMonths(11)); } - public function testOfWeeks() + public function testOfWeeks(): void { $this->assertPeriodIs(0, 0, 77, Period::ofWeeks(11)); } - public function testOfDays() + public function testOfDays(): void { $this->assertPeriodIs(0, 0, 11, Period::ofDays(11)); } - public function testZero() + public function testZero(): void { $this->assertPeriodIs(0, 0, 0, Period::zero()); } @@ -51,14 +51,11 @@ public function testZero() * @param int $months The expected months in the period. * @param int $days The expected days in the period. */ - public function testParse(string $text, int $years, int $months, int $days) + public function testParse(string $text, int $years, int $months, int $days): void { $this->assertPeriodIs($years, $months, $days, Period::parse($text)); } - /** - * @return array - */ public function providerParse() : array { return [ @@ -81,18 +78,13 @@ public function providerParse() : array /** * @dataProvider providerParseInvalidStringThrowsException - * - * @param string $text */ - public function testParseInvalidStringThrowsException(string $text) + public function testParseInvalidStringThrowsException(string $text): void { $this->expectException(DateTimeParseException::class); Period::parse($text); } - /** - * @return array - */ public function providerParseInvalidStringThrowsException() : array { return [ @@ -114,28 +106,28 @@ public function providerParseInvalidStringThrowsException() : array /** * Extensive testing is done in LocalDate::until(). */ - public function testBetween() + public function testBetween(): void { $period = Period::between(LocalDate::of(2010, 1, 15), LocalDate::of(2011, 3, 18)); $this->assertPeriodIs(1, 2, 3, $period); } - public function testWithYears() + public function testWithYears(): void { $this->assertPeriodIs(9, 2, 3, Period::of(1, 2, 3)->withYears(9)); } - public function testWithMonths() + public function testWithMonths(): void { $this->assertPeriodIs(1, 9, 3, Period::of(1, 2, 3)->withMonths(9)); } - public function testWithDays() + public function testWithDays(): void { $this->assertPeriodIs(1, 2, 9, Period::of(1, 2, 3)->withDays(9)); } - public function testWithSameValuesReturnsThis() + public function testWithSameValuesReturnsThis(): void { $period = Period::of(1, 2, 3); @@ -144,22 +136,22 @@ public function testWithSameValuesReturnsThis() $this->assertSame($period, $period->withDays(3)); } - public function testPlusYears() + public function testPlusYears(): void { $this->assertPeriodIs(11, 2, 3, Period::of(1, 2, 3)->plusYears(10)); } - public function testPlusMonths() + public function testPlusMonths(): void { $this->assertPeriodIs(1, 12, 3, Period::of(1, 2, 3)->plusMonths(10)); } - public function testPlusDays() + public function testPlusDays(): void { $this->assertPeriodIs(1, 2, 13, Period::of(1, 2, 3)->plusDays(10)); } - public function testPlusZeroReturnsThis() + public function testPlusZeroReturnsThis(): void { $period = Period::of(1, 2, 3); @@ -168,22 +160,22 @@ public function testPlusZeroReturnsThis() $this->assertSame($period, $period->plusDays(0)); } - public function testMinusYears() + public function testMinusYears(): void { $this->assertPeriodIs(-1, 2, 3, Period::of(1, 2, 3)->minusYears(2)); } - public function testMinusMonths() + public function testMinusMonths(): void { $this->assertPeriodIs(1, -2, 3, Period::of(1, 2, 3)->minusMonths(4)); } - public function testMinusDays() + public function testMinusDays(): void { $this->assertPeriodIs(1, 2, -3, Period::of(1, 2, 3)->minusDays(6)); } - public function testMinusZeroReturnsThis() + public function testMinusZeroReturnsThis(): void { $period = Period::of(1, 2, 3); @@ -192,23 +184,23 @@ public function testMinusZeroReturnsThis() $this->assertSame($period, $period->minusDays(0)); } - public function testMultipliedBy() + public function testMultipliedBy(): void { $this->assertPeriodIs(-2, -4, -6, Period::of(1, 2, 3)->multipliedBy(-2)); } - public function testMultipliedByOneReturnsThis() + public function testMultipliedByOneReturnsThis(): void { $period = Period::of(1, 2, 3); $this->assertSame($period, $period->multipliedBy(1)); } - public function testNegated() + public function testNegated(): void { $this->assertPeriodIs(-7, -8, -9, Period::of(7, 8, 9)->negated()); } - public function testZeroNegatedReturnsThis() + public function testZeroNegatedReturnsThis(): void { $period = Period::zero(); $this->assertSame($period, $period->negated()); @@ -223,14 +215,11 @@ public function testZeroNegatedReturnsThis() * @param int $ny The years of the normalized period. * @param int $nm The months of the normalized period. */ - public function testNormalized(int $y, int $m, int $d, int $ny, int $nm) + public function testNormalized(int $y, int $m, int $d, int $ny, int $nm): void { $this->assertPeriodIs($ny, $nm, $d, Period::of($y, $m, $d)->normalized()); } - /** - * @return array - */ public function providerNormalized() : array { return [ @@ -253,14 +242,11 @@ public function providerNormalized() : array * @param int $days The number of days in the period. * @param bool $isZero The expected return value. */ - public function testIsZero(int $years, int $months, int $days, bool $isZero) + public function testIsZero(int $years, int $months, int $days, bool $isZero): void { $this->assertSame($isZero, Period::of($years, $months, $days)->isZero()); } - /** - * @return array - */ public function providerIsZero() : array { return [ @@ -282,7 +268,7 @@ public function providerIsZero() : array * @param int $d2 The number of days in the 2nd period. * @param bool $isEqual The expected return value. */ - public function testIsEqualTo(int $y1, int $m1, int $d1, int $y2, int $m2, int $d2, bool $isEqual) + public function testIsEqualTo(int $y1, int $m1, int $d1, int $y2, int $m2, int $d2, bool $isEqual): void { $p1 = Period::of($y1, $m1, $d1); $p2 = Period::of($y2, $m2, $d2); @@ -291,9 +277,6 @@ public function testIsEqualTo(int $y1, int $m1, int $d1, int $y2, int $m2, int $ $this->assertSame($isEqual, $p2->isEqualTo($p1)); } - /** - * @return array - */ public function providerIsEqualTo() : array { return [ @@ -313,12 +296,8 @@ public function providerIsEqualTo() : array /** * @dataProvider providerToDateInterval - * - * @param int $years - * @param int $months - * @param int $days */ - public function testToDateInterval(int $years, int $months, int $days) + public function testToDateInterval(int $years, int $months, int $days): void { $period = Period::of($years, $months, $days); $dateInterval = $period->toDateInterval(); @@ -328,9 +307,6 @@ public function testToDateInterval(int $years, int $months, int $days) $this->assertSame($days, $dateInterval->d); } - /** - * @return array - */ public function providerToDateInterval() : array { return [ @@ -347,7 +323,7 @@ public function providerToDateInterval() : array * @param int $days The number of days in the period. * @param string $expected The expected string output. */ - public function testJsonSerialize(int $years, int $months, int $days, string $expected) + public function testJsonSerialize(int $years, int $months, int $days, string $expected): void { $this->assertSame(json_encode($expected), json_encode(Period::of($years, $months, $days))); } @@ -360,14 +336,11 @@ public function testJsonSerialize(int $years, int $months, int $days, string $ex * @param int $days The number of days in the period. * @param string $expected The expected string output. */ - public function testToString(int $years, int $months, int $days, string $expected) + public function testToString(int $years, int $months, int $days, string $expected): void { $this->assertSame($expected, (string) Period::of($years, $months, $days)); } - /** - * @return array - */ public function providerToString() : array { return [ diff --git a/tests/StopwatchTest.php b/tests/StopwatchTest.php index 41275f0..c15bfd5 100644 --- a/tests/StopwatchTest.php +++ b/tests/StopwatchTest.php @@ -28,7 +28,7 @@ private static function setClockTime(int $second, int $nano) : void self::$clock->setTime(Instant::of($second, $nano)); } - public function testConstructorWithNullClock() + public function testConstructorWithNullClock(): void { $stopwatch = new Stopwatch(); @@ -37,9 +37,6 @@ public function testConstructorWithNullClock() $this->assertDurationIs(0, 0, $stopwatch->getElapsedTime()); } - /** - * @return Stopwatch - */ public function testNew() : Stopwatch { $stopwatch = new Stopwatch(self::$clock); @@ -53,10 +50,6 @@ public function testNew() : Stopwatch /** * @depends testNew - * - * @param Stopwatch $stopwatch - * - * @return Stopwatch */ public function testStart(Stopwatch $stopwatch) : Stopwatch { @@ -73,10 +66,6 @@ public function testStart(Stopwatch $stopwatch) : Stopwatch /** * @depends testStart - * - * @param Stopwatch $stopwatch - * - * @return Stopwatch */ public function testElapsedTimeWhileRunning(Stopwatch $stopwatch) : Stopwatch { @@ -89,7 +78,7 @@ public function testElapsedTimeWhileRunning(Stopwatch $stopwatch) : Stopwatch return $stopwatch; } - public function testStopWithNullStartTime() + public function testStopWithNullStartTime(): void { $stopwatch = new Stopwatch(); $stopwatch->stop(); @@ -101,10 +90,6 @@ public function testStopWithNullStartTime() /** * @depends testElapsedTimeWhileRunning - * - * @param Stopwatch $stopwatch - * - * @return Stopwatch */ public function testStop(Stopwatch $stopwatch) : Stopwatch { @@ -121,10 +106,6 @@ public function testStop(Stopwatch $stopwatch) : Stopwatch /** * @depends testStop - * - * @param Stopwatch $stopwatch - * - * @return Stopwatch */ public function testFrozenAfterStop(Stopwatch $stopwatch) : Stopwatch { @@ -139,10 +120,6 @@ public function testFrozenAfterStop(Stopwatch $stopwatch) : Stopwatch /** * @depends testFrozenAfterStop - * - * @param Stopwatch $stopwatch - * - * @return Stopwatch */ public function testRestart(Stopwatch $stopwatch) : Stopwatch { @@ -159,10 +136,6 @@ public function testRestart(Stopwatch $stopwatch) : Stopwatch /** * @depends testRestart - * - * @param Stopwatch $stopwatch - * - * @return Stopwatch */ public function testElapsedTimeWhileRunningAfterRestart(Stopwatch $stopwatch) : Stopwatch { @@ -177,10 +150,6 @@ public function testElapsedTimeWhileRunningAfterRestart(Stopwatch $stopwatch) : /** * @depends testElapsedTimeWhileRunningAfterRestart - * - * @param Stopwatch $stopwatch - * - * @return Stopwatch */ public function testStopAgain(Stopwatch $stopwatch) : Stopwatch { @@ -197,10 +166,8 @@ public function testStopAgain(Stopwatch $stopwatch) : Stopwatch /** * @depends testStopAgain - * - * @param Stopwatch $stopwatch */ - public function testFrozenAfterSecondStop(Stopwatch $stopwatch) + public function testFrozenAfterSecondStop(Stopwatch $stopwatch): void { self::setClockTime(6000, 999); diff --git a/tests/TimeZoneOffsetTest.php b/tests/TimeZoneOffsetTest.php index f804bce..98de4f8 100644 --- a/tests/TimeZoneOffsetTest.php +++ b/tests/TimeZoneOffsetTest.php @@ -22,14 +22,11 @@ class TimeZoneOffsetTest extends AbstractTestCase * @param int $seconds The seconds part of the offset. * @param int $totalSeconds The expected total number of seconds. */ - public function testOf(int $hours, int $minutes, int $seconds, int $totalSeconds) + public function testOf(int $hours, int $minutes, int $seconds, int $totalSeconds): void { $this->assertTimeZoneOffsetIs($totalSeconds, TimeZoneOffset::of($hours, $minutes, $seconds)); } - /** - * @return array - */ public function providerOf() : array { return [ @@ -62,20 +59,13 @@ public function providerOf() : array /** * @dataProvider providerOfInvalidValuesThrowsException - * - * @param int $hours - * @param int $minutes - * @param int $seconds */ - public function testOfInvalidValuesThrowsException(int $hours, int $minutes, int $seconds) + public function testOfInvalidValuesThrowsException(int $hours, int $minutes, int $seconds): void { $this->expectException(DateTimeException::class); TimeZoneOffset::of($hours, $minutes, $seconds); } - /** - * @return array - */ public function providerOfInvalidValuesThrowsException() : array { return [ @@ -103,17 +93,12 @@ public function providerOfInvalidValuesThrowsException() : array /** * @dataProvider providerTotalSeconds - * - * @param int $totalSeconds */ - public function testOfTotalSeconds(int $totalSeconds) + public function testOfTotalSeconds(int $totalSeconds): void { $this->assertTimeZoneOffsetIs($totalSeconds, TimeZoneOffset::ofTotalSeconds($totalSeconds)); } - /** - * @return array - */ public function providerTotalSeconds() : array { return [ @@ -127,18 +112,13 @@ public function providerTotalSeconds() : array /** * @dataProvider providerOfInvalidTotalSecondsThrowsException - * - * @param int $totalSeconds */ - public function testOfInvalidTotalSecondsThrowsException(int $totalSeconds) + public function testOfInvalidTotalSecondsThrowsException(int $totalSeconds): void { $this->expectException(DateTimeException::class); TimeZoneOffset::ofTotalSeconds($totalSeconds); } - /** - * @return array - */ public function providerOfInvalidTotalSecondsThrowsException() : array { return [ @@ -147,7 +127,7 @@ public function providerOfInvalidTotalSecondsThrowsException() : array ]; } - public function testUtc() + public function testUtc(): void { $this->assertTimeZoneOffsetIs(0, TimeZoneOffset::utc()); } @@ -158,14 +138,11 @@ public function testUtc() * @param string $text The text to parse. * @param int $totalSeconds The expected total offset seconds. */ - public function testParse(string $text, int $totalSeconds) + public function testParse(string $text, int $totalSeconds): void { $this->assertTimeZoneOffsetIs($totalSeconds, TimeZoneOffset::parse($text)); } - /** - * @return array - */ public function providerParse() : array { return [ @@ -186,18 +163,13 @@ public function providerParse() : array /** * @dataProvider providerParseInvalidStringThrowsException - * - * @param string $text */ - public function testParseInvalidStringThrowsException(string $text) + public function testParseInvalidStringThrowsException(string $text): void { $this->expectException(DateTimeParseException::class); TimeZoneOffset::parse($text); } - /** - * @return array - */ public function providerParseInvalidStringThrowsException() : array { return [ @@ -214,18 +186,13 @@ public function providerParseInvalidStringThrowsException() : array /** * @dataProvider providerParseValueStringThrowsException - * - * @param string $text */ - public function testParseInvalidValueThrowsException(string $text) + public function testParseInvalidValueThrowsException(string $text): void { $this->expectException(DateTimeException::class); TimeZoneOffset::parse($text); } - /** - * @return array - */ public function providerParseValueStringThrowsException() : array { return [ @@ -244,7 +211,7 @@ public function providerParseValueStringThrowsException() : array * @param int $totalSeconds The total offset seconds. * @param string $expectedId The expected id. */ - public function testGetId(int $totalSeconds, string $expectedId) + public function testGetId(int $totalSeconds, string $expectedId): void { $this->assertSame($expectedId, TimeZoneOffset::ofTotalSeconds($totalSeconds)->getId()); } @@ -255,14 +222,11 @@ public function testGetId(int $totalSeconds, string $expectedId) * @param int $totalSeconds The total offset seconds. * @param string $string The expected string. */ - public function testToString(int $totalSeconds, string $string) + public function testToString(int $totalSeconds, string $string): void { $this->assertSame($string, (string) TimeZoneOffset::ofTotalSeconds($totalSeconds)); } - /** - * @return array - */ public function providerGetId() : array { return [ @@ -286,7 +250,7 @@ public function providerGetId() : array ]; } - public function testGetOffset() + public function testGetOffset(): void { $whateverInstant = Instant::of(123456789, 987654321); $timeZoneOffset = TimeZoneOffset::ofTotalSeconds(-18000); @@ -294,7 +258,7 @@ public function testGetOffset() $this->assertSame(-18000, $timeZoneOffset->getOffset($whateverInstant)); } - public function testToDateTimeZone() + public function testToDateTimeZone(): void { $dateTimeZone = TimeZoneOffset::ofTotalSeconds(-18000)->toDateTimeZone(); diff --git a/tests/TimeZoneRegionTest.php b/tests/TimeZoneRegionTest.php index 1342f42..95a0817 100644 --- a/tests/TimeZoneRegionTest.php +++ b/tests/TimeZoneRegionTest.php @@ -14,25 +14,20 @@ */ class TimeZoneRegionTest extends AbstractTestCase { - public function testOf() + public function testOf(): void { $this->assertSame('Europe/London', TimeZoneRegion::of('Europe/London')->getId()); } /** * @dataProvider providerOfInvalidRegionThrowsException - * - * @param string $region */ - public function testOfInvalidRegionThrowsException(string $region) + public function testOfInvalidRegionThrowsException(string $region): void { $this->expectException(DateTimeException::class); TimeZoneRegion::of($region); } - /** - * @return array - */ public function providerOfInvalidRegionThrowsException() : array { return [ @@ -45,25 +40,20 @@ public function providerOfInvalidRegionThrowsException() : array ]; } - public function testParse() + public function testParse(): void { $this->assertSame('Europe/London', TimeZoneRegion::parse('Europe/London')->getId()); } /** * @dataProvider providerParseInvalidStringThrowsException - * - * @param string $text */ - public function testParseInvalidStringThrowsException(string $text) + public function testParseInvalidStringThrowsException(string $text): void { $this->expectException(DateTimeParseException::class); TimeZoneRegion::parse($text); } - /** - * @return array - */ public function providerParseInvalidStringThrowsException() : array { return [ @@ -74,10 +64,8 @@ public function providerParseInvalidStringThrowsException() : array /** * @dataProvider providerGetAllTimeZones - * - * @param bool $includeObsolete */ - public function testGetAllTimeZones(bool $includeObsolete) + public function testGetAllTimeZones(bool $includeObsolete): void { $identifiers = TimeZoneRegion::getAllIdentifiers($includeObsolete); $this->assertGreaterThan(1, \count($identifiers)); @@ -107,9 +95,6 @@ public function testGetAllTimeZones(bool $includeObsolete) } } - /** - * @return array - */ public function providerGetAllTimeZones() : array { return [ @@ -120,20 +105,14 @@ public function providerGetAllTimeZones() : array /** * @dataProvider providerGetTimeZonesForCountry - * - * @param string $countryCode - * @param string[] $expectedIdentifiers */ - public function testGetTimeZonesForCountry(string $countryCode, string ...$expectedIdentifiers) + public function testGetTimeZonesForCountry(string $countryCode, string ...$expectedIdentifiers): void { $identifiers = TimeZoneRegion::getIdentifiersForCountry($countryCode); $this->assertSame($expectedIdentifiers, $identifiers); } - /** - * @return array - */ public function providerGetTimeZonesForCountry() : array { return [ @@ -156,15 +135,12 @@ public function providerGetTimeZonesForCountry() : array * @param int $epochSecond The instant to test. * @param int $expectedOffset The expected offset in seconds. */ - public function testGetOffset(string $region, int $epochSecond, int $expectedOffset) + public function testGetOffset(string $region, int $epochSecond, int $expectedOffset): void { $actualOffset = TimeZoneRegion::of($region)->getOffset(Instant::of($epochSecond)); $this->assertSame($expectedOffset, $actualOffset); } - /** - * @return array - */ public function providerGetOffset() : array { return [ @@ -175,7 +151,7 @@ public function providerGetOffset() : array ]; } - public function testToDateTimeZone() + public function testToDateTimeZone(): void { $dateTimeZone = TimeZoneRegion::of('Europe/London')->toDateTimeZone(); @@ -183,12 +159,12 @@ public function testToDateTimeZone() $this->assertSame('Europe/London', $dateTimeZone->getName()); } - public function testGetId() + public function testGetId(): void { $this->assertSame('Europe/Paris', TimeZoneRegion::of('Europe/Paris')->getId()); } - public function testToString() + public function testToString(): void { $this->assertSame('America/Los_Angeles', (string) TimeZoneRegion::of('America/Los_Angeles')); } diff --git a/tests/TimeZoneTest.php b/tests/TimeZoneTest.php index cd26df6..4e4709f 100644 --- a/tests/TimeZoneTest.php +++ b/tests/TimeZoneTest.php @@ -21,7 +21,7 @@ class TimeZoneTest extends AbstractTestCase * @param string $class The expected class name. * @param string $id The expected id. */ - public function testParse(string $text, string $class, string $id) + public function testParse(string $text, string $class, string $id): void { $timeZone = TimeZone::parse($text); @@ -29,9 +29,6 @@ public function testParse(string $text, string $class, string $id) $this->assertSame($id, $timeZone->getId()); } - /** - * @return array - */ public function providerParse() : array { return [ @@ -46,18 +43,13 @@ public function providerParse() : array /** * @dataProvider providerParseInvalidStringThrowsException - * - * @param string $text */ - public function testParseInvalidStringThrowsException(string $text) + public function testParseInvalidStringThrowsException(string $text): void { $this->expectException(DateTimeParseException::class); TimeZone::parse($text); } - /** - * @return array - */ public function providerParseInvalidStringThrowsException() : array { return [ @@ -67,12 +59,12 @@ public function providerParseInvalidStringThrowsException() : array ]; } - public function testUtc() + public function testUtc(): void { $this->assertTimeZoneOffsetIs(0, TimeZone::utc()); } - public function testIsEqualTo() + public function testIsEqualTo(): void { $this->assertTrue(TimeZone::utc()->isEqualTo(TimeZoneOffset::ofTotalSeconds(0))); $this->assertFalse(TimeZone::utc()->isEqualTo(TimeZoneOffset::ofTotalSeconds(1))); @@ -83,15 +75,12 @@ public function testIsEqualTo() * * @param string $tz The time-zone name. */ - public function testFromDateTimeZone(string $tz) + public function testFromDateTimeZone(string $tz): void { $dateTimeZone = new \DateTimeZone($tz); $this->assertSame($tz, TimeZone::fromDateTimeZone($dateTimeZone)->getId()); } - /** - * @return array - */ public function providerFromDateTimeZone() : array { return [ diff --git a/tests/Utility/MathTest.php b/tests/Utility/MathTest.php index 61eb655..39cbace 100644 --- a/tests/Utility/MathTest.php +++ b/tests/Utility/MathTest.php @@ -20,14 +20,11 @@ class MathTest extends TestCase * @param int $b The divisor. * @param int $expected The expected floor division result. */ - public function testFloorDiv(int $a, int $b, int $expected) + public function testFloorDiv(int $a, int $b, int $expected): void { $this->assertSame($expected, Math::floorDiv($a, $b)); } - /** - * @return array - */ public function providerFloorDiv() : array { return [ @@ -45,14 +42,11 @@ public function providerFloorDiv() : array * @param int $b The divisor. * @param int $expected The expected floor modulus result. */ - public function testFloorMod(int $a, int $b, int $expected) + public function testFloorMod(int $a, int $b, int $expected): void { $this->assertSame($expected, Math::floorMod($a, $b)); } - /** - * @return array - */ public function providerFloorMod() : array { return [ diff --git a/tests/YearMonthRangeTest.php b/tests/YearMonthRangeTest.php index cd548ba..cf97738 100644 --- a/tests/YearMonthRangeTest.php +++ b/tests/YearMonthRangeTest.php @@ -14,7 +14,7 @@ */ class YearMonthRangeTest extends AbstractTestCase { - public function testOf() + public function testOf(): void { $this->assertYearMonthRangeIs(2001, 2, 2004, 5, YearMonthRange::of( YearMonth::of(2001, 2), @@ -22,7 +22,7 @@ public function testOf() )); } - public function testOfInvalidRangeThrowsException() + public function testOfInvalidRangeThrowsException(): void { $this->expectException(DateTimeException::class); @@ -41,14 +41,11 @@ public function testOfInvalidRangeThrowsException() * @param int $y2 The expected end year. * @param int $m2 The expected end month. */ - public function testParse(string $text, int $y1, int $m1, int $y2, int $m2) + public function testParse(string $text, int $y1, int $m1, int $y2, int $m2): void { $this->assertYearMonthRangeIs($y1, $m1, $y2, $m2, YearMonthRange::parse($text)); } - /** - * @return array - */ public function providerParse() : array { return [ @@ -62,15 +59,12 @@ public function providerParse() : array * * @param string $text The invalid text to parse. */ - public function testParseInvalidRangeThrowsException(string $text) + public function testParseInvalidRangeThrowsException(string $text): void { $this->expectException(DateTimeParseException::class); YearMonthRange::parse($text); } - /** - * @return array - */ public function providerParseInvalidRangeThrowsException() : array { return [ @@ -90,7 +84,7 @@ public function providerParseInvalidRangeThrowsException() : array * @param string $testRange The string representation of the range to test. * @param bool $isEqual Whether this range is expected to be equal to our range. */ - public function testIsEqualTo(string $testRange, bool $isEqual) + public function testIsEqualTo(string $testRange, bool $isEqual): void { $this->assertSame($isEqual, YearMonthRange::of( YearMonth::of(2001, 2), @@ -98,9 +92,6 @@ public function testIsEqualTo(string $testRange, bool $isEqual) )->isEqualTo(YearMonthRange::parse($testRange))); } - /** - * @return array - */ public function providerIsEqualTo() : array { return [ @@ -114,19 +105,12 @@ public function providerIsEqualTo() : array /** * @dataProvider providerContains - * - * @param string $range - * @param string $yearMonth - * @param bool $contains */ - public function testContains(string $range, string $yearMonth, bool $contains) + public function testContains(string $range, string $yearMonth, bool $contains): void { $this->assertSame($contains, YearMonthRange::parse($range)->contains(YearMonth::parse($yearMonth))); } - /** - * @return array - */ public function providerContains() : array { return [ @@ -143,7 +127,7 @@ public function providerContains() : array ]; } - public function testIterator() + public function testIterator(): void { $start = YearMonth::of(2013, 10); $end = YearMonth::of(2014, 3); @@ -176,14 +160,11 @@ public function testIterator() * @param string $range The year-month range string representation. * @param int $count The expected day count. */ - public function testCount(string $range, int $count) + public function testCount(string $range, int $count): void { $this->assertCount($count, YearMonthRange::parse($range)); } - /** - * @return array - */ public function providerCount() : array { return [ @@ -195,7 +176,7 @@ public function providerCount() : array ]; } - public function testJsonSerialize() + public function testJsonSerialize(): void { $this->assertSame(json_encode('2008-12/2011-01'), json_encode(YearMonthRange::of( YearMonth::of(2008, 12), @@ -203,7 +184,7 @@ public function testJsonSerialize() ))); } - public function testToString() + public function testToString(): void { $this->assertSame('2008-12/2011-01', (string) YearMonthRange::of( YearMonth::of(2008, 12), diff --git a/tests/YearMonthTest.php b/tests/YearMonthTest.php index 309a3bc..18b0547 100644 --- a/tests/YearMonthTest.php +++ b/tests/YearMonthTest.php @@ -15,7 +15,7 @@ */ class YearMonthTest extends AbstractTestCase { - public function testOf() + public function testOf(): void { $this->assertYearMonthIs(2007, 7, YearMonth::of(2007, 7)); } @@ -27,14 +27,11 @@ public function testOf() * @param int $year The expected year. * @param int $month The expected month. */ - public function testParse(string $text, int $year, int $month) + public function testParse(string $text, int $year, int $month): void { $this->assertYearMonthIs($year, $month, YearMonth::parse($text)); } - /** - * @return array - */ public function providerParse() : array { return [ @@ -51,15 +48,12 @@ public function providerParse() : array * * @param string $text The text to parse. */ - public function testParseInvalidStringThrowsException(string $text) + public function testParseInvalidStringThrowsException(string $text): void { $this->expectException(DateTimeException::class); YearMonth::parse($text); } - /** - * @return array - */ public function providerParseInvalidStringThrowsException() : array { return [ @@ -77,15 +71,12 @@ public function providerParseInvalidStringThrowsException() : array * * @param string $text The text to parse. */ - public function testParseInvalidYearMonthThrowsException(string $text) + public function testParseInvalidYearMonthThrowsException(string $text): void { $this->expectException(DateTimeException::class); YearMonth::parse($text); } - /** - * @return array - */ public function providerParseInvalidYearMonthThrowsException() : array { return [ @@ -102,15 +93,12 @@ public function providerParseInvalidYearMonthThrowsException() : array * @param int $year The expected year. * @param int $month The expected month. */ - public function testNow(int $epochSecond, string $timeZone, int $year, int $month) + public function testNow(int $epochSecond, string $timeZone, int $year, int $month): void { $clock = new FixedClock(Instant::of($epochSecond)); $this->assertYearMonthIs($year, $month, YearMonth::now(TimeZone::parse($timeZone), $clock)); } - /** - * @return array - */ public function providerNow() : array { return [ @@ -128,14 +116,11 @@ public function providerNow() : array * @param int $month The month to test. * @param bool $isLeap The expected result. */ - public function testIsLeapYear(int $year, int $month, bool $isLeap) + public function testIsLeapYear(int $year, int $month, bool $isLeap): void { $this->assertSame($isLeap, YearMonth::of($year, $month)->isLeapYear()); } - /** - * @return array - */ public function providerIsLeapYear() : array { return [ @@ -155,14 +140,11 @@ public function providerIsLeapYear() : array * @param int $month The month. * @param int $length The expected length of month. */ - public function testGetLengthOfMonth(int $year, int $month, int $length) + public function testGetLengthOfMonth(int $year, int $month, int $length): void { $this->assertSame($length, YearMonth::of($year, $month)->getLengthOfMonth()); } - /** - * @return array - */ public function providerGetLengthOfMonth() : array { return [ @@ -200,14 +182,11 @@ public function providerGetLengthOfMonth() : array * @param int $month The month. * @param int $length The expected length of year. */ - public function testGetLengthOfYear(int $year, int $month, int $length) + public function testGetLengthOfYear(int $year, int $month, int $length): void { $this->assertSame($length, YearMonth::of($year, $month)->getLengthOfYear()); } - /** - * @return array - */ public function providerGetLengthOfYear() : array { return [ @@ -226,7 +205,7 @@ public function providerGetLengthOfYear() : array * @param int $m2 The month of the year-month to compare to. * @param int $result The expected result. */ - public function testCompareTo(int $y1, int $m1, int $y2, int $m2, int $result) + public function testCompareTo(int $y1, int $m1, int $y2, int $m2, int $result): void { $this->assertSame($result, YearMonth::of($y1, $m1)->compareTo(YearMonth::of($y2, $m2))); } @@ -240,7 +219,7 @@ public function testCompareTo(int $y1, int $m1, int $y2, int $m2, int $result) * @param int $m2 The month of the year-month to compare to. * @param int $result The comparison result. */ - public function testIsEqualTo(int $y1, int $m1, int $y2, int $m2, int $result) + public function testIsEqualTo(int $y1, int $m1, int $y2, int $m2, int $result): void { $this->assertSame($result == 0, YearMonth::of($y1, $m1)->isEqualTo(YearMonth::of($y2, $m2))); } @@ -254,7 +233,7 @@ public function testIsEqualTo(int $y1, int $m1, int $y2, int $m2, int $result) * @param int $m2 The month of the year-month to compare to. * @param int $result The comparison result. */ - public function testIsBefore(int $y1, int $m1, int $y2, int $m2, int $result) + public function testIsBefore(int $y1, int $m1, int $y2, int $m2, int $result): void { $this->assertSame($result == -1, YearMonth::of($y1, $m1)->isBefore(YearMonth::of($y2, $m2))); } @@ -268,7 +247,7 @@ public function testIsBefore(int $y1, int $m1, int $y2, int $m2, int $result) * @param int $m2 The month of the year-month to compare to. * @param int $result The comparison result. */ - public function testIsBeforeOrEqualTo(int $y1, int $m1, int $y2, int $m2, int $result) + public function testIsBeforeOrEqualTo(int $y1, int $m1, int $y2, int $m2, int $result): void { $this->assertSame($result <= 0, YearMonth::of($y1, $m1)->isBeforeOrEqualTo(YearMonth::of($y2, $m2))); } @@ -282,7 +261,7 @@ public function testIsBeforeOrEqualTo(int $y1, int $m1, int $y2, int $m2, int $r * @param int $m2 The month of the year-month to compare to. * @param int $result The comparison result. */ - public function testIsAfter(int $y1, int $m1, int $y2, int $m2, int $result) + public function testIsAfter(int $y1, int $m1, int $y2, int $m2, int $result): void { $this->assertSame($result == 1, YearMonth::of($y1, $m1)->isAfter(YearMonth::of($y2, $m2))); } @@ -296,14 +275,11 @@ public function testIsAfter(int $y1, int $m1, int $y2, int $m2, int $result) * @param int $m2 The month of the year-month to compare to. * @param int $result The comparison result. */ - public function testIsAfterOrEqualTo(int $y1, int $m1, int $y2, int $m2, int $result) + public function testIsAfterOrEqualTo(int $y1, int $m1, int $y2, int $m2, int $result): void { $this->assertSame($result >= 0, YearMonth::of($y1, $m1)->isAfterOrEqualTo(YearMonth::of($y2, $m2))); } - /** - * @return array - */ public function providerCompareTo() : array { return [ @@ -326,46 +302,39 @@ public function providerCompareTo() : array ]; } - public function testWithYear() + public function testWithYear(): void { $this->assertYearMonthIs(2001, 5, YearMonth::of(2000, 5)->withYear(2001)); } - public function testWithYearWithSameYear() + public function testWithYearWithSameYear(): void { $this->assertYearMonthIs(2018, 2, YearMonth::of(2018, 2)->withYear(2018)); } - public function testWithMonth() + public function testWithMonth(): void { $this->assertYearMonthIs(2000, 12, YearMonth::of(2000, 1)->withMonth(12)); } - public function testWithMonthWithSameMonth() + public function testWithMonthWithSameMonth(): void { $this->assertYearMonthIs(2000, 2, YearMonth::of(2000, 2)->withMonth(2)); } - public function testGetFirstDay() + public function testGetFirstDay(): void { $this->assertLocalDateIs(2023, 10, 1, YearMonth::of(2023, 10)->getFirstDay()); } /** * @dataProvider providerGetLastDay - * - * @param int $year - * @param int $month - * @param int $day */ - public function testGetLastDay(int $year, int $month, int $day) + public function testGetLastDay(int $year, int $month, int $day): void { $this->assertLocalDateIs($year, $month, $day, YearMonth::of($year, $month)->getLastDay()); } - /** - * @return array - */ public function providerGetLastDay() : array { return [ @@ -377,35 +346,26 @@ public function providerGetLastDay() : array ]; } - public function testAtDay() + public function testAtDay(): void { $this->assertLocalDateIs(2001, 2, 3, YearMonth::of(2001, 02)->atDay(3)); } /** * @dataProvider providerPlusYears - * - * @param int $year - * @param int $month - * @param int $plusYears - * @param int $expectedYear - * @param int $expectedMonth */ - public function testPlusYears(int $year, int $month, int $plusYears, int $expectedYear, int $expectedMonth) + public function testPlusYears(int $year, int $month, int $plusYears, int $expectedYear, int $expectedMonth): void { $yearMonth = YearMonth::of($year, $month); $this->assertYearMonthIs($expectedYear, $expectedMonth, $yearMonth->plusYears($plusYears)); } - public function testPlusZeroYears() + public function testPlusZeroYears(): void { $yearMonth = YearMonth::of(2005, 1); $this->assertYearMonthIs(2005, 1, $yearMonth->plusYears(0)); } - /** - * @return array - */ public function providerPlusYears() : array { return [ @@ -416,22 +376,13 @@ public function providerPlusYears() : array /** * @dataProvider providerMinusYears - * - * @param int $year - * @param int $month - * @param int $plusYears - * @param int $expectedYear - * @param int $expectedMonth */ - public function testMinusYears(int $year, int $month, int $plusYears, int $expectedYear, int $expectedMonth) + public function testMinusYears(int $year, int $month, int $plusYears, int $expectedYear, int $expectedMonth): void { $yearMonth = YearMonth::of($year, $month); $this->assertYearMonthIs($expectedYear, $expectedMonth, $yearMonth->minusYears($plusYears)); } - /** - * @return array - */ public function providerMinusYears() : array { return [ @@ -442,22 +393,13 @@ public function providerMinusYears() : array /** * @dataProvider providerPlusMonths - * - * @param int $year - * @param int $month - * @param int $plusMonths - * @param int $expectedYear - * @param int $expectedMonth */ - public function testPlusMonths(int $year, int $month, int $plusMonths, int $expectedYear, int $expectedMonth) + public function testPlusMonths(int $year, int $month, int $plusMonths, int $expectedYear, int $expectedMonth): void { $yearMonth = YearMonth::of($year, $month); $this->assertYearMonthIs($expectedYear, $expectedMonth, $yearMonth->plusMonths($plusMonths)); } - /** - * @return array - */ public function providerPlusMonths() : array { return [ @@ -475,22 +417,13 @@ public function providerPlusMonths() : array /** * @dataProvider providerMinusMonths - * - * @param int $year - * @param int $month - * @param int $plusMonths - * @param int $expectedYear - * @param int $expectedMonth */ - public function testMinusMonths(int $year, int $month, int $plusMonths, int $expectedYear, int $expectedMonth) + public function testMinusMonths(int $year, int $month, int $plusMonths, int $expectedYear, int $expectedMonth): void { $yearMonth = YearMonth::of($year, $month); $this->assertYearMonthIs($expectedYear, $expectedMonth, $yearMonth->minusMonths($plusMonths)); } - /** - * @return array - */ public function providerMinusMonths() : array { return [ @@ -506,12 +439,12 @@ public function providerMinusMonths() : array ]; } - public function testJsonSerialize() + public function testJsonSerialize(): void { $this->assertSame(json_encode('2013-09'), json_encode(YearMonth::of(2013, 9))); } - public function testToString() + public function testToString(): void { $this->assertSame('2013-09', (string) YearMonth::of(2013, 9)); } diff --git a/tests/YearTest.php b/tests/YearTest.php index 659b6b0..ba7f51f 100644 --- a/tests/YearTest.php +++ b/tests/YearTest.php @@ -16,25 +16,20 @@ */ class YearTest extends AbstractTestCase { - public function testOf() + public function testOf(): void { $this->assertYearIs(1987, Year::of(1987)); } /** * @dataProvider providerOfInvalidYearThrowsException - * - * @param int $invalidYear */ - public function testOfInvalidYearThrowsException(int $invalidYear) + public function testOfInvalidYearThrowsException(int $invalidYear): void { $this->expectException(DateTimeException::class); Year::of($invalidYear); } - /** - * @return array - */ public function providerOfInvalidYearThrowsException() : array { return [ @@ -52,15 +47,12 @@ public function providerOfInvalidYearThrowsException() : array * @param string $timeZone The time-zone to get the current year in. * @param int $expectedYear The expected year. */ - public function testNow(int $epochSecond, string $timeZone, int $expectedYear) + public function testNow(int $epochSecond, string $timeZone, int $expectedYear): void { $clock = new FixedClock(Instant::of($epochSecond)); $this->assertYearIs($expectedYear, Year::now(TimeZone::parse($timeZone), $clock)); } - /** - * @return array - */ public function providerNow() : array { return [ @@ -79,14 +71,11 @@ public function providerNow() : array * @param int $year The year to test. * @param bool $isLeap Whether the year is a leap year. */ - public function testIsLeap(int $year, bool $isLeap) + public function testIsLeap(int $year, bool $isLeap): void { $this->assertSame($isLeap, Year::of($year)->isLeap()); } - /** - * @return array - */ public function providerIsLeap() : array { return [ @@ -156,14 +145,11 @@ public function providerIsLeap() : array * @param int $day The day-of-month of the month-day to test. * @param bool $isValid Whether the month-day is expected to be valid. */ - public function testIsValidMonthDay(int $year, int $month, int $day, bool $isValid) + public function testIsValidMonthDay(int $year, int $month, int $day, bool $isValid): void { $this->assertSame($isValid, Year::of($year)->isValidMonthDay(MonthDay::of($month, $day))); } - /** - * @return array - */ public function providerIsValidMonthDay() : array { return [ @@ -185,14 +171,11 @@ public function providerIsValidMonthDay() : array * @param int $year The year to test. * @param int $length The expected length of year in days. */ - public function testGetLength(int $year, int $length) + public function testGetLength(int $year, int $length): void { $this->assertSame($length, Year::of($year)->getLength()); } - /** - * @return array - */ public function providerGetLength() : array { return [ @@ -256,19 +239,12 @@ public function providerGetLength() : array /** * @dataProvider providerPlus - * - * @param int $year - * @param int $plusYears - * @param int $expectedYear */ - public function testPlus(int $year, int $plusYears, int $expectedYear) + public function testPlus(int $year, int $plusYears, int $expectedYear): void { $this->assertYearIs($expectedYear, Year::of($year)->plus($plusYears)); } - /** - * @return array - */ public function providerPlus() : array { return [ @@ -280,19 +256,12 @@ public function providerPlus() : array /** * @dataProvider providerMinus - * - * @param int $year - * @param int $minusYears - * @param int $expectedYear */ - public function testMinus(int $year, int $minusYears, int $expectedYear) + public function testMinus(int $year, int $minusYears, int $expectedYear): void { $this->assertYearIs($expectedYear, Year::of($year)->minus($minusYears)); } - /** - * @return array - */ public function providerMinus() : array { return [ @@ -309,7 +278,7 @@ public function providerMinus() : array * @param int $year2 The year to compare to. * @param int $cmp The comparison value. */ - public function testCompareTo(int $year1, int $year2, int $cmp) + public function testCompareTo(int $year1, int $year2, int $cmp): void { $this->assertSame($cmp, Year::of($year1)->compareTo(Year::of($year2))); } @@ -321,7 +290,7 @@ public function testCompareTo(int $year1, int $year2, int $cmp) * @param int $year2 The year to compare to. * @param int $cmp The comparison value. */ - public function testIsEqualTo(int $year1, int $year2, int $cmp) + public function testIsEqualTo(int $year1, int $year2, int $cmp): void { $this->assertSame($cmp === 0, Year::of($year1)->isEqualTo(Year::of($year2))); } @@ -333,7 +302,7 @@ public function testIsEqualTo(int $year1, int $year2, int $cmp) * @param int $year2 The year to compare to. * @param int $cmp The comparison value. */ - public function testIsAfter(int $year1, int $year2, int $cmp) + public function testIsAfter(int $year1, int $year2, int $cmp): void { $this->assertSame($cmp === 1, Year::of($year1)->isAfter(Year::of($year2))); } @@ -345,14 +314,11 @@ public function testIsAfter(int $year1, int $year2, int $cmp) * @param int $year2 The year to compare to. * @param int $cmp The comparison value. */ - public function testIsBefore(int $year1, int $year2, int $cmp) + public function testIsBefore(int $year1, int $year2, int $cmp): void { $this->assertSame($cmp === -1, Year::of($year1)->isBefore(Year::of($year2))); } - /** - * @return array - */ public function providerCompareTo() : array { return [ @@ -392,14 +358,11 @@ public function providerCompareTo() : array * @param int $month The expected month of the resulting date. * @param int $day The expected day-of-month of the resulting date. */ - public function testAtDay(int $year, int $dayOfYear, int $month, int $day) + public function testAtDay(int $year, int $dayOfYear, int $month, int $day): void { $this->assertLocalDateIs($year, $month, $day, Year::of($year)->atDay($dayOfYear)); } - /** - * @return array - */ public function providerAtDay() : array { return [ @@ -414,31 +377,26 @@ public function providerAtDay() : array ]; } - public function testAtInvalidDayThrowsException() + public function testAtInvalidDayThrowsException(): void { $this->expectException(DateTimeException::class); Year::of(2007)->atDay(366); } - public function testAtMonth() + public function testAtMonth(): void { $this->assertYearMonthIs(2014, 7, Year::of(2014)->atMonth(7)); } /** * @dataProvider providerAtInvalidMonthThrowsException - * - * @param int $invalidMonth */ - public function testAtInvalidMonthThrowsException(int $invalidMonth) + public function testAtInvalidMonthThrowsException(int $invalidMonth): void { $this->expectException(DateTimeException::class); Year::of(2000)->atMonth($invalidMonth); } - /** - * @return array - */ public function providerAtInvalidMonthThrowsException() : array { return [ @@ -456,15 +414,12 @@ public function providerAtInvalidMonthThrowsException() : array * @param int $day The day-of-month of the month-day to apply. * @param int $expectedDay The expected day of the resulting date. */ - public function testAtMonthDay(int $year, int $month, int $day, int $expectedDay) + public function testAtMonthDay(int $year, int $month, int $day, int $expectedDay): void { $monthDay = MonthDay::of($month, $day); $this->assertLocalDateIs($year, $month, $expectedDay, Year::of($year)->atMonthDay($monthDay)); } - /** - * @return array - */ public function providerAtMonthDay() : array { return [ @@ -478,12 +433,12 @@ public function providerAtMonthDay() : array ]; } - public function testJsonSerialize() + public function testJsonSerialize(): void { $this->assertSame(json_encode('1987'), json_encode(Year::of(1987))); } - public function testToString() + public function testToString(): void { $this->assertSame('1987', (string) Year::of(1987)); } diff --git a/tests/YearWeekTest.php b/tests/YearWeekTest.php index 5a0b59b..42d8b71 100644 --- a/tests/YearWeekTest.php +++ b/tests/YearWeekTest.php @@ -17,9 +17,6 @@ */ class YearWeekTest extends AbstractTestCase { - /** - * @return array - */ public function provider53WeekYear() : array { return [ @@ -99,10 +96,8 @@ public function provider53WeekYear() : array /** * @dataProvider provider53WeekYear - * - * @param int $year */ - public function testIs53WeekYear(int $year) + public function testIs53WeekYear(int $year): void { $yearWeek = YearWeek::of($year, 1); $this->assertTrue($yearWeek->is53WeekYear()); @@ -110,15 +105,8 @@ public function testIs53WeekYear(int $year) /** * @dataProvider providerAtDay - * - * @param int $weekBasedYear - * @param int $weekOfWeekBasedYear - * @param int $dayOfWeek - * @param int $year - * @param int $month - * @param int $dayOfMonth */ - public function testAtDay(int $weekBasedYear, int $weekOfWeekBasedYear, int $dayOfWeek, int $year, int $month, int $dayOfMonth) + public function testAtDay(int $weekBasedYear, int $weekOfWeekBasedYear, int $dayOfWeek, int $year, int $month, int $dayOfMonth): void { $yearWeek = YearWeek::of($weekBasedYear, $weekOfWeekBasedYear); $actual = $yearWeek->atDay($dayOfWeek); @@ -126,9 +114,6 @@ public function testAtDay(int $weekBasedYear, int $weekOfWeekBasedYear, int $day $this->assertLocalDateIs($year, $month, $dayOfMonth, $actual); } - /** - * @return array - */ public function providerAtDay() : array { return [ @@ -162,7 +147,7 @@ public function providerAtDay() : array ]; } - public function testAtDayWithInvalidDay() + public function testAtDayWithInvalidDay(): void { $this->expectException(DateTimeException::class); $this->expectExceptionMessage('Invalid day-of-week: 0 is not in the range 1 to 7.'); @@ -170,7 +155,7 @@ public function testAtDayWithInvalidDay() YearWeek::of(2000, 1)->atDay(0); } - public function testCompareTo() + public function testCompareTo(): void { $years = [-3, -2, 1, 0, 1, 2, 3]; $weeks = [1, 2, 3, 50, 51, 52]; @@ -205,12 +190,7 @@ public function testCompareTo() } } - /** - * @param int $expected - * @param YearWeek $a - * @param YearWeek $b - */ - private function assertCompareTo(int $expected, YearWeek $a, YearWeek $b) + private function assertCompareTo(int $expected, YearWeek $a, YearWeek $b): void { $this->assertSame($expected, $a->compareTo($b)); $this->assertSame($expected === -1 || $expected === 0, $a->isBeforeOrEqualTo($b)); @@ -220,9 +200,6 @@ private function assertCompareTo(int $expected, YearWeek $a, YearWeek $b) $this->assertSame($expected === 1 || $expected === 0, $a->isAfterOrEqualTo($b)); } - /** - * @return array - */ public function providerWithYear() : array { return [ @@ -235,22 +212,13 @@ public function providerWithYear() : array /** * @dataProvider providerWithYear - * - * @param int $year - * @param int $week - * @param int $withYear - * @param int $expectedYear - * @param int $expectedWeek */ - public function testWithYear(int $year, int $week, int $withYear, int $expectedYear, int $expectedWeek) + public function testWithYear(int $year, int $week, int $withYear, int $expectedYear, int $expectedWeek): void { $yearWeek = YearWeek::of($year, $week)->withYear($withYear); $this->assertYearWeekIs($expectedYear, $expectedWeek, $yearWeek); } - /** - * @return array - */ public function providerWithWeek() : array { return [ @@ -262,22 +230,13 @@ public function providerWithWeek() : array /** * @dataProvider providerWithWeek - * - * @param int $year - * @param int $week - * @param int $withWeek - * @param int $expectedYear - * @param int $expectedWeek */ - public function testWithWeek(int $year, int $week, int $withWeek, int $expectedYear, int $expectedWeek) + public function testWithWeek(int $year, int $week, int $withWeek, int $expectedYear, int $expectedWeek): void { $yearWeek = YearWeek::of($year, $week)->withWeek($withWeek); $this->assertYearWeekIs($expectedYear, $expectedWeek, $yearWeek); } - /** - * @return array - */ public function providerPlusYears() : array { return [ @@ -296,14 +255,8 @@ public function providerPlusYears() : array /** * @dataProvider providerPlusYears - * - * @param int $year - * @param int $week - * @param int $delta - * @param int $expectedYear - * @param int $expectedWeek */ - public function testPlusYears(int $year, int $week, int $delta, int $expectedYear, int $expectedWeek) + public function testPlusYears(int $year, int $week, int $delta, int $expectedYear, int $expectedWeek): void { $yearWeek = YearWeek::of($year, $week)->plusYears($delta); $this->assertYearWeekIs($expectedYear, $expectedWeek, $yearWeek); @@ -311,22 +264,13 @@ public function testPlusYears(int $year, int $week, int $delta, int $expectedYea /** * @dataProvider providerPlusYears - * - * @param int $year - * @param int $week - * @param int $delta - * @param int $expectedYear - * @param int $expectedWeek */ - public function testMinusYears(int $year, int $week, int $delta, int $expectedYear, int $expectedWeek) + public function testMinusYears(int $year, int $week, int $delta, int $expectedYear, int $expectedWeek): void { $yearWeek = YearWeek::of($year, $week)->minusYears(-$delta); $this->assertYearWeekIs($expectedYear, $expectedWeek, $yearWeek); } - /** - * @return array - */ public function providerPlusWeeks() : array { return [ @@ -348,14 +292,8 @@ public function providerPlusWeeks() : array /** * @dataProvider providerPlusWeeks - * - * @param int $year - * @param int $week - * @param int $delta - * @param int $expectedYear - * @param int $expectedWeek */ - public function testPlusWeeks(int $year, int $week, int $delta, int $expectedYear, int $expectedWeek) + public function testPlusWeeks(int $year, int $week, int $delta, int $expectedYear, int $expectedWeek): void { $yearWeek = YearWeek::of($year, $week)->plusWeeks($delta); $this->assertYearWeekIs($expectedYear, $expectedWeek, $yearWeek); @@ -363,22 +301,13 @@ public function testPlusWeeks(int $year, int $week, int $delta, int $expectedYea /** * @dataProvider providerPlusWeeks - * - * @param int $year - * @param int $week - * @param int $delta - * @param int $expectedYear - * @param int $expectedWeek */ - public function testMinusWeeks(int $year, int $week, int $delta, int $expectedYear, int $expectedWeek) + public function testMinusWeeks(int $year, int $week, int $delta, int $expectedYear, int $expectedWeek): void { $yearWeek = YearWeek::of($year, $week)->minusWeeks(-$delta); $this->assertYearWeekIs($expectedYear, $expectedWeek, $yearWeek); } - /** - * @return array - */ public function providerToString() : array { return [ @@ -398,12 +327,8 @@ public function providerToString() : array /** * @dataProvider providerToString - * - * @param int $year - * @param int $week - * @param string $expected */ - public function testJsonSerialize(int $year, int $week, string $expected) + public function testJsonSerialize(int $year, int $week, string $expected): void { $yearWeek = YearWeek::of($year, $week); $this->assertSame(json_encode($expected), json_encode($yearWeek)); @@ -411,18 +336,14 @@ public function testJsonSerialize(int $year, int $week, string $expected) /** * @dataProvider providerToString - * - * @param int $year - * @param int $week - * @param string $expected */ - public function testToString(int $year, int $week, string $expected) + public function testToString(int $year, int $week, string $expected): void { $yearWeek = YearWeek::of($year, $week); $this->assertSame($expected, (string) $yearWeek); } - public function testNow() + public function testNow(): void { $now = new FixedClock(Instant::of(2000000000)); $timeZone = TimeZone::parse('Asia/Taipei'); @@ -439,7 +360,7 @@ public function testNow() * @param string $firstDay The expected first day of the week. * @param string $lastDay The expected last day of the week. */ - public function testGetFirstLastDay(int $year, int $week, string $firstDay, string $lastDay) + public function testGetFirstLastDay(int $year, int $week, string $firstDay, string $lastDay): void { $yearWeek = YearWeek::of($year, $week); @@ -447,9 +368,6 @@ public function testGetFirstLastDay(int $year, int $week, string $firstDay, stri $this->assertIs(LocalDate::class, $lastDay, $yearWeek->getLastDay()); } - /** - * @return array - */ public function providerGetFirstLastDay() : array { return [ diff --git a/tests/ZonedDateTimeTest.php b/tests/ZonedDateTimeTest.php index a1f0d75..151b3b4 100644 --- a/tests/ZonedDateTimeTest.php +++ b/tests/ZonedDateTimeTest.php @@ -32,7 +32,7 @@ class ZonedDateTimeTest extends AbstractTestCase * @param int $epochSecond The expected epoch-second the result zoned date-time resolves to. * @param int $nanoOfSecond The expected nano-of-second of the result zoned date-time. */ - public function testOf(string $localDateTime, string $timeZone, string $offset, int $shift, int $epochSecond, int $nanoOfSecond) + public function testOf(string $localDateTime, string $timeZone, string $offset, int $shift, int $epochSecond, int $nanoOfSecond): void { $localDateTime = LocalDateTime::parse($localDateTime); $timeZone = TimeZone::parse($timeZone); @@ -52,9 +52,6 @@ public function testOf(string $localDateTime, string $timeZone, string $offset, $this->assertSame($nanoOfSecond, $zonedDateTime->getNano()); } - /** - * @return array - */ public function providerOf() : array { return [ @@ -324,11 +321,8 @@ public function providerOf() : array /** * @dataProvider providerOfInstant - * - * @param string $formattedDatetime - * @param string $timeZone */ - public function testOfInstant(string $formattedDatetime, string $timeZone) + public function testOfInstant(string $formattedDatetime, string $timeZone): void { $instant = Instant::of(1000000000); $zonedDateTime = ZonedDateTime::ofInstant($instant, TimeZone::parse($timeZone)); @@ -337,9 +331,6 @@ public function testOfInstant(string $formattedDatetime, string $timeZone) $this->assertSame($formattedDatetime, (string) $zonedDateTime->getDateTime()); } - /** - * @return array - */ public function providerOfInstant() : array { return [ @@ -357,7 +348,7 @@ public function providerOfInstant() : array * @param string $offset The expected time-zone offset. * @param string $zone The expected time-zone, should be the same as offset when no region is specified. */ - public function testParse(string $text, string $date, string $time, string $offset, string $zone) + public function testParse(string $text, string $date, string $time, string $offset, string $zone): void { $zonedDateTime = ZonedDateTime::parse($text); @@ -367,9 +358,6 @@ public function testParse(string $text, string $date, string $time, string $offs $this->assertSame($zone, (string) $zonedDateTime->getTimeZone()); } - /** - * @return array - */ public function providerParse() : array { return [ @@ -388,18 +376,13 @@ public function providerParse() : array /** * @dataProvider providerParseInvalidStringThrowsException - * - * @param string $text */ - public function testParseInvalidStringThrowsException(string $text) + public function testParseInvalidStringThrowsException(string $text): void { $this->expectException(DateTimeParseException::class); ZonedDateTime::parse($text); } - /** - * @return array - */ public function providerParseInvalidStringThrowsException() : array { return [ @@ -428,20 +411,13 @@ public function providerParseInvalidStringThrowsException() : array /** * @dataProvider providerFromDateTime - * - * @param string $dateTimeString - * @param string $timeZone - * @param string $expected */ - public function testFromDateTime(string $dateTimeString, string $timeZone, string $expected) + public function testFromDateTime(string $dateTimeString, string $timeZone, string $expected): void { $dateTime = new \DateTime($dateTimeString, new \DateTimeZone($timeZone)); $this->assertIs(ZonedDateTime::class, $expected, ZonedDateTime::fromDateTime($dateTime)); } - /** - * @return array - */ public function providerFromDateTime() : array { return [ @@ -451,7 +427,7 @@ public function providerFromDateTime() : array ]; } - public function testChangeTimeZone() + public function testChangeTimeZone(): void { $timezone1 = TimeZone::parse('UTC'); $timezone2 = TimeZone::parse('America/Los_Angeles'); @@ -477,7 +453,7 @@ public function testChangeTimeZone() * @param string $z2 The second zoned date-time. * @param int $cmp The comparison value. */ - public function testCompareTo(string $z1, string $z2, int $cmp) + public function testCompareTo(string $z1, string $z2, int $cmp): void { $z1 = ZonedDateTime::parse($z1); $z2 = ZonedDateTime::parse($z2); @@ -497,9 +473,6 @@ public function testCompareTo(string $z1, string $z2, int $cmp) $this->assertSame($cmp <= 0, $z2->isAfterOrEqualTo($z1)); } - /** - * @return array - */ public function providerCompareTo() : array { return [ @@ -515,9 +488,6 @@ public function providerCompareTo() : array ]; } - /** - * @return ZonedDateTime - */ private function getTestZonedDateTime() : ZonedDateTime { $timeZone = TimeZone::parse('America/Los_Angeles'); @@ -526,191 +496,191 @@ private function getTestZonedDateTime() : ZonedDateTime return ZonedDateTime::of($localDateTime, $timeZone); } - public function testGetYear() + public function testGetYear(): void { $this->assertSame(2000, $this->getTestZonedDateTime()->getYear()); } - public function testGetMonth() + public function testGetMonth(): void { $this->assertSame(1, $this->getTestZonedDateTime()->getMonth()); } - public function testGetDay() + public function testGetDay(): void { $this->assertSame(20, $this->getTestZonedDateTime()->getDay()); } - public function testGetDayOfWeek() + public function testGetDayOfWeek(): void { $this->assertDayOfWeekIs(DayOfWeek::THURSDAY, $this->getTestZonedDateTime()->getDayOfWeek()); } - public function testGetDayOfYear() + public function testGetDayOfYear(): void { $this->assertSame(20, $this->getTestZonedDateTime()->getDayOfYear()); } - public function testGetHour() + public function testGetHour(): void { $this->assertSame(12, $this->getTestZonedDateTime()->getHour()); } - public function testGetMinute() + public function testGetMinute(): void { $this->assertSame(34, $this->getTestZonedDateTime()->getMinute()); } - public function testGetSecond() + public function testGetSecond(): void { $this->assertSame(56, $this->getTestZonedDateTime()->getSecond()); } - public function testWithDate() + public function testWithDate(): void { $newDate = LocalDate::of(2000, 1, 22); $this->assertIs(ZonedDateTime::class, '2000-01-22T12:34:56.123456789-08:00[America/Los_Angeles]', $this->getTestZonedDateTime()->withDate($newDate)); } - public function testWithTime() + public function testWithTime(): void { $time = LocalTime::of(1, 2, 3, 987654321); $this->assertIs(ZonedDateTime::class, '2000-01-20T01:02:03.987654321-08:00[America/Los_Angeles]', $this->getTestZonedDateTime()->withTime($time)); } - public function testWithYear() + public function testWithYear(): void { $this->assertIs(ZonedDateTime::class, '2020-01-20T12:34:56.123456789-08:00[America/Los_Angeles]', $this->getTestZonedDateTime()->withYear(2020)); } - public function testWithMonth() + public function testWithMonth(): void { $this->assertIs(ZonedDateTime::class, '2000-07-20T12:34:56.123456789-07:00[America/Los_Angeles]', $this->getTestZonedDateTime()->withMonth(7)); } - public function testWithDay() + public function testWithDay(): void { $this->assertIs(ZonedDateTime::class, '2000-01-31T12:34:56.123456789-08:00[America/Los_Angeles]', $this->getTestZonedDateTime()->withDay(31)); } - public function testWithHour() + public function testWithHour(): void { $this->assertIs(ZonedDateTime::class, '2000-01-20T23:34:56.123456789-08:00[America/Los_Angeles]', $this->getTestZonedDateTime()->withHour(23)); } - public function testWithMinute() + public function testWithMinute(): void { $this->assertIs(ZonedDateTime::class, '2000-01-20T12:00:56.123456789-08:00[America/Los_Angeles]', $this->getTestZonedDateTime()->withMinute(0)); } - public function testWithSecond() + public function testWithSecond(): void { $this->assertIs(ZonedDateTime::class, '2000-01-20T12:34:06.123456789-08:00[America/Los_Angeles]', $this->getTestZonedDateTime()->withSecond(6)); } - public function testWithNano() + public function testWithNano(): void { $this->assertIs(ZonedDateTime::class, '2000-01-20T12:34:56.000000123-08:00[America/Los_Angeles]', $this->getTestZonedDateTime()->withNano(123)); } - public function testWithFixedOffsetTimeZone() + public function testWithFixedOffsetTimeZone(): void { $this->assertIs(ZonedDateTime::class, '2000-01-20T12:34:56.123456789-08:00', $this->getTestZonedDateTime()->withFixedOffsetTimeZone()); } - public function testPlusPeriod() + public function testPlusPeriod(): void { $this->assertIs(ZonedDateTime::class, '2000-04-06T12:34:56.123456789-07:00[America/Los_Angeles]', $this->getTestZonedDateTime()->plusPeriod(Period::ofWeeks(11))); } - public function testPlusDuration() + public function testPlusDuration(): void { $this->assertIs(ZonedDateTime::class, '2000-01-20T12:35:01.123456789-08:00[America/Los_Angeles]', $this->getTestZonedDateTime()->plusDuration(Duration::ofSeconds(5))); } - public function testPlusYears() + public function testPlusYears(): void { $this->assertIs(ZonedDateTime::class, '2002-01-20T12:34:56.123456789-08:00[America/Los_Angeles]', $this->getTestZonedDateTime()->plusYears(2)); } - public function testPlusMonths() + public function testPlusMonths(): void { $this->assertIs(ZonedDateTime::class, '2000-03-20T12:34:56.123456789-08:00[America/Los_Angeles]', $this->getTestZonedDateTime()->plusMonths(2)); } - public function testPlusWeeks() + public function testPlusWeeks(): void { $this->assertIs(ZonedDateTime::class, '2000-02-03T12:34:56.123456789-08:00[America/Los_Angeles]', $this->getTestZonedDateTime()->plusWeeks(2)); } - public function testPlusDays() + public function testPlusDays(): void { $this->assertIs(ZonedDateTime::class, '2000-01-22T12:34:56.123456789-08:00[America/Los_Angeles]', $this->getTestZonedDateTime()->plusDays(2)); } - public function testPlusHours() + public function testPlusHours(): void { $this->assertIs(ZonedDateTime::class, '2000-01-20T14:34:56.123456789-08:00[America/Los_Angeles]', $this->getTestZonedDateTime()->plusHours(2)); } - public function testPlusMinutes() + public function testPlusMinutes(): void { $this->assertIs(ZonedDateTime::class, '2000-01-20T12:36:56.123456789-08:00[America/Los_Angeles]', $this->getTestZonedDateTime()->plusMinutes(2)); } - public function testPlusSeconds() + public function testPlusSeconds(): void { $this->assertIs(ZonedDateTime::class, '2000-01-20T12:34:58.123456789-08:00[America/Los_Angeles]', $this->getTestZonedDateTime()->plusSeconds(2)); } - public function testMinusPeriod() + public function testMinusPeriod(): void { $this->assertIs(ZonedDateTime::class, '1999-11-04T12:34:56.123456789-08:00[America/Los_Angeles]', $this->getTestZonedDateTime()->minusPeriod(Period::ofWeeks(11))); } - public function testMinusDuration() + public function testMinusDuration(): void { $this->assertIs(ZonedDateTime::class, '2000-01-20T12:34:51.123456789-08:00[America/Los_Angeles]', $this->getTestZonedDateTime()->minusDuration(Duration::ofSeconds(5))); } - public function testMinusYears() + public function testMinusYears(): void { $this->assertIs(ZonedDateTime::class, '1999-01-20T12:34:56.123456789-08:00[America/Los_Angeles]', $this->getTestZonedDateTime()->minusYears(1)); } - public function testMinusMonths() + public function testMinusMonths(): void { $this->assertIs(ZonedDateTime::class, '1999-12-20T12:34:56.123456789-08:00[America/Los_Angeles]', $this->getTestZonedDateTime()->minusMonths(1)); } - public function testMinusWeeks() + public function testMinusWeeks(): void { $this->assertIs(ZonedDateTime::class, '2000-01-06T12:34:56.123456789-08:00[America/Los_Angeles]', $this->getTestZonedDateTime()->minusWeeks(2)); } - public function testMinusDays() + public function testMinusDays(): void { $this->assertIs(ZonedDateTime::class, '2000-01-18T12:34:56.123456789-08:00[America/Los_Angeles]', $this->getTestZonedDateTime()->minusDays(2)); } - public function testMinusHours() + public function testMinusHours(): void { $this->assertIs(ZonedDateTime::class, '2000-01-20T10:34:56.123456789-08:00[America/Los_Angeles]', $this->getTestZonedDateTime()->minusHours(2)); } - public function testMinusMinutes() + public function testMinusMinutes(): void { $this->assertIs(ZonedDateTime::class, '2000-01-20T12:32:56.123456789-08:00[America/Los_Angeles]', $this->getTestZonedDateTime()->minusMinutes(2)); } - public function testMinusSeconds() + public function testMinusSeconds(): void { $this->assertIs(ZonedDateTime::class, '2000-01-20T12:34:54.123456789-08:00[America/Los_Angeles]', $this->getTestZonedDateTime()->minusSeconds(2)); } - public function testIsBetweenInclusive() + public function testIsBetweenInclusive(): void { $timeZone = TimeZone::parse('America/Los_Angeles'); $localDateTime = '2000-01-20T12:34:56.123456789'; @@ -729,7 +699,7 @@ public function testIsBetweenInclusive() $this->assertFalse($fromZonedDateTime->isBetweenInclusive($toZonedDateTime, $notIncluZonedDateTime)); } - public function testIsBetweenExclusive() + public function testIsBetweenExclusive(): void { $timeZone = TimeZone::parse('America/Los_Angeles'); $localDateTime = '2000-01-20T12:34:56.123456789'; @@ -751,7 +721,7 @@ public function testIsBetweenExclusive() /** * @dataProvider providerForPastFuture */ - public function testIsFuture($clockTimestamp, $zonedDateTime, $isFuture) + public function testIsFuture(int $clockTimestamp, string $zonedDateTime, bool $isFuture): void { $clock = new FixedClock(Instant::of($clockTimestamp)); $zonedDateTime = ZonedDateTime::parse($zonedDateTime); @@ -761,17 +731,14 @@ public function testIsFuture($clockTimestamp, $zonedDateTime, $isFuture) /** * @dataProvider providerForPastFuture */ - public function testIsPast($clockTimestamp, $zonedDateTime, $isFuture) + public function testIsPast(int $clockTimestamp, string $zonedDateTime, bool $isFuture): void { $clock = new FixedClock(Instant::of($clockTimestamp)); $zonedDateTime = ZonedDateTime::parse($zonedDateTime); $this->assertSame(! $isFuture, $zonedDateTime->isPast($clock)); } - /** - * @return array - */ - public function providerForPastFuture() + public function providerForPastFuture(): array { return [ [1234567890, '2009-02-14T00:31:29+01:00', false], @@ -787,7 +754,7 @@ public function providerForPastFuture() * @param string $dateTime The date-time string that will be parse()d by ZonedDateTime. * @param string $expected The expected output from the native DateTime object. */ - public function testToDateTime(string $dateTime, string $expected) + public function testToDateTime(string $dateTime, string $expected): void { $zonedDateTime = ZonedDateTime::parse($dateTime); $dateTime = $zonedDateTime->toDateTime(); @@ -802,7 +769,7 @@ public function testToDateTime(string $dateTime, string $expected) * @param string $dateTime The date-time string that will be parse()d by ZonedDateTime. * @param string $expected The expected output from the native DateTime object. */ - public function testToDateTimeImmutable(string $dateTime, string $expected) + public function testToDateTimeImmutable(string $dateTime, string $expected): void { $zonedDateTime = ZonedDateTime::parse($dateTime); $dateTime = $zonedDateTime->toDateTimeImmutable(); @@ -811,10 +778,7 @@ public function testToDateTimeImmutable(string $dateTime, string $expected) $this->assertSame($expected, $dateTime->format('Y-m-d\TH:i:s.uO')); } - /** - * @return array - */ - public function providerToDateTime() + public function providerToDateTime(): array { return [ ['2018-10-18T12:34Z', '2018-10-18T12:34:00.000000+0000'], @@ -828,7 +792,7 @@ public function providerToDateTime() ]; } - public function testJsonSerialize() + public function testJsonSerialize(): void { $timeZone = TimeZone::parse('America/Los_Angeles'); $localDateTime = '2000-01-20T12:34:56.123456789'; @@ -838,7 +802,7 @@ public function testJsonSerialize() $this->assertSame(json_encode('2000-01-20T12:34:56.123456789-08:00[America/Los_Angeles]'), json_encode($zonedDateTime)); } - public function testToString() + public function testToString(): void { $timeZone = TimeZone::parse('America/Los_Angeles'); $localDateTime = '2000-01-20T12:34:56.123456789';