diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 363fa046200..274534118f6 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -94,7 +94,7 @@ parameters: - '~^Parameter #1 \$row of method Doctrine\\DBAL\\Driver\\PgSQL\\Result\:\:mapNumericRow\(\) expects list, .* given\.$~' # Required for Psalm compatibility - - '~^Property Doctrine\\DBAL\\Tests\\Types\\BaseDateTypeTestCase\:\:\$currentTimezone \(non-empty-string\) does not accept string\.$~' + - '~^Property Doctrine\\DBAL\\Tests\\Types\\BaseDateTypeTestCase\:\:\$currentTimezone \(non-empty-string\) does not accept string\.$~' # The @throws annotations are part of a contract. Even if the default implementation doen't throw those # exceptions, the child implementations might do so. diff --git a/tests/Types/BaseDateTypeTestCase.php b/tests/Types/BaseDateTypeTestCase.php index 65ea018dd50..7eadf23a278 100644 --- a/tests/Types/BaseDateTypeTestCase.php +++ b/tests/Types/BaseDateTypeTestCase.php @@ -9,16 +9,19 @@ use Doctrine\DBAL\Types\ConversionException; use Doctrine\DBAL\Types\Type; use PHPUnit\Framework\Attributes\DataProvider; -use PHPUnit\Framework\MockObject\MockObject; +use PHPUnit\Framework\MockObject\Stub; use PHPUnit\Framework\TestCase; use stdClass; use function date_default_timezone_get; use function date_default_timezone_set; +/** @template TType of Type */ abstract class BaseDateTypeTestCase extends TestCase { - protected AbstractPlatform&MockObject $platform; + protected AbstractPlatform&Stub $platform; + + /** @var TType */ protected Type $type; /** @var non-empty-string */ @@ -26,7 +29,7 @@ abstract class BaseDateTypeTestCase extends TestCase protected function setUp(): void { - $this->platform = $this->createMock(AbstractPlatform::class); + $this->platform = self::createStub(AbstractPlatform::class); $this->currentTimezone = date_default_timezone_get(); } diff --git a/tests/Types/DateTest.php b/tests/Types/DateTest.php index 12476b05dd5..5ec160a985f 100644 --- a/tests/Types/DateTest.php +++ b/tests/Types/DateTest.php @@ -10,6 +10,7 @@ use function date_default_timezone_set; +/** @extends BaseDateTypeTestCase */ class DateTest extends BaseDateTypeTestCase { protected function setUp(): void diff --git a/tests/Types/DateTimeTest.php b/tests/Types/DateTimeTest.php index f2d13739156..7137d420c22 100644 --- a/tests/Types/DateTimeTest.php +++ b/tests/Types/DateTimeTest.php @@ -8,6 +8,7 @@ use Doctrine\DBAL\Types\ConversionException; use Doctrine\DBAL\Types\DateTimeType; +/** @extends BaseDateTypeTestCase */ class DateTimeTest extends BaseDateTypeTestCase { protected function setUp(): void diff --git a/tests/Types/DateTimeTzTest.php b/tests/Types/DateTimeTzTest.php index d6a9598a5ae..7c2d393313a 100644 --- a/tests/Types/DateTimeTzTest.php +++ b/tests/Types/DateTimeTzTest.php @@ -8,6 +8,7 @@ use Doctrine\DBAL\Types\ConversionException; use Doctrine\DBAL\Types\DateTimeTzType; +/** @extends BaseDateTypeTestCase */ class DateTimeTzTest extends BaseDateTypeTestCase { protected function setUp(): void diff --git a/tests/Types/TimeTest.php b/tests/Types/TimeTest.php index cbe8c50caaa..70b816dca76 100644 --- a/tests/Types/TimeTest.php +++ b/tests/Types/TimeTest.php @@ -8,6 +8,7 @@ use Doctrine\DBAL\Types\ConversionException; use Doctrine\DBAL\Types\TimeType; +/** @extends BaseDateTypeTestCase */ class TimeTest extends BaseDateTypeTestCase { protected function setUp(): void