From 8188b8610ea8f9d17e48249ff8b815e7736f62ec Mon Sep 17 00:00:00 2001
From: Wouter Wolters <typo3@wouterwolters.nl>
Date: Thu, 12 Aug 2021 17:31:16 +0200
Subject: [PATCH] [TASK] Strictify UnitTests part 1
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The following core extensions are handled:

* EXT:scheduler
* EXT:seo
* EXT:setup
* EXT:t3editor
* EXT:workspaces

Resolves: #94850
Releases: master
Change-Id: Ia3e7138a2c4babbcf4428a9a3e5d64de81262687
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/70503
Tested-by: core-ci <typo3@b13.com>
Tested-by: Marcin SÄ…gol <marcin@soee.pl>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Marcin SÄ…gol <marcin@soee.pl>
Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
---
 .../NormalizeCommandAccessibleProxy.php       | 20 +++---
 .../Unit/CronCommand/CronCommandTest.php      | 34 +++++-----
 .../Unit/CronCommand/NormalizeCommandTest.php | 68 +++++++++----------
 .../CachingFrameworkGarbageCollectionTest.php | 13 ++--
 .../Unit/HrefLang/HrefLangGeneratorTest.php   | 16 ++---
 .../MetaTag/OpenGraphMetaTagManagerTest.php   | 12 ++--
 .../MetaTag/TwitterCardMetaTagManagerTest.php | 12 ++--
 .../PagesXmlSitemapDataProviderTest.php       | 10 +--
 .../Controller/SetupModuleControllerTest.php  | 12 ++--
 .../Tests/Unit/Registry/AddonRegistryTest.php |  8 +--
 .../Tests/Unit/Registry/ModeRegistryTest.php  |  5 +-
 .../Controller/Remote/RemoteServerTest.php    | 18 ++---
 12 files changed, 108 insertions(+), 120 deletions(-)

diff --git a/typo3/sysext/scheduler/Tests/Unit/CronCommand/AccessibleProxies/NormalizeCommandAccessibleProxy.php b/typo3/sysext/scheduler/Tests/Unit/CronCommand/AccessibleProxies/NormalizeCommandAccessibleProxy.php
index 6baa123938e0..e91028e19f63 100644
--- a/typo3/sysext/scheduler/Tests/Unit/CronCommand/AccessibleProxies/NormalizeCommandAccessibleProxy.php
+++ b/typo3/sysext/scheduler/Tests/Unit/CronCommand/AccessibleProxies/NormalizeCommandAccessibleProxy.php
@@ -24,52 +24,52 @@ use TYPO3\CMS\Scheduler\CronCommand\NormalizeCommand;
  */
 class NormalizeCommandAccessibleProxy extends NormalizeCommand
 {
-    public static function convertKeywordsToCronCommand($cronCommand)
+    public static function convertKeywordsToCronCommand($cronCommand): string
     {
         return parent::convertKeywordsToCronCommand($cronCommand);
     }
 
-    public static function normalizeFields($cronCommand)
+    public static function normalizeFields($cronCommand): string
     {
         return parent::normalizeFields($cronCommand);
     }
 
-    public static function normalizeMonthAndWeekdayField($expression, $isMonthField = true)
+    public static function normalizeMonthAndWeekdayField($expression, $isMonthField = true): string
     {
         return parent::normalizeMonthAndWeekdayField($expression, $isMonthField);
     }
 
-    public static function normalizeIntegerField($expression, $lowerBound = 0, $upperBound = 59)
+    public static function normalizeIntegerField($expression, $lowerBound = 0, $upperBound = 59): string
     {
         return parent::normalizeIntegerField($expression, $lowerBound, $upperBound);
     }
 
-    public static function splitFields($cronCommand)
+    public static function splitFields($cronCommand): array
     {
         return parent::splitFields($cronCommand);
     }
 
-    public static function convertRangeToListOfValues($range)
+    public static function convertRangeToListOfValues($range): string
     {
         return parent::convertRangeToListOfValues($range);
     }
 
-    public static function reduceListOfValuesByStepValue($stepExpression)
+    public static function reduceListOfValuesByStepValue($stepExpression): string
     {
         return parent::reduceListOfValuesByStepValue($stepExpression);
     }
 
-    public static function normalizeMonthAndWeekday($expression, $isMonth = true)
+    public static function normalizeMonthAndWeekday($expression, $isMonth = true): string
     {
         return parent::normalizeMonthAndWeekday($expression, $isMonth);
     }
 
-    public static function normalizeMonth($month)
+    public static function normalizeMonth($month): int
     {
         return parent::normalizeMonth($month);
     }
 
-    public static function normalizeWeekday($weekday)
+    public static function normalizeWeekday($weekday): int
     {
         return parent::normalizeWeekday($weekday);
     }
diff --git a/typo3/sysext/scheduler/Tests/Unit/CronCommand/CronCommandTest.php b/typo3/sysext/scheduler/Tests/Unit/CronCommand/CronCommandTest.php
index 60e1d3bb62a1..c895825920da 100644
--- a/typo3/sysext/scheduler/Tests/Unit/CronCommand/CronCommandTest.php
+++ b/typo3/sysext/scheduler/Tests/Unit/CronCommand/CronCommandTest.php
@@ -28,12 +28,12 @@ class CronCommandTest extends UnitTestCase
     /**
      * @var int timestamp of 1.1.2010 0:00 (Friday), timezone UTC/GMT
      */
-    const TIMESTAMP = 1262304000;
+    private const TIMESTAMP = 1262304000;
 
     /**
      * @var string Selected timezone backup
      */
-    protected $timezoneBackup = '';
+    protected string $timezoneBackup = '';
 
     /**
      * We're fiddling with hard timestamps in the tests, but time methods in
@@ -57,7 +57,7 @@ class CronCommandTest extends UnitTestCase
     /**
      * @test
      */
-    public function constructorSetsNormalizedCronCommandSections()
+    public function constructorSetsNormalizedCronCommandSections(): void
     {
         $instance = new CronCommand('2-3 * * * *');
         self::assertSame(['2,3', '*', '*', '*', '*'], $instance->getCronCommandSections());
@@ -66,7 +66,7 @@ class CronCommandTest extends UnitTestCase
     /**
      * @test
      */
-    public function constructorThrowsExceptionForInvalidCronCommand()
+    public function constructorThrowsExceptionForInvalidCronCommand(): void
     {
         $this->expectException(\InvalidArgumentException::class);
         $this->expectExceptionCode(1291470170);
@@ -76,7 +76,7 @@ class CronCommandTest extends UnitTestCase
     /**
      * @test
      */
-    public function constructorSetsTimestampToNowPlusOneMinuteRoundedDownToSixtySeconds()
+    public function constructorSetsTimestampToNowPlusOneMinuteRoundedDownToSixtySeconds(): void
     {
         $instance = new CronCommand('* * * * *');
         $currentTime = time();
@@ -87,7 +87,7 @@ class CronCommandTest extends UnitTestCase
     /**
      * @test
      */
-    public function constructorSetsTimestampToGivenTimestampPlusSixtySeconds()
+    public function constructorSetsTimestampToGivenTimestampPlusSixtySeconds(): void
     {
         $instance = new CronCommand('* * * * *', self::TIMESTAMP);
         self::assertSame(self::TIMESTAMP + 60, $instance->getTimestamp());
@@ -96,7 +96,7 @@ class CronCommandTest extends UnitTestCase
     /**
      * @test
      */
-    public function constructorSetsTimestampToGiveTimestampRoundedDownToSixtySeconds()
+    public function constructorSetsTimestampToGiveTimestampRoundedDownToSixtySeconds(): void
     {
         $instance = new CronCommand('* * * * *', self::TIMESTAMP + 1);
         self::assertSame(self::TIMESTAMP + 60, $instance->getTimestamp());
@@ -105,7 +105,7 @@ class CronCommandTest extends UnitTestCase
     /**
      * @return array
      */
-    public static function expectedTimestampDataProvider()
+    public static function expectedTimestampDataProvider(): array
     {
         return [
             'every minute' => [
@@ -186,7 +186,7 @@ class CronCommandTest extends UnitTestCase
     /**
      * @return array
      */
-    public static function expectedCalculatedTimestampDataProvider()
+    public static function expectedCalculatedTimestampDataProvider(): array
     {
         return [
             'every first day of month' => [
@@ -247,7 +247,7 @@ class CronCommandTest extends UnitTestCase
      * @param int $startTimestamp Timestamp for start of calculation
      * @param int $expectedTimestamp Expected result (next time of execution)
      */
-    public function calculateNextValueDeterminesCorrectNextTimestamp($cronCommand, $startTimestamp, $expectedTimestamp)
+    public function calculateNextValueDeterminesCorrectNextTimestamp(string $cronCommand, int $startTimestamp, int $expectedTimestamp): void
     {
         $instance = new CronCommand($cronCommand, $startTimestamp);
         $instance->calculateNextValue();
@@ -261,7 +261,7 @@ class CronCommandTest extends UnitTestCase
      * @param int $startTimestamp Timestamp for start of calculation
      * @param string $expectedTimestamp Expected result (next time of execution), to be fed to strtotime
      */
-    public function calculateNextValueDeterminesCorrectNextCalculatedTimestamp($cronCommand, $startTimestamp, $expectedTimestamp)
+    public function calculateNextValueDeterminesCorrectNextCalculatedTimestamp(string $cronCommand, int $startTimestamp, string $expectedTimestamp): void
     {
         $instance = new CronCommand($cronCommand, $startTimestamp);
         $instance->calculateNextValue();
@@ -276,7 +276,7 @@ class CronCommandTest extends UnitTestCase
      * @param int $firstTimestamp Timestamp of the next execution
      * @param int $secondTimestamp Timestamp of the further execution
      */
-    public function calculateNextValueDeterminesCorrectNextTimestampOnConsecutiveCall($cronCommand, $startTimestamp, $firstTimestamp, $secondTimestamp)
+    public function calculateNextValueDeterminesCorrectNextTimestampOnConsecutiveCall(string $cronCommand, int $startTimestamp, int $firstTimestamp, int $secondTimestamp): void
     {
         $instance = new CronCommand($cronCommand, $firstTimestamp);
         $instance->calculateNextValue();
@@ -291,7 +291,7 @@ class CronCommandTest extends UnitTestCase
      * @param string $firstTimestamp Timestamp of the next execution, to be fed to strtotime
      * @param string $secondTimestamp Timestamp of the further execution, to be fed to strtotime
      */
-    public function calculateNextValueDeterminesCorrectNextCalculatedTimestampOnConsecutiveCall($cronCommand, $startTimestamp, $firstTimestamp, $secondTimestamp)
+    public function calculateNextValueDeterminesCorrectNextCalculatedTimestampOnConsecutiveCall(string $cronCommand, int $startTimestamp, string $firstTimestamp, string $secondTimestamp): void
     {
         $instance = new CronCommand($cronCommand, strtotime($firstTimestamp));
         $instance->calculateNextValue();
@@ -301,7 +301,7 @@ class CronCommandTest extends UnitTestCase
     /**
      * @test
      */
-    public function calculateNextValueDeterminesCorrectNextTimestampOnChangeToSummertime()
+    public function calculateNextValueDeterminesCorrectNextTimestampOnChangeToSummertime(): void
     {
         $backupTimezone = date_default_timezone_get();
         date_default_timezone_set('Europe/Berlin');
@@ -314,7 +314,7 @@ class CronCommandTest extends UnitTestCase
     /**
      * @test
      */
-    public function calculateNextValueThrowsExceptionWithImpossibleCronCommand()
+    public function calculateNextValueThrowsExceptionWithImpossibleCronCommand(): void
     {
         $this->expectException(\RuntimeException::class);
         $this->expectExceptionCode(1291501280);
@@ -325,7 +325,7 @@ class CronCommandTest extends UnitTestCase
     /**
      * @test
      */
-    public function getTimestampReturnsInteger()
+    public function getTimestampReturnsInteger(): void
     {
         $instance = new CronCommand('* * * * *');
         self::assertIsInt($instance->getTimestamp());
@@ -334,7 +334,7 @@ class CronCommandTest extends UnitTestCase
     /**
      * @test
      */
-    public function getCronCommandSectionsReturnsArray()
+    public function getCronCommandSectionsReturnsArray(): void
     {
         $instance = new CronCommand('* * * * *');
         self::assertIsArray($instance->getCronCommandSections());
diff --git a/typo3/sysext/scheduler/Tests/Unit/CronCommand/NormalizeCommandTest.php b/typo3/sysext/scheduler/Tests/Unit/CronCommand/NormalizeCommandTest.php
index bd58435da745..8ca511283fd1 100644
--- a/typo3/sysext/scheduler/Tests/Unit/CronCommand/NormalizeCommandTest.php
+++ b/typo3/sysext/scheduler/Tests/Unit/CronCommand/NormalizeCommandTest.php
@@ -67,7 +67,7 @@ class NormalizeCommandTest extends UnitTestCase
      * @param string $expression Cron command to test
      * @param string $expected Expected result (normalized cron command syntax)
      */
-    public function normalizeConvertsCronCommand($expression, $expected): void
+    public function normalizeConvertsCronCommand(string $expression, string $expected): void
     {
         $result = NormalizeCommand::normalize($expression);
         self::assertEquals($expected, $result);
@@ -95,7 +95,7 @@ class NormalizeCommandTest extends UnitTestCase
      * @param string $keyword Cron command keyword
      * @param string $expectedCronCommand Expected result (normalized cron command syntax)
      */
-    public function convertKeywordsToCronCommandConvertsValidKeywords($keyword, $expectedCronCommand): void
+    public function convertKeywordsToCronCommandConvertsValidKeywords(string $keyword, string $expectedCronCommand): void
     {
         $result = NormalizeCommandAccessibleProxy::convertKeywordsToCronCommand($keyword);
         self::assertEquals($expectedCronCommand, $result);
@@ -131,7 +131,7 @@ class NormalizeCommandTest extends UnitTestCase
      * @param string $expression Cron command to normalize
      * @param string $expected Expected result (normalized cron command syntax)
      */
-    public function normalizeFieldsConvertsField($expression, $expected): void
+    public function normalizeFieldsConvertsField(string $expression, string $expected): void
     {
         $result = NormalizeCommandAccessibleProxy::normalizeFields($expression);
         self::assertEquals($expected, $result);
@@ -173,9 +173,9 @@ class NormalizeCommandTest extends UnitTestCase
      * @param string $expected Expected result (normalized months or weekdays)
      */
     public function normalizeMonthAndWeekdayFieldReturnsNormalizedListForValidExpression(
-        $expression,
-        $isMonthField,
-        $expected
+        string $expression,
+        bool $isMonthField,
+        string $expected
     ): void {
         $result = NormalizeCommandAccessibleProxy::normalizeMonthAndWeekdayField($expression, $isMonthField);
         self::assertSame($expected, $result);
@@ -204,9 +204,9 @@ class NormalizeCommandTest extends UnitTestCase
      * @param int $expectedExceptionCode Expected exception code from provider
      */
     public function normalizeMonthAndWeekdayFieldThrowsExceptionForInvalidExpression(
-        $expression,
-        $isMonthField,
-        $expectedExceptionCode
+        string $expression,
+        bool $isMonthField,
+        int $expectedExceptionCode
     ): void {
         $this->expectException(\InvalidArgumentException::class);
         $this->expectExceptionCode($expectedExceptionCode);
@@ -238,10 +238,10 @@ class NormalizeCommandTest extends UnitTestCase
     /**
      * @test
      * @dataProvider normalizeIntegerFieldValidDataProvider
-     * @param string $expression Cron command partial integer expression
+     * @param string|int $expression Cron command partial integer expression
      * @param string $expected Expected result (normalized integer or integer list)
      */
-    public function normalizeIntegerFieldReturnsNormalizedListForValidExpression($expression, $expected): void
+    public function normalizeIntegerFieldReturnsNormalizedListForValidExpression($expression, string $expected): void
     {
         $result = NormalizeCommandAccessibleProxy::normalizeIntegerField($expression);
         self::assertSame($expected, $result);
@@ -275,10 +275,10 @@ class NormalizeCommandTest extends UnitTestCase
      * @param int $expectedExceptionCode Expected exception code
      */
     public function normalizeIntegerFieldThrowsExceptionForInvalidExpressions(
-        $expression,
-        $lowerBound,
-        $upperBound,
-        $expectedExceptionCode
+        string $expression,
+        int $lowerBound,
+        int $upperBound,
+        int $expectedExceptionCode
     ): void {
         $this->expectException(\InvalidArgumentException::class);
         $this->expectExceptionCode($expectedExceptionCode);
@@ -319,7 +319,7 @@ class NormalizeCommandTest extends UnitTestCase
     /**
      * @test
      * @dataProvider invalidCronCommandFieldsDataProvider
-     * @param string $cronCommand Invalid cron command
+     * @param string|int $cronCommand Invalid cron command
      */
     public function splitFieldsThrowsExceptionIfCronCommandDoesNotContainFiveFields($cronCommand): void
     {
@@ -346,10 +346,10 @@ class NormalizeCommandTest extends UnitTestCase
     /**
      * @test
      * @dataProvider validRangeDataProvider
-     * @param string $range Cron command range expression
+     * @param string|int $range Cron command range expression
      * @param string $expected Expected result (normalized range)
      */
-    public function convertRangeToListOfValuesReturnsCorrectListForValidRanges($range, $expected): void
+    public function convertRangeToListOfValuesReturnsCorrectListForValidRanges($range, string $expected): void
     {
         $result = NormalizeCommandAccessibleProxy::convertRangeToListOfValues($range);
         self::assertSame($expected, $result);
@@ -380,7 +380,7 @@ class NormalizeCommandTest extends UnitTestCase
      * @param string $range Cron command range expression (invalid)
      * @param int $expectedExceptionCode Expected exception code from provider
      */
-    public function convertRangeToListOfValuesThrowsExceptionForInvalidRanges($range, $expectedExceptionCode): void
+    public function convertRangeToListOfValuesThrowsExceptionForInvalidRanges(string $range, int $expectedExceptionCode): void
     {
         $this->expectException(\InvalidArgumentException::class);
         $this->expectExceptionCode($expectedExceptionCode);
@@ -406,7 +406,7 @@ class NormalizeCommandTest extends UnitTestCase
      * @param string $stepExpression Cron command step expression
      * @param string $expected Expected result (normalized range)
      */
-    public function reduceListOfValuesByStepValueReturnsCorrectListOfValues($stepExpression, $expected): void
+    public function reduceListOfValuesByStepValueReturnsCorrectListOfValues(string $stepExpression, string $expected): void
     {
         $result = NormalizeCommandAccessibleProxy::reduceListOfValuesByStepValue($stepExpression);
         self::assertSame($expected, $result);
@@ -437,8 +437,8 @@ class NormalizeCommandTest extends UnitTestCase
      * @param int $expectedExceptionCode Expected exception code
      */
     public function reduceListOfValuesByStepValueThrowsExceptionForInvalidStepExpressions(
-        $stepExpression,
-        $expectedExceptionCode
+        string $stepExpression,
+        int $expectedExceptionCode
     ): void {
         $this->expectException(\InvalidArgumentException::class);
         $this->expectExceptionCode($expectedExceptionCode);
@@ -501,10 +501,10 @@ class NormalizeCommandTest extends UnitTestCase
     /**
      * @test
      * @dataProvider validMonthNamesDataProvider
-     * @param string $monthName Month name
+     * @param string|int $monthName Month name
      * @param int $expectedInteger Number of the month
      */
-    public function normalizeMonthConvertsName($monthName, $expectedInteger): void
+    public function normalizeMonthConvertsName($monthName, int $expectedInteger): void
     {
         $result = NormalizeCommandAccessibleProxy::normalizeMonth($monthName);
         self::assertEquals($expectedInteger, $result);
@@ -513,10 +513,9 @@ class NormalizeCommandTest extends UnitTestCase
     /**
      * @test
      * @dataProvider validMonthNamesDataProvider
-     * @param string $monthName Month name
-     * @param int $expectedInteger Number of the month (not used)
+     * @param string|int $monthName Month name
      */
-    public function normalizeMonthReturnsInteger($monthName, $expectedInteger): void
+    public function normalizeMonthReturnsInteger($monthName): void
     {
         $result = NormalizeCommandAccessibleProxy::normalizeMonth($monthName);
         self::assertIsInt($result);
@@ -553,12 +552,12 @@ class NormalizeCommandTest extends UnitTestCase
     /**
      * @test
      * @dataProvider invalidMonthNamesDataProvider
-     * @param string $invalidMonthName Month name (invalid)
+     * @param string|int $invalidMonthName Month name (invalid)
      * @param int $expectedExceptionCode Expected exception code
      */
     public function normalizeMonthThrowsExceptionForInvalidMonthRepresentation(
         $invalidMonthName,
-        $expectedExceptionCode
+        int $expectedExceptionCode
     ): void {
         $this->expectException(\InvalidArgumentException::class);
         $this->expectExceptionCode($expectedExceptionCode);
@@ -604,10 +603,10 @@ class NormalizeCommandTest extends UnitTestCase
     /**
      * @test
      * @dataProvider validWeekdayDataProvider
-     * @param string $weekday Weekday expression
+     * @param string|int $weekday Weekday expression
      * @param int $expectedInteger Number of weekday
      */
-    public function normalizeWeekdayConvertsName($weekday, $expectedInteger): void
+    public function normalizeWeekdayConvertsName($weekday, int $expectedInteger): void
     {
         $result = NormalizeCommandAccessibleProxy::normalizeWeekday($weekday);
         self::assertEquals($expectedInteger, $result);
@@ -616,10 +615,9 @@ class NormalizeCommandTest extends UnitTestCase
     /**
      * @test
      * @dataProvider validWeekdayDataProvider
-     * @param string $weekday Weekday expression
-     * @param int $expectedInteger Number of weekday (not used)
+     * @param string|int $weekday Weekday expression
      */
-    public function normalizeWeekdayReturnsInteger($weekday, $expectedInteger): void
+    public function normalizeWeekdayReturnsInteger($weekday): void
     {
         $result = NormalizeCommandAccessibleProxy::normalizeWeekday($weekday);
         self::assertIsInt($result);
@@ -654,7 +652,7 @@ class NormalizeCommandTest extends UnitTestCase
     /**
      * @test
      * @dataProvider invalidWeekdayDataProvider
-     * @param string $weekday Weekday expression (invalid)
+     * @param string|int $weekday Weekday expression (invalid)
      */
     public function normalizeWeekdayThrowsExceptionForInvalidWeekdayRepresentation($weekday): void
     {
diff --git a/typo3/sysext/scheduler/Tests/Unit/Task/CachingFrameworkGarbageCollectionTest.php b/typo3/sysext/scheduler/Tests/Unit/Task/CachingFrameworkGarbageCollectionTest.php
index b29b1d45fd66..d501b6b5dc1f 100644
--- a/typo3/sysext/scheduler/Tests/Unit/Task/CachingFrameworkGarbageCollectionTest.php
+++ b/typo3/sysext/scheduler/Tests/Unit/Task/CachingFrameworkGarbageCollectionTest.php
@@ -17,6 +17,7 @@ declare(strict_types=1);
 
 namespace TYPO3\CMS\Scheduler\Tests\Unit\Task;
 
+use PHPUnit\Framework\MockObject\MockObject;
 use TYPO3\CMS\Core\Cache\Backend\AbstractBackend;
 use TYPO3\CMS\Core\Cache\Backend\NullBackend;
 use TYPO3\CMS\Core\Cache\CacheManager;
@@ -38,10 +39,10 @@ class CachingFrameworkGarbageCollectionTest extends UnitTestCase
     /**
      * @test
      */
-    public function executeCallsCollectGarbageOfConfiguredBackend()
+    public function executeCallsCollectGarbageOfConfiguredBackend(): void
     {
         $cache = $this->createMock(VariableFrontend::class);
-        $cache->expects(self::any())->method('getIdentifier')->willReturn('cache');
+        $cache->method('getIdentifier')->willReturn('cache');
         $cache->expects(self::atLeastOnce())->method('collectGarbage');
         $mockCacheManager = new CacheManager();
         $mockCacheManager->registerCache($cache);
@@ -52,7 +53,7 @@ class CachingFrameworkGarbageCollectionTest extends UnitTestCase
                 'backend' => AbstractBackend::class,
             ]
         ];
-        /** @var \TYPO3\CMS\Scheduler\Task\CachingFrameworkGarbageCollectionTask|\PHPUnit\Framework\MockObject\MockObject $subject */
+        /** @var CachingFrameworkGarbageCollectionTask|MockObject $subject */
         $subject = $this->getMockBuilder(CachingFrameworkGarbageCollectionTask::class)
             ->addMethods(['dummy'])
             ->disableOriginalConstructor()
@@ -64,10 +65,10 @@ class CachingFrameworkGarbageCollectionTest extends UnitTestCase
     /**
      * @test
      */
-    public function executeDoesNotCallCollectGarbageOfNotConfiguredBackend()
+    public function executeDoesNotCallCollectGarbageOfNotConfiguredBackend(): void
     {
         $cache = $this->createMock(VariableFrontend::class);
-        $cache->expects(self::any())->method('getIdentifier')->willReturn('cache');
+        $cache->method('getIdentifier')->willReturn('cache');
         $cache->expects(self::never())->method('collectGarbage');
         $mockCacheManager = new CacheManager();
         $mockCacheManager->registerCache($cache);
@@ -78,7 +79,7 @@ class CachingFrameworkGarbageCollectionTest extends UnitTestCase
                 'backend' => AbstractBackend::class,
             ]
         ];
-        /** @var \TYPO3\CMS\Scheduler\Task\CachingFrameworkGarbageCollectionTask|\PHPUnit\Framework\MockObject\MockObject $subject */
+        /** @var CachingFrameworkGarbageCollectionTask|MockObject $subject */
         $subject = $this->getMockBuilder(CachingFrameworkGarbageCollectionTask::class)
             ->addMethods(['dummy'])
             ->disableOriginalConstructor()
diff --git a/typo3/sysext/seo/Tests/Unit/HrefLang/HrefLangGeneratorTest.php b/typo3/sysext/seo/Tests/Unit/HrefLang/HrefLangGeneratorTest.php
index 576f46c53b64..009edb992739 100644
--- a/typo3/sysext/seo/Tests/Unit/HrefLang/HrefLangGeneratorTest.php
+++ b/typo3/sysext/seo/Tests/Unit/HrefLang/HrefLangGeneratorTest.php
@@ -17,6 +17,7 @@ declare(strict_types=1);
 
 namespace TYPO3\CMS\Seo\Tests\Unit\HrefLang;
 
+use Prophecy\PhpUnit\ProphecyTrait;
 use Psr\Http\Message\UriInterface;
 use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
 use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
@@ -29,16 +30,16 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
  */
 class HrefLangGeneratorTest extends UnitTestCase
 {
-    use \Prophecy\PhpUnit\ProphecyTrait;
+    use ProphecyTrait;
+
     /**
      * @test
      *
      * @param string $url
-     * @param bool $shouldBeCalled
      *
      * @dataProvider urlPathDataProvider
      */
-    public function checkIfGetSiteLanguageIsCalled($url, $shouldBeCalled)
+    public function checkIfGetSiteLanguageIsCalled(string $url): void
     {
         $subject = $this->getAccessibleMock(
             HrefLangGenerator::class,
@@ -62,39 +63,30 @@ class HrefLangGeneratorTest extends UnitTestCase
         return [
             [
                 '/',
-                true
             ],
             [
                 'example.com',
-                true    //This can't be defined as a domain because it can also be a filename
             ],
             [
                 'filename.pdf',
-                true
             ],
             [
                 'example.com/filename.pdf',
-                true
             ],
             [
                 '//example.com/filename.pdf',
-                false
             ],
             [
                 '//example.com',
-                false
             ],
             [
                 'https://example.com',
-                false
             ],
             [
                 '/page-1/subpage-1',
-                true
             ],
             [
                 'https://example.com/page-1/subpage-1',
-                false
             ],
         ];
     }
diff --git a/typo3/sysext/seo/Tests/Unit/MetaTag/OpenGraphMetaTagManagerTest.php b/typo3/sysext/seo/Tests/Unit/MetaTag/OpenGraphMetaTagManagerTest.php
index fd0874ba3722..21338cb14737 100644
--- a/typo3/sysext/seo/Tests/Unit/MetaTag/OpenGraphMetaTagManagerTest.php
+++ b/typo3/sysext/seo/Tests/Unit/MetaTag/OpenGraphMetaTagManagerTest.php
@@ -28,7 +28,7 @@ class OpenGraphMetaTagManagerTest extends UnitTestCase
     /**
      * @test
      */
-    public function checkIfGetAllHandledPropertiesReturnsNonEmptyArray()
+    public function checkIfGetAllHandledPropertiesReturnsNonEmptyArray(): void
     {
         $manager = new OpenGraphMetaTagManager();
         $handledProperties = $manager->getAllHandledProperties();
@@ -41,7 +41,7 @@ class OpenGraphMetaTagManagerTest extends UnitTestCase
      *
      * @test
      */
-    public function checkIfPropertyIsStoredAfterAddingProperty($property, $expected, $expectedRenderedTag)
+    public function checkIfPropertyIsStoredAfterAddingProperty(array $property, array $expected, string $expectedRenderedTag): void
     {
         $manager = new OpenGraphMetaTagManager();
         $manager->addProperty(
@@ -57,7 +57,7 @@ class OpenGraphMetaTagManagerTest extends UnitTestCase
     /**
      * @test
      */
-    public function checkIfAddingOnlySubPropertyAndNoMainPropertyIsReturningException()
+    public function checkIfAddingOnlySubPropertyAndNoMainPropertyIsReturningException(): void
     {
         $manager = new OpenGraphMetaTagManager();
 
@@ -68,7 +68,7 @@ class OpenGraphMetaTagManagerTest extends UnitTestCase
     /**
      * @test
      */
-    public function checkRenderAllPropertiesRendersCorrectMetaTags()
+    public function checkRenderAllPropertiesRendersCorrectMetaTags(): void
     {
         $properties = [
             [
@@ -133,7 +133,7 @@ class OpenGraphMetaTagManagerTest extends UnitTestCase
     /**
      * @test
      */
-    public function checkIfRemovePropertyReallyRemovesProperty()
+    public function checkIfRemovePropertyReallyRemovesProperty(): void
     {
         $manager = new OpenGraphMetaTagManager();
         $manager->addProperty('og:title', 'Title');
@@ -154,7 +154,7 @@ class OpenGraphMetaTagManagerTest extends UnitTestCase
     /**
      * @return array
      */
-    public function propertiesProvider()
+    public function propertiesProvider(): array
     {
         return [
             [
diff --git a/typo3/sysext/seo/Tests/Unit/MetaTag/TwitterCardMetaTagManagerTest.php b/typo3/sysext/seo/Tests/Unit/MetaTag/TwitterCardMetaTagManagerTest.php
index 5768cda880f4..f2c5170d4df8 100644
--- a/typo3/sysext/seo/Tests/Unit/MetaTag/TwitterCardMetaTagManagerTest.php
+++ b/typo3/sysext/seo/Tests/Unit/MetaTag/TwitterCardMetaTagManagerTest.php
@@ -28,7 +28,7 @@ class TwitterCardMetaTagManagerTest extends UnitTestCase
     /**
      * @test
      */
-    public function checkIfGetAllHandledPropertiesReturnsNonEmptyArray()
+    public function checkIfGetAllHandledPropertiesReturnsNonEmptyArray(): void
     {
         $manager = new TwitterCardMetaTagManager();
         $handledProperties = $manager->getAllHandledProperties();
@@ -45,7 +45,7 @@ class TwitterCardMetaTagManagerTest extends UnitTestCase
      * @param array $expected
      * @param string $expectedRenderedTag
      */
-    public function checkIfPropertyIsStoredAfterAddingProperty(array $property, array $expected, string $expectedRenderedTag)
+    public function checkIfPropertyIsStoredAfterAddingProperty(array $property, array $expected, string $expectedRenderedTag): void
     {
         $manager = new TwitterCardMetaTagManager();
         $manager->addProperty(
@@ -61,7 +61,7 @@ class TwitterCardMetaTagManagerTest extends UnitTestCase
     /**
      * @return array
      */
-    public function propertiesProvider()
+    public function propertiesProvider(): array
     {
         return [
             'title is set' => [
@@ -129,7 +129,7 @@ class TwitterCardMetaTagManagerTest extends UnitTestCase
     /**
      * @test
      */
-    public function checkIfAddingOnlySubPropertyAndNoMainPropertyIsReturningException()
+    public function checkIfAddingOnlySubPropertyAndNoMainPropertyIsReturningException(): void
     {
         $manager = new TwitterCardMetaTagManager();
 
@@ -140,7 +140,7 @@ class TwitterCardMetaTagManagerTest extends UnitTestCase
     /**
      * @test
      */
-    public function checkRenderAllPropertiesRendersCorrectMetaTags()
+    public function checkRenderAllPropertiesRendersCorrectMetaTags(): void
     {
         $properties = [
             [
@@ -195,7 +195,7 @@ class TwitterCardMetaTagManagerTest extends UnitTestCase
     /**
      * @test
      */
-    public function checkIfRemovePropertyReallyRemovesProperty()
+    public function checkIfRemovePropertyReallyRemovesProperty(): void
     {
         $manager = new TwitterCardMetaTagManager();
         $manager->addProperty('twitter:title', 'Title');
diff --git a/typo3/sysext/seo/Tests/Unit/XmlSitemap/PagesXmlSitemapDataProviderTest.php b/typo3/sysext/seo/Tests/Unit/XmlSitemap/PagesXmlSitemapDataProviderTest.php
index a795d3d805df..145575da28c6 100644
--- a/typo3/sysext/seo/Tests/Unit/XmlSitemap/PagesXmlSitemapDataProviderTest.php
+++ b/typo3/sysext/seo/Tests/Unit/XmlSitemap/PagesXmlSitemapDataProviderTest.php
@@ -17,6 +17,7 @@ declare(strict_types=1);
 
 namespace TYPO3\CMS\Seo\Tests\Unit\XmlSitemap;
 
+use Prophecy\PhpUnit\ProphecyTrait;
 use Psr\Http\Message\ServerRequestInterface;
 use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
 use TYPO3\CMS\Seo\XmlSitemap\PagesXmlSitemapDataProvider;
@@ -24,13 +25,14 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 class PagesXmlSitemapDataProviderTest extends UnitTestCase
 {
-    use \Prophecy\PhpUnit\ProphecyTrait;
+    use ProphecyTrait;
+
     protected $resetSingletonInstances = true;
 
     /**
      * @var array
      */
-    protected $items;
+    protected array $items;
 
     public function setUp(): void
     {
@@ -77,7 +79,7 @@ class PagesXmlSitemapDataProviderTest extends UnitTestCase
      * @dataProvider numberOfItemsPerPageProvider
      * @test
      */
-    public function checkGetItemsReturnsDefinedItems($numberOfItemsPerPage): void
+    public function checkGetItemsReturnsDefinedItems(int $numberOfItemsPerPage): void
     {
         $key = 'dummyKey';
         $cObj = $this->prophesize(ContentObjectRenderer::class);
@@ -93,7 +95,7 @@ class PagesXmlSitemapDataProviderTest extends UnitTestCase
         $subject->_set('items', $this->items);
         $subject->_set('numberOfItemsPerPage', $numberOfItemsPerPage);
 
-        $subject->expects(self::any())->method('defineUrl')->willReturnCallback(
+        $subject->method('defineUrl')->willReturnCallback(
             function ($input) {
                 return $input;
             }
diff --git a/typo3/sysext/setup/Tests/Unit/Controller/SetupModuleControllerTest.php b/typo3/sysext/setup/Tests/Unit/Controller/SetupModuleControllerTest.php
index 5d841e3727c0..501bfa7e7c25 100644
--- a/typo3/sysext/setup/Tests/Unit/Controller/SetupModuleControllerTest.php
+++ b/typo3/sysext/setup/Tests/Unit/Controller/SetupModuleControllerTest.php
@@ -29,7 +29,7 @@ class SetupModuleControllerTest extends UnitTestCase
     /**
      * @test
      */
-    public function addFlashMessagesAddsMessagesIfSetupIsUpdated()
+    public function addFlashMessagesAddsMessagesIfSetupIsUpdated(): void
     {
         $setupModuleControllerMock = $this->getAccessibleMock(
             SetupModuleController::class,
@@ -54,7 +54,7 @@ class SetupModuleControllerTest extends UnitTestCase
     /**
      * @test
      */
-    public function addFlashMessagesAddsMessageIfSettingsAreResetToDefault()
+    public function addFlashMessagesAddsMessageIfSettingsAreResetToDefault(): void
     {
         $setupModuleControllerMock = $this->getAccessibleMock(
             SetupModuleController::class,
@@ -79,7 +79,7 @@ class SetupModuleControllerTest extends UnitTestCase
     /**
      * @test
      */
-    public function addFlashMessagesAddsMessageIfPasswordWasSuccessfullyUpdated()
+    public function addFlashMessagesAddsMessageIfPasswordWasSuccessfullyUpdated(): void
     {
         $setupModuleControllerMock = $this->getAccessibleMock(
             SetupModuleController::class,
@@ -104,7 +104,7 @@ class SetupModuleControllerTest extends UnitTestCase
     /**
      * @test
      */
-    public function addFlashMessagesAddsMessageIfOldPasswordWasWrong()
+    public function addFlashMessagesAddsMessageIfOldPasswordWasWrong(): void
     {
         $setupModuleControllerMock = $this->getAccessibleMock(
             SetupModuleController::class,
@@ -129,7 +129,7 @@ class SetupModuleControllerTest extends UnitTestCase
     /**
      * @test
      */
-    public function addFlashMessagesAddsMessageIfPasswordsNotTheSame()
+    public function addFlashMessagesAddsMessageIfPasswordsNotTheSame(): void
     {
         $setupModuleControllerMock = $this->getAccessibleMock(
             SetupModuleController::class,
@@ -154,7 +154,7 @@ class SetupModuleControllerTest extends UnitTestCase
     /**
      * @test
      */
-    public function addFlashMessagesAddsMessagesToQueue()
+    public function addFlashMessagesAddsMessagesToQueue(): void
     {
         $setupModuleControllerMock = $this->getAccessibleMock(
             SetupModuleController::class,
diff --git a/typo3/sysext/t3editor/Tests/Unit/Registry/AddonRegistryTest.php b/typo3/sysext/t3editor/Tests/Unit/Registry/AddonRegistryTest.php
index 4edfec00cd0f..f53459bd5a8e 100644
--- a/typo3/sysext/t3editor/Tests/Unit/Registry/AddonRegistryTest.php
+++ b/typo3/sysext/t3editor/Tests/Unit/Registry/AddonRegistryTest.php
@@ -27,10 +27,7 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
  */
 class AddonRegistryTest extends UnitTestCase
 {
-    /**
-     * @var AddonRegistry
-     */
-    protected $subject;
+    protected AddonRegistry $subject;
 
     protected function setUp(): void
     {
@@ -67,8 +64,7 @@ class AddonRegistryTest extends UnitTestCase
                         'foobar' => false,
                         'randomInt' => 4 // chosen by fair dice roll
                     ])
-            )
-        ;
+            );
     }
 
     /**
diff --git a/typo3/sysext/t3editor/Tests/Unit/Registry/ModeRegistryTest.php b/typo3/sysext/t3editor/Tests/Unit/Registry/ModeRegistryTest.php
index 755cfc85bb18..1e729462f22a 100644
--- a/typo3/sysext/t3editor/Tests/Unit/Registry/ModeRegistryTest.php
+++ b/typo3/sysext/t3editor/Tests/Unit/Registry/ModeRegistryTest.php
@@ -27,10 +27,7 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
  */
 class ModeRegistryTest extends UnitTestCase
 {
-    /**
-     * @var ModeRegistry
-     */
-    protected $subject;
+    protected ModeRegistry $subject;
 
     protected function setUp(): void
     {
diff --git a/typo3/sysext/workspaces/Tests/Unit/Controller/Remote/RemoteServerTest.php b/typo3/sysext/workspaces/Tests/Unit/Controller/Remote/RemoteServerTest.php
index 77a4f233fbaa..eaee3aa96db8 100644
--- a/typo3/sysext/workspaces/Tests/Unit/Controller/Remote/RemoteServerTest.php
+++ b/typo3/sysext/workspaces/Tests/Unit/Controller/Remote/RemoteServerTest.php
@@ -18,6 +18,7 @@ declare(strict_types=1);
 namespace TYPO3\CMS\Workspaces\Tests\Unit\Controller\Remote;
 
 use Prophecy\Argument;
+use Prophecy\PhpUnit\ProphecyTrait;
 use Prophecy\Prophecy\ObjectProphecy;
 use TYPO3\CMS\Core\Resource\File;
 use TYPO3\CMS\Core\Resource\FileReference;
@@ -31,7 +32,8 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
  */
 class RemoteServerTest extends UnitTestCase
 {
-    use \Prophecy\PhpUnit\ProphecyTrait;
+    use ProphecyTrait;
+
     /**
      * @var bool Reset singletons created by subject
      */
@@ -40,12 +42,12 @@ class RemoteServerTest extends UnitTestCase
     /**
      * @var FileReference[]|ObjectProphecy[]
      */
-    protected $fileReferenceProphecies;
+    protected array $fileReferenceProphecies;
 
     /**
      * @return array
      */
-    public function prepareFileReferenceDifferencesAreCorrectDataProvider()
+    public function prepareFileReferenceDifferencesAreCorrectDataProvider(): array
     {
         return [
             // without thumbnails
@@ -106,12 +108,12 @@ class RemoteServerTest extends UnitTestCase
     /**
      * @param string $fileFileReferenceList
      * @param string $versionFileReferenceList
-     * @param $useThumbnails
+     * @param bool $useThumbnails
      * @param array|null $expected
      * @dataProvider prepareFileReferenceDifferencesAreCorrectDataProvider
      * @test
      */
-    public function prepareFileReferenceDifferencesAreCorrect($fileFileReferenceList, $versionFileReferenceList, $useThumbnails, array $expected = null)
+    public function prepareFileReferenceDifferencesAreCorrect(string $fileFileReferenceList, string $versionFileReferenceList, bool $useThumbnails, array $expected = null): void
     {
         $liveFileReferences = $this->getFileReferenceProphecies($fileFileReferenceList);
         $versionFileReferences = $this->getFileReferenceProphecies($versionFileReferenceList);
@@ -131,7 +133,7 @@ class RemoteServerTest extends UnitTestCase
      * @param string $idList List of ids
      * @return FileReference[]|ObjectProphecy[]
      */
-    protected function getFileReferenceProphecies($idList)
+    protected function getFileReferenceProphecies(string $idList): array
     {
         $fileReferenceProphecies = [];
         $ids = GeneralUtility::trimExplode(',', $idList, true);
@@ -144,10 +146,10 @@ class RemoteServerTest extends UnitTestCase
     }
 
     /**
-     * @param int $id
+     * @param string $id
      * @return ObjectProphecy|FileReference
      */
-    protected function getFileReferenceProphecy($id)
+    protected function getFileReferenceProphecy(string $id): FileReference
     {
         if (isset($this->fileReferenceProphecies[$id])) {
             return $this->fileReferenceProphecies[$id];
-- 
GitLab