From 90420ea2f5192f8cd01a2ae439af797360719651 Mon Sep 17 00:00:00 2001 From: kylekatarnls Date: Sun, 12 Nov 2023 16:19:47 +0100 Subject: [PATCH] Fix tests --- .github/workflows/tests.yml | 4 ---- phpstan.neon | 1 + src/Carbon/CarbonInterface.php | 2 ++ src/Carbon/CarbonPeriod.php | 2 ++ tests/CarbonInterval/FromStringTest.php | 2 +- tests/CarbonPeriod/MacroTest.php | 6 ++---- 6 files changed, 8 insertions(+), 9 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index eb6cb45cd8..7e405a0a2c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -40,10 +40,6 @@ jobs: - php: 8.1 setup: lowest - - php: 8.1 - laravel: true - reference: 9.x - - php: 8.2 - php: 8.2 setup: lowest diff --git a/phpstan.neon b/phpstan.neon index 26f67eed28..148482f1f7 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -26,6 +26,7 @@ parameters: - '#should return (\S*)(static|\$this)\(Carbon\\Carbon\)(\|null)? but returns Carbon\\Carbon(Interface)?(\|null)?\.$#' - '#should return (\S*)(static|\$this)\(Carbon\\CarbonImmutable\)(\|null)? but returns Carbon\\Carbon(Immutable|Interface)(\|null)?\.$#' - '#should return (\S*)\$this\(Carbon\\CarbonInterval\)(\|null)? but returns static\(Carbon\\CarbonInterval\)(\|null)?\.$#' + - '#should return (\S*)static\(Carbon\\CarbonInterval\)(\|null)? but returns Carbon\\CarbonInterval(\|null)?\.$#' - '#^PHPDoc tag @return with type Carbon\\CarbonTimeZone is not subtype of native type static\(Carbon\\CarbonTimeZone\)\.$#' - '#^PHPDoc tag @mixin contains invalid type Carbon\\Traits\\DeprecatedProperties\.$#' - '#^Access to an undefined property DatePeriod::\$include_end_date\.$#' diff --git a/src/Carbon/CarbonInterface.php b/src/Carbon/CarbonInterface.php index 08acf73a40..9023d97dee 100644 --- a/src/Carbon/CarbonInterface.php +++ b/src/Carbon/CarbonInterface.php @@ -516,6 +516,8 @@ * @method string longRelativeToOtherDiffForHumans(DateTimeInterface $other = null, int $parts = 1) Get the difference (long format, 'RelativeToOther' mode) in a human readable format in the current locale. ($other and $parts parameters can be swapped.) * * + * + * @codeCoverageIgnore */ interface CarbonInterface extends DateTimeInterface, JsonSerializable { diff --git a/src/Carbon/CarbonPeriod.php b/src/Carbon/CarbonPeriod.php index 8d8ed62153..c59f9bb6eb 100644 --- a/src/Carbon/CarbonPeriod.php +++ b/src/Carbon/CarbonPeriod.php @@ -42,9 +42,11 @@ use RuntimeException; use Throwable; +// @codeCoverageIgnoreStart require PHP_VERSION < 8.2 ? __DIR__.'/../../lazy/Carbon/ProtectedDatePeriod.php' : __DIR__.'/../../lazy/Carbon/UnprotectedDatePeriod.php'; +// @codeCoverageIgnoreEnd /** * Substitution of DatePeriod with some modifications and many more features. diff --git a/tests/CarbonInterval/FromStringTest.php b/tests/CarbonInterval/FromStringTest.php index 2f909d1599..53aaee5033 100644 --- a/tests/CarbonInterval/FromStringTest.php +++ b/tests/CarbonInterval/FromStringTest.php @@ -109,7 +109,7 @@ public static function dataForValidStrings(): Generator // big numbers yield ['1999999999999.5 hours', new CarbonInterval(0, 0, 0, 0, 1999999999999, 30, 0)]; yield [(0x7fffffffffffffff).' days', new CarbonInterval(0, 0, 0, 0x7fffffffffffffff, 0, 0, 0)]; - yield ['1999999999999.5 hours -85 minutes', new CarbonInterval(0, 0, 0, 0, 1999999999999, 115, 0)]; + yield ['1999999999999.5 hours -85 minutes', new CarbonInterval(0, 0, 0, 0, 1999999999999, -55, 0)]; yield ['2.333 seconds', new CarbonInterval(0, 0, 0, 0, 0, 0, 2, 333000)]; } diff --git a/tests/CarbonPeriod/MacroTest.php b/tests/CarbonPeriod/MacroTest.php index 740cceca6b..7ec72cde38 100644 --- a/tests/CarbonPeriod/MacroTest.php +++ b/tests/CarbonPeriod/MacroTest.php @@ -27,10 +27,8 @@ class MacroTest extends AbstractTestCase { protected function tearDown(): void { - $reflection = new ReflectionClass(static::$periodClass); - - $reflection->getProperty('macros') - ->setValue([]); + (new ReflectionClass(static::$periodClass)) + ->setStaticPropertyValue('macros', []); parent::tearDown(); }