From b904c6d00d4c613950c135016983bcaaf9b46cb1 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 29 Dec 2019 22:27:00 +0100 Subject: [PATCH] Added property types to some classes --- composer.json | 2 +- .../CLI/src/Command/Api/DisableKeyCommand.php | 3 +- .../src/Command/Api/GenerateKeyCommand.php | 3 +- .../CLI/src/Command/Api/ListKeysCommand.php | 3 +- .../Command/Db/AbstractDatabaseCommand.php | 6 +-- .../src/Command/Db/CreateDatabaseCommand.php | 6 +-- .../ShortUrl/DeleteShortUrlCommand.php | 3 +- .../ShortUrl/GenerateShortUrlCommand.php | 6 +-- .../src/Command/ShortUrl/GetVisitsCommand.php | 3 +- .../Command/ShortUrl/ListShortUrlsCommand.php | 6 +-- .../Command/ShortUrl/ResolveUrlCommand.php | 3 +- .../CLI/src/Command/Tag/CreateTagCommand.php | 3 +- .../CLI/src/Command/Tag/DeleteTagsCommand.php | 3 +- .../CLI/src/Command/Tag/ListTagsCommand.php | 3 +- .../CLI/src/Command/Tag/RenameTagCommand.php | 3 +- .../Command/Util/AbstractLockedCommand.php | 3 +- .../src/Command/Util/LockedCommandConfig.php | 9 ++--- .../src/Command/Visit/LocateVisitsCommand.php | 15 +++---- .../GeolocationDbUpdateFailedException.php | 3 +- module/CLI/src/Util/GeolocationDbUpdater.php | 9 ++--- module/CLI/src/Util/ShlinkTable.php | 3 +- .../Command/Api/DisableKeyCommandTest.php | 10 ++--- .../Command/Api/GenerateKeyCommandTest.php | 10 ++--- .../test/Command/Api/ListKeysCommandTest.php | 10 ++--- .../Config/GenerateCharsetCommandTest.php | 3 +- .../Command/Db/CreateDatabaseCommandTest.php | 18 +++------ .../Command/Db/MigrateDatabaseCommandTest.php | 6 +-- .../ShortUrl/DeleteShortUrlCommandTest.php | 6 +-- .../ShortUrl/GeneratePreviewCommandTest.php | 9 ++--- .../ShortUrl/GenerateShortUrlCommandTest.php | 6 +-- .../Command/ShortUrl/GetVisitsCommandTest.php | 6 +-- .../ShortUrl/ListShortUrlsCommandTest.php | 6 +-- .../ShortUrl/ResolveUrlCommandTest.php | 6 +-- .../test/Command/Tag/CreateTagCommandTest.php | 10 ++--- .../Command/Tag/DeleteTagsCommandTest.php | 12 ++---- .../test/Command/Tag/ListTagsCommandTest.php | 12 ++---- .../test/Command/Tag/RenameTagCommandTest.php | 8 +--- .../Command/Visit/LocateVisitsCommandTest.php | 18 +++------ .../Command/Visit/UpdateDbCommandTest.php | 6 +-- module/CLI/test/ConfigProviderTest.php | 3 +- .../test/Factory/ApplicationFactoryTest.php | 4 +- .../test/Util/GeolocationDbUpdaterTest.php | 15 +++---- module/CLI/test/Util/ShlinkTableTest.php | 6 +-- .../src/Action/AbstractTrackingAction.php | 12 ++---- module/Core/src/Action/QrCodeAction.php | 9 ++--- .../Resolver/PersistenceDomainResolver.php | 3 +- module/Core/src/Entity/Domain.php | 3 +- module/Core/src/Entity/ShortUrl.php | 28 +++++-------- module/Core/src/Entity/Tag.php | 3 +- module/Core/src/Entity/Visit.php | 18 +++------ module/Core/src/Entity/VisitLocation.php | 21 ++++------ .../ErrorHandler/NotFoundRedirectHandler.php | 6 +-- .../ErrorHandler/NotFoundTemplateHandler.php | 3 +- .../EventDispatcher/LocateShortUrlVisit.php | 15 +++---- .../EventDispatcher/NotifyVisitToWebHooks.php | 19 ++++----- .../src/EventDispatcher/ShortUrlVisited.php | 3 +- .../Core/src/EventDispatcher/VisitLocated.php | 3 +- .../Exception/IpCannotBeLocatedException.php | 22 ++++------- .../src/Exception/ValidationException.php | 3 +- .../src/Middleware/QrCodeCacheMiddleware.php | 3 +- module/Core/src/Model/CreateShortUrlData.php | 9 ++--- module/Core/src/Model/ShortUrlMeta.php | 22 ++++------- module/Core/src/Model/Visitor.php | 9 ++--- module/Core/src/Model/VisitsParams.php | 9 ++--- module/Core/src/Options/AppOptions.php | 16 +++----- .../src/Options/NotFoundRedirectOptions.php | 9 ++--- .../Adapter/ShortUrlRepositoryAdapter.php | 12 ++---- .../Adapter/VisitsPaginatorAdapter.php | 9 ++--- .../ShortUrl/DeleteShortUrlService.php | 6 +-- module/Core/src/Service/ShortUrlService.php | 3 +- module/Core/src/Service/Tag/TagService.php | 3 +- module/Core/src/Service/UrlShortener.php | 9 ++--- module/Core/src/Service/VisitService.php | 3 +- module/Core/src/Service/VisitsTracker.php | 6 +-- .../Transformer/ShortUrlDataTransformer.php | 3 +- module/Core/src/Util/UrlValidator.php | 3 +- .../Repository/ShortUrlRepositoryTest.php | 3 +- .../test-db/Repository/TagRepositoryTest.php | 3 +- .../Repository/VisitRepositoryTest.php | 3 +- module/Core/test/Action/PixelActionTest.php | 10 ++--- module/Core/test/Action/PreviewActionTest.php | 1 + module/Core/test/Action/QrCodeActionTest.php | 6 +-- .../Core/test/Action/RedirectActionTest.php | 9 ++--- module/Core/test/ConfigProviderTest.php | 3 +- .../IpCannotBeLocatedExceptionTest.php | 39 ------------------- module/Core/test/Service/VisitServiceTest.php | 5 ++- 86 files changed, 218 insertions(+), 457 deletions(-) diff --git a/composer.json b/composer.json index b49848cd..1dddb7f8 100644 --- a/composer.json +++ b/composer.json @@ -60,7 +60,7 @@ "devster/ubench": "^2.0", "eaglewu/swoole-ide-helper": "dev-master", "infection/infection": "^0.15.0", - "phpstan/phpstan-shim": "^0.11.16", + "phpstan/phpstan": "^0.12.3", "phpunit/phpunit": "^8.3", "roave/security-advisories": "dev-master", "shlinkio/php-coding-standard": "~2.0.0", diff --git a/module/CLI/src/Command/Api/DisableKeyCommand.php b/module/CLI/src/Command/Api/DisableKeyCommand.php index f3eb7f6b..1a8024ec 100644 --- a/module/CLI/src/Command/Api/DisableKeyCommand.php +++ b/module/CLI/src/Command/Api/DisableKeyCommand.php @@ -19,8 +19,7 @@ class DisableKeyCommand extends Command { public const NAME = 'api-key:disable'; - /** @var ApiKeyServiceInterface */ - private $apiKeyService; + private ApiKeyServiceInterface $apiKeyService; public function __construct(ApiKeyServiceInterface $apiKeyService) { diff --git a/module/CLI/src/Command/Api/GenerateKeyCommand.php b/module/CLI/src/Command/Api/GenerateKeyCommand.php index bbe86a51..cadc1fc1 100644 --- a/module/CLI/src/Command/Api/GenerateKeyCommand.php +++ b/module/CLI/src/Command/Api/GenerateKeyCommand.php @@ -19,8 +19,7 @@ class GenerateKeyCommand extends Command { public const NAME = 'api-key:generate'; - /** @var ApiKeyServiceInterface */ - private $apiKeyService; + private ApiKeyServiceInterface $apiKeyService; public function __construct(ApiKeyServiceInterface $apiKeyService) { diff --git a/module/CLI/src/Command/Api/ListKeysCommand.php b/module/CLI/src/Command/Api/ListKeysCommand.php index c9df3a07..2d8b8cd6 100644 --- a/module/CLI/src/Command/Api/ListKeysCommand.php +++ b/module/CLI/src/Command/Api/ListKeysCommand.php @@ -25,8 +25,7 @@ class ListKeysCommand extends Command public const NAME = 'api-key:list'; - /** @var ApiKeyServiceInterface */ - private $apiKeyService; + private ApiKeyServiceInterface $apiKeyService; public function __construct(ApiKeyServiceInterface $apiKeyService) { diff --git a/module/CLI/src/Command/Db/AbstractDatabaseCommand.php b/module/CLI/src/Command/Db/AbstractDatabaseCommand.php index bf99de9b..4b45fa56 100644 --- a/module/CLI/src/Command/Db/AbstractDatabaseCommand.php +++ b/module/CLI/src/Command/Db/AbstractDatabaseCommand.php @@ -15,10 +15,8 @@ use function array_unshift; abstract class AbstractDatabaseCommand extends AbstractLockedCommand { - /** @var ProcessHelper */ - private $processHelper; - /** @var string */ - private $phpBinary; + private ProcessHelper $processHelper; + private string $phpBinary; public function __construct(LockFactory $locker, ProcessHelper $processHelper, PhpExecutableFinder $phpFinder) { diff --git a/module/CLI/src/Command/Db/CreateDatabaseCommand.php b/module/CLI/src/Command/Db/CreateDatabaseCommand.php index 54cd27ea..30043f72 100644 --- a/module/CLI/src/Command/Db/CreateDatabaseCommand.php +++ b/module/CLI/src/Command/Db/CreateDatabaseCommand.php @@ -21,10 +21,8 @@ class CreateDatabaseCommand extends AbstractDatabaseCommand public const DOCTRINE_SCRIPT = 'vendor/doctrine/orm/bin/doctrine.php'; public const DOCTRINE_CREATE_SCHEMA_COMMAND = 'orm:schema-tool:create'; - /** @var Connection */ - private $regularConn; - /** @var Connection */ - private $noDbNameConn; + private Connection $regularConn; + private Connection $noDbNameConn; public function __construct( LockFactory $locker, diff --git a/module/CLI/src/Command/ShortUrl/DeleteShortUrlCommand.php b/module/CLI/src/Command/ShortUrl/DeleteShortUrlCommand.php index c2e81d0d..6626791b 100644 --- a/module/CLI/src/Command/ShortUrl/DeleteShortUrlCommand.php +++ b/module/CLI/src/Command/ShortUrl/DeleteShortUrlCommand.php @@ -21,8 +21,7 @@ class DeleteShortUrlCommand extends Command public const NAME = 'short-url:delete'; private const ALIASES = ['short-code:delete']; - /** @var DeleteShortUrlServiceInterface */ - private $deleteShortUrlService; + private DeleteShortUrlServiceInterface $deleteShortUrlService; public function __construct(DeleteShortUrlServiceInterface $deleteShortUrlService) { diff --git a/module/CLI/src/Command/ShortUrl/GenerateShortUrlCommand.php b/module/CLI/src/Command/ShortUrl/GenerateShortUrlCommand.php index faefbf4b..94748795 100644 --- a/module/CLI/src/Command/ShortUrl/GenerateShortUrlCommand.php +++ b/module/CLI/src/Command/ShortUrl/GenerateShortUrlCommand.php @@ -28,10 +28,8 @@ class GenerateShortUrlCommand extends Command public const NAME = 'short-url:generate'; private const ALIASES = ['shortcode:generate', 'short-code:generate']; - /** @var UrlShortenerInterface */ - private $urlShortener; - /** @var array */ - private $domainConfig; + private UrlShortenerInterface $urlShortener; + private array $domainConfig; public function __construct(UrlShortenerInterface $urlShortener, array $domainConfig) { diff --git a/module/CLI/src/Command/ShortUrl/GetVisitsCommand.php b/module/CLI/src/Command/ShortUrl/GetVisitsCommand.php index 7a51ac0b..94462a57 100644 --- a/module/CLI/src/Command/ShortUrl/GetVisitsCommand.php +++ b/module/CLI/src/Command/ShortUrl/GetVisitsCommand.php @@ -24,8 +24,7 @@ class GetVisitsCommand extends AbstractWithDateRangeCommand public const NAME = 'short-url:visits'; private const ALIASES = ['shortcode:visits', 'short-code:visits']; - /** @var VisitsTrackerInterface */ - private $visitsTracker; + private VisitsTrackerInterface $visitsTracker; public function __construct(VisitsTrackerInterface $visitsTracker) { diff --git a/module/CLI/src/Command/ShortUrl/ListShortUrlsCommand.php b/module/CLI/src/Command/ShortUrl/ListShortUrlsCommand.php index 01080189..9eb0cc13 100644 --- a/module/CLI/src/Command/ShortUrl/ListShortUrlsCommand.php +++ b/module/CLI/src/Command/ShortUrl/ListShortUrlsCommand.php @@ -42,10 +42,8 @@ class ListShortUrlsCommand extends AbstractWithDateRangeCommand 'tags', ]; - /** @var ShortUrlServiceInterface */ - private $shortUrlService; - /** @var ShortUrlDataTransformer */ - private $transformer; + private ShortUrlServiceInterface $shortUrlService; + private ShortUrlDataTransformer $transformer; public function __construct(ShortUrlServiceInterface $shortUrlService, array $domainConfig) { diff --git a/module/CLI/src/Command/ShortUrl/ResolveUrlCommand.php b/module/CLI/src/Command/ShortUrl/ResolveUrlCommand.php index e8db28e2..c75ac9d6 100644 --- a/module/CLI/src/Command/ShortUrl/ResolveUrlCommand.php +++ b/module/CLI/src/Command/ShortUrl/ResolveUrlCommand.php @@ -21,8 +21,7 @@ class ResolveUrlCommand extends Command public const NAME = 'short-url:parse'; private const ALIASES = ['shortcode:parse', 'short-code:parse']; - /** @var UrlShortenerInterface */ - private $urlShortener; + private UrlShortenerInterface $urlShortener; public function __construct(UrlShortenerInterface $urlShortener) { diff --git a/module/CLI/src/Command/Tag/CreateTagCommand.php b/module/CLI/src/Command/Tag/CreateTagCommand.php index 9971d96a..18aba957 100644 --- a/module/CLI/src/Command/Tag/CreateTagCommand.php +++ b/module/CLI/src/Command/Tag/CreateTagCommand.php @@ -16,8 +16,7 @@ class CreateTagCommand extends Command { public const NAME = 'tag:create'; - /** @var TagServiceInterface */ - private $tagService; + private TagServiceInterface $tagService; public function __construct(TagServiceInterface $tagService) { diff --git a/module/CLI/src/Command/Tag/DeleteTagsCommand.php b/module/CLI/src/Command/Tag/DeleteTagsCommand.php index 2677f11c..a3dd81e1 100644 --- a/module/CLI/src/Command/Tag/DeleteTagsCommand.php +++ b/module/CLI/src/Command/Tag/DeleteTagsCommand.php @@ -16,8 +16,7 @@ class DeleteTagsCommand extends Command { public const NAME = 'tag:delete'; - /** @var TagServiceInterface */ - private $tagService; + private TagServiceInterface $tagService; public function __construct(TagServiceInterface $tagService) { diff --git a/module/CLI/src/Command/Tag/ListTagsCommand.php b/module/CLI/src/Command/Tag/ListTagsCommand.php index db3df1c3..e4059291 100644 --- a/module/CLI/src/Command/Tag/ListTagsCommand.php +++ b/module/CLI/src/Command/Tag/ListTagsCommand.php @@ -18,8 +18,7 @@ class ListTagsCommand extends Command { public const NAME = 'tag:list'; - /** @var TagServiceInterface */ - private $tagService; + private TagServiceInterface $tagService; public function __construct(TagServiceInterface $tagService) { diff --git a/module/CLI/src/Command/Tag/RenameTagCommand.php b/module/CLI/src/Command/Tag/RenameTagCommand.php index d1607f34..f30bc757 100644 --- a/module/CLI/src/Command/Tag/RenameTagCommand.php +++ b/module/CLI/src/Command/Tag/RenameTagCommand.php @@ -18,8 +18,7 @@ class RenameTagCommand extends Command { public const NAME = 'tag:rename'; - /** @var TagServiceInterface */ - private $tagService; + private TagServiceInterface $tagService; public function __construct(TagServiceInterface $tagService) { diff --git a/module/CLI/src/Command/Util/AbstractLockedCommand.php b/module/CLI/src/Command/Util/AbstractLockedCommand.php index 59ea74fa..eab43436 100644 --- a/module/CLI/src/Command/Util/AbstractLockedCommand.php +++ b/module/CLI/src/Command/Util/AbstractLockedCommand.php @@ -14,8 +14,7 @@ use function sprintf; abstract class AbstractLockedCommand extends Command { - /** @var LockFactory */ - private $locker; + private LockFactory $locker; public function __construct(LockFactory $locker) { diff --git a/module/CLI/src/Command/Util/LockedCommandConfig.php b/module/CLI/src/Command/Util/LockedCommandConfig.php index be7c2deb..8a217f85 100644 --- a/module/CLI/src/Command/Util/LockedCommandConfig.php +++ b/module/CLI/src/Command/Util/LockedCommandConfig.php @@ -8,12 +8,9 @@ final class LockedCommandConfig { private const DEFAULT_TTL = 90.0; // 1.5 minutes - /** @var string */ - private $lockName; - /** @var bool */ - private $isBlocking; - /** @var float */ - private $ttl; + private string $lockName; + private bool $isBlocking; + private float $ttl; public function __construct(string $lockName, bool $isBlocking = false, float $ttl = self::DEFAULT_TTL) { diff --git a/module/CLI/src/Command/Visit/LocateVisitsCommand.php b/module/CLI/src/Command/Visit/LocateVisitsCommand.php index 710c4a3a..0bbd0c90 100644 --- a/module/CLI/src/Command/Visit/LocateVisitsCommand.php +++ b/module/CLI/src/Command/Visit/LocateVisitsCommand.php @@ -32,17 +32,12 @@ class LocateVisitsCommand extends AbstractLockedCommand public const NAME = 'visit:locate'; public const ALIASES = ['visit:process']; - /** @var VisitServiceInterface */ - private $visitService; - /** @var IpLocationResolverInterface */ - private $ipLocationResolver; - /** @var GeolocationDbUpdaterInterface */ - private $dbUpdater; + private VisitServiceInterface $visitService; + private IpLocationResolverInterface $ipLocationResolver; + private GeolocationDbUpdaterInterface $dbUpdater; - /** @var SymfonyStyle */ - private $io; - /** @var ProgressBar */ - private $progressBar; + private SymfonyStyle $io; + private ?ProgressBar $progressBar = null; public function __construct( VisitServiceInterface $visitService, diff --git a/module/CLI/src/Exception/GeolocationDbUpdateFailedException.php b/module/CLI/src/Exception/GeolocationDbUpdateFailedException.php index 38bb4c5f..42707d9b 100644 --- a/module/CLI/src/Exception/GeolocationDbUpdateFailedException.php +++ b/module/CLI/src/Exception/GeolocationDbUpdateFailedException.php @@ -9,8 +9,7 @@ use Throwable; class GeolocationDbUpdateFailedException extends RuntimeException implements ExceptionInterface { - /** @var bool */ - private $olderDbExists; + private bool $olderDbExists; public static function create(bool $olderDbExists, ?Throwable $prev = null): self { diff --git a/module/CLI/src/Util/GeolocationDbUpdater.php b/module/CLI/src/Util/GeolocationDbUpdater.php index 25b49c37..b74ebdac 100644 --- a/module/CLI/src/Util/GeolocationDbUpdater.php +++ b/module/CLI/src/Util/GeolocationDbUpdater.php @@ -15,12 +15,9 @@ class GeolocationDbUpdater implements GeolocationDbUpdaterInterface { private const LOCK_NAME = 'geolocation-db-update'; - /** @var DbUpdaterInterface */ - private $dbUpdater; - /** @var Reader */ - private $geoLiteDbReader; - /** @var LockFactory */ - private $locker; + private DbUpdaterInterface $dbUpdater; + private Reader $geoLiteDbReader; + private LockFactory $locker; public function __construct(DbUpdaterInterface $dbUpdater, Reader $geoLiteDbReader, LockFactory $locker) { diff --git a/module/CLI/src/Util/ShlinkTable.php b/module/CLI/src/Util/ShlinkTable.php index a577ce8d..ac8733ad 100644 --- a/module/CLI/src/Util/ShlinkTable.php +++ b/module/CLI/src/Util/ShlinkTable.php @@ -12,8 +12,7 @@ final class ShlinkTable private const DEFAULT_STYLE_NAME = 'default'; private const TABLE_TITLE_STYLE = ' %s '; - /** @var Table|null */ - private $baseTable; + private ?Table $baseTable; public function __construct(Table $baseTable) { diff --git a/module/CLI/test/Command/Api/DisableKeyCommandTest.php b/module/CLI/test/Command/Api/DisableKeyCommandTest.php index 37629091..8b5ef6c4 100644 --- a/module/CLI/test/Command/Api/DisableKeyCommandTest.php +++ b/module/CLI/test/Command/Api/DisableKeyCommandTest.php @@ -8,20 +8,18 @@ use PHPUnit\Framework\TestCase; use Prophecy\Prophecy\ObjectProphecy; use Shlinkio\Shlink\CLI\Command\Api\DisableKeyCommand; use Shlinkio\Shlink\Common\Exception\InvalidArgumentException; -use Shlinkio\Shlink\Rest\Service\ApiKeyService; +use Shlinkio\Shlink\Rest\Service\ApiKeyServiceInterface; use Symfony\Component\Console\Application; use Symfony\Component\Console\Tester\CommandTester; class DisableKeyCommandTest extends TestCase { - /** @var CommandTester */ - private $commandTester; - /** @var ObjectProphecy */ - private $apiKeyService; + private CommandTester $commandTester; + private ObjectProphecy $apiKeyService; public function setUp(): void { - $this->apiKeyService = $this->prophesize(ApiKeyService::class); + $this->apiKeyService = $this->prophesize(ApiKeyServiceInterface::class); $command = new DisableKeyCommand($this->apiKeyService->reveal()); $app = new Application(); $app->add($command); diff --git a/module/CLI/test/Command/Api/GenerateKeyCommandTest.php b/module/CLI/test/Command/Api/GenerateKeyCommandTest.php index 1556aa85..fe5bc137 100644 --- a/module/CLI/test/Command/Api/GenerateKeyCommandTest.php +++ b/module/CLI/test/Command/Api/GenerateKeyCommandTest.php @@ -10,20 +10,18 @@ use Prophecy\Argument; use Prophecy\Prophecy\ObjectProphecy; use Shlinkio\Shlink\CLI\Command\Api\GenerateKeyCommand; use Shlinkio\Shlink\Rest\Entity\ApiKey; -use Shlinkio\Shlink\Rest\Service\ApiKeyService; +use Shlinkio\Shlink\Rest\Service\ApiKeyServiceInterface; use Symfony\Component\Console\Application; use Symfony\Component\Console\Tester\CommandTester; class GenerateKeyCommandTest extends TestCase { - /** @var CommandTester */ - private $commandTester; - /** @var ObjectProphecy */ - private $apiKeyService; + private CommandTester $commandTester; + private ObjectProphecy $apiKeyService; public function setUp(): void { - $this->apiKeyService = $this->prophesize(ApiKeyService::class); + $this->apiKeyService = $this->prophesize(ApiKeyServiceInterface::class); $command = new GenerateKeyCommand($this->apiKeyService->reveal()); $app = new Application(); $app->add($command); diff --git a/module/CLI/test/Command/Api/ListKeysCommandTest.php b/module/CLI/test/Command/Api/ListKeysCommandTest.php index 027b22c2..9e30605a 100644 --- a/module/CLI/test/Command/Api/ListKeysCommandTest.php +++ b/module/CLI/test/Command/Api/ListKeysCommandTest.php @@ -8,20 +8,18 @@ use PHPUnit\Framework\TestCase; use Prophecy\Prophecy\ObjectProphecy; use Shlinkio\Shlink\CLI\Command\Api\ListKeysCommand; use Shlinkio\Shlink\Rest\Entity\ApiKey; -use Shlinkio\Shlink\Rest\Service\ApiKeyService; +use Shlinkio\Shlink\Rest\Service\ApiKeyServiceInterface; use Symfony\Component\Console\Application; use Symfony\Component\Console\Tester\CommandTester; class ListKeysCommandTest extends TestCase { - /** @var CommandTester */ - private $commandTester; - /** @var ObjectProphecy */ - private $apiKeyService; + private CommandTester $commandTester; + private ObjectProphecy $apiKeyService; public function setUp(): void { - $this->apiKeyService = $this->prophesize(ApiKeyService::class); + $this->apiKeyService = $this->prophesize(ApiKeyServiceInterface::class); $command = new ListKeysCommand($this->apiKeyService->reveal()); $app = new Application(); $app->add($command); diff --git a/module/CLI/test/Command/Config/GenerateCharsetCommandTest.php b/module/CLI/test/Command/Config/GenerateCharsetCommandTest.php index 8475cecc..e5430e4a 100644 --- a/module/CLI/test/Command/Config/GenerateCharsetCommandTest.php +++ b/module/CLI/test/Command/Config/GenerateCharsetCommandTest.php @@ -15,8 +15,7 @@ use function str_split; class GenerateCharsetCommandTest extends TestCase { - /** @var CommandTester */ - private $commandTester; + private CommandTester $commandTester; public function setUp(): void { diff --git a/module/CLI/test/Command/Db/CreateDatabaseCommandTest.php b/module/CLI/test/Command/Db/CreateDatabaseCommandTest.php index 7945ea05..700b96bb 100644 --- a/module/CLI/test/Command/Db/CreateDatabaseCommandTest.php +++ b/module/CLI/test/Command/Db/CreateDatabaseCommandTest.php @@ -21,18 +21,12 @@ use Symfony\Component\Process\PhpExecutableFinder; class CreateDatabaseCommandTest extends TestCase { - /** @var CommandTester */ - private $commandTester; - /** @var ObjectProphecy */ - private $processHelper; - /** @var ObjectProphecy */ - private $regularConn; - /** @var ObjectProphecy */ - private $noDbNameConn; - /** @var ObjectProphecy */ - private $schemaManager; - /** @var ObjectProphecy */ - private $databasePlatform; + private CommandTester $commandTester; + private ObjectProphecy $processHelper; + private ObjectProphecy $regularConn; + private ObjectProphecy $noDbNameConn; + private ObjectProphecy $schemaManager; + private ObjectProphecy $databasePlatform; public function setUp(): void { diff --git a/module/CLI/test/Command/Db/MigrateDatabaseCommandTest.php b/module/CLI/test/Command/Db/MigrateDatabaseCommandTest.php index be36a980..70dce5cc 100644 --- a/module/CLI/test/Command/Db/MigrateDatabaseCommandTest.php +++ b/module/CLI/test/Command/Db/MigrateDatabaseCommandTest.php @@ -18,10 +18,8 @@ use Symfony\Component\Process\PhpExecutableFinder; class MigrateDatabaseCommandTest extends TestCase { - /** @var CommandTester */ - private $commandTester; - /** @var ObjectProphecy */ - private $processHelper; + private CommandTester $commandTester; + private ObjectProphecy $processHelper; public function setUp(): void { diff --git a/module/CLI/test/Command/ShortUrl/DeleteShortUrlCommandTest.php b/module/CLI/test/Command/ShortUrl/DeleteShortUrlCommandTest.php index 85521835..989277b8 100644 --- a/module/CLI/test/Command/ShortUrl/DeleteShortUrlCommandTest.php +++ b/module/CLI/test/Command/ShortUrl/DeleteShortUrlCommandTest.php @@ -20,10 +20,8 @@ use const PHP_EOL; class DeleteShortUrlCommandTest extends TestCase { - /** @var CommandTester */ - private $commandTester; - /** @var ObjectProphecy */ - private $service; + private CommandTester $commandTester; + private ObjectProphecy $service; public function setUp(): void { diff --git a/module/CLI/test/Command/ShortUrl/GeneratePreviewCommandTest.php b/module/CLI/test/Command/ShortUrl/GeneratePreviewCommandTest.php index 077e0c60..e4029231 100644 --- a/module/CLI/test/Command/ShortUrl/GeneratePreviewCommandTest.php +++ b/module/CLI/test/Command/ShortUrl/GeneratePreviewCommandTest.php @@ -22,12 +22,9 @@ use function substr_count; class GeneratePreviewCommandTest extends TestCase { - /** @var CommandTester */ - private $commandTester; - /** @var ObjectProphecy */ - private $previewGenerator; - /** @var ObjectProphecy */ - private $shortUrlService; + private CommandTester $commandTester; + private ObjectProphecy $previewGenerator; + private ObjectProphecy $shortUrlService; public function setUp(): void { diff --git a/module/CLI/test/Command/ShortUrl/GenerateShortUrlCommandTest.php b/module/CLI/test/Command/ShortUrl/GenerateShortUrlCommandTest.php index abae0fe6..4f55e7c8 100644 --- a/module/CLI/test/Command/ShortUrl/GenerateShortUrlCommandTest.php +++ b/module/CLI/test/Command/ShortUrl/GenerateShortUrlCommandTest.php @@ -25,10 +25,8 @@ class GenerateShortUrlCommandTest extends TestCase 'hostname' => 'foo.com', ]; - /** @var CommandTester */ - private $commandTester; - /** @var ObjectProphecy */ - private $urlShortener; + private CommandTester $commandTester; + private ObjectProphecy $urlShortener; public function setUp(): void { diff --git a/module/CLI/test/Command/ShortUrl/GetVisitsCommandTest.php b/module/CLI/test/Command/ShortUrl/GetVisitsCommandTest.php index e2ea29d1..1fd0c229 100644 --- a/module/CLI/test/Command/ShortUrl/GetVisitsCommandTest.php +++ b/module/CLI/test/Command/ShortUrl/GetVisitsCommandTest.php @@ -26,10 +26,8 @@ use function sprintf; class GetVisitsCommandTest extends TestCase { - /** @var CommandTester */ - private $commandTester; - /** @var ObjectProphecy */ - private $visitsTracker; + private CommandTester $commandTester; + private ObjectProphecy $visitsTracker; public function setUp(): void { diff --git a/module/CLI/test/Command/ShortUrl/ListShortUrlsCommandTest.php b/module/CLI/test/Command/ShortUrl/ListShortUrlsCommandTest.php index 0bf3bfab..5fc3ecee 100644 --- a/module/CLI/test/Command/ShortUrl/ListShortUrlsCommandTest.php +++ b/module/CLI/test/Command/ShortUrl/ListShortUrlsCommandTest.php @@ -21,10 +21,8 @@ use function explode; class ListShortUrlsCommandTest extends TestCase { - /** @var CommandTester */ - private $commandTester; - /** @var ObjectProphecy */ - private $shortUrlService; + private CommandTester $commandTester; + private ObjectProphecy $shortUrlService; public function setUp(): void { diff --git a/module/CLI/test/Command/ShortUrl/ResolveUrlCommandTest.php b/module/CLI/test/Command/ShortUrl/ResolveUrlCommandTest.php index 11b549e5..1fe8b238 100644 --- a/module/CLI/test/Command/ShortUrl/ResolveUrlCommandTest.php +++ b/module/CLI/test/Command/ShortUrl/ResolveUrlCommandTest.php @@ -19,10 +19,8 @@ use const PHP_EOL; class ResolveUrlCommandTest extends TestCase { - /** @var CommandTester */ - private $commandTester; - /** @var ObjectProphecy */ - private $urlShortener; + private CommandTester $commandTester; + private ObjectProphecy $urlShortener; public function setUp(): void { diff --git a/module/CLI/test/Command/Tag/CreateTagCommandTest.php b/module/CLI/test/Command/Tag/CreateTagCommandTest.php index 402c63a6..bed087a5 100644 --- a/module/CLI/test/Command/Tag/CreateTagCommandTest.php +++ b/module/CLI/test/Command/Tag/CreateTagCommandTest.php @@ -14,10 +14,8 @@ use Symfony\Component\Console\Tester\CommandTester; class CreateTagCommandTest extends TestCase { - /** @var CommandTester */ - private $commandTester; - /** @var ObjectProphecy */ - private $tagService; + private CommandTester $commandTester; + private ObjectProphecy $tagService; public function setUp(): void { @@ -31,7 +29,7 @@ class CreateTagCommandTest extends TestCase } /** @test */ - public function errorIsReturnedWhenNoTagsAreProvided() + public function errorIsReturnedWhenNoTagsAreProvided(): void { $this->commandTester->execute([]); @@ -40,7 +38,7 @@ class CreateTagCommandTest extends TestCase } /** @test */ - public function serviceIsInvokedOnSuccess() + public function serviceIsInvokedOnSuccess(): void { $tagNames = ['foo', 'bar']; $createTags = $this->tagService->createTags($tagNames)->willReturn(new ArrayCollection()); diff --git a/module/CLI/test/Command/Tag/DeleteTagsCommandTest.php b/module/CLI/test/Command/Tag/DeleteTagsCommandTest.php index 79701ddb..f526f37f 100644 --- a/module/CLI/test/Command/Tag/DeleteTagsCommandTest.php +++ b/module/CLI/test/Command/Tag/DeleteTagsCommandTest.php @@ -13,12 +13,8 @@ use Symfony\Component\Console\Tester\CommandTester; class DeleteTagsCommandTest extends TestCase { - /** @var DeleteTagsCommand */ - private $command; - /** @var CommandTester */ - private $commandTester; - /** @var ObjectProphecy */ - private $tagService; + private CommandTester $commandTester; + private ObjectProphecy $tagService; public function setUp(): void { @@ -32,7 +28,7 @@ class DeleteTagsCommandTest extends TestCase } /** @test */ - public function errorIsReturnedWhenNoTagsAreProvided() + public function errorIsReturnedWhenNoTagsAreProvided(): void { $this->commandTester->execute([]); @@ -41,7 +37,7 @@ class DeleteTagsCommandTest extends TestCase } /** @test */ - public function serviceIsInvokedOnSuccess() + public function serviceIsInvokedOnSuccess(): void { $tagNames = ['foo', 'bar']; $deleteTags = $this->tagService->deleteTags($tagNames)->will(function () { diff --git a/module/CLI/test/Command/Tag/ListTagsCommandTest.php b/module/CLI/test/Command/Tag/ListTagsCommandTest.php index eec94372..f171127c 100644 --- a/module/CLI/test/Command/Tag/ListTagsCommandTest.php +++ b/module/CLI/test/Command/Tag/ListTagsCommandTest.php @@ -14,12 +14,8 @@ use Symfony\Component\Console\Tester\CommandTester; class ListTagsCommandTest extends TestCase { - /** @var ListTagsCommand */ - private $command; - /** @var CommandTester */ - private $commandTester; - /** @var ObjectProphecy */ - private $tagService; + private CommandTester $commandTester; + private ObjectProphecy $tagService; public function setUp(): void { @@ -33,7 +29,7 @@ class ListTagsCommandTest extends TestCase } /** @test */ - public function noTagsPrintsEmptyMessage() + public function noTagsPrintsEmptyMessage(): void { $listTags = $this->tagService->listTags()->willReturn([]); @@ -45,7 +41,7 @@ class ListTagsCommandTest extends TestCase } /** @test */ - public function listOfTagsIsPrinted() + public function listOfTagsIsPrinted(): void { $listTags = $this->tagService->listTags()->willReturn([ new Tag('foo'), diff --git a/module/CLI/test/Command/Tag/RenameTagCommandTest.php b/module/CLI/test/Command/Tag/RenameTagCommandTest.php index c626e0c0..59f8d89c 100644 --- a/module/CLI/test/Command/Tag/RenameTagCommandTest.php +++ b/module/CLI/test/Command/Tag/RenameTagCommandTest.php @@ -15,12 +15,8 @@ use Symfony\Component\Console\Tester\CommandTester; class RenameTagCommandTest extends TestCase { - /** @var RenameTagCommand */ - private $command; - /** @var CommandTester */ - private $commandTester; - /** @var ObjectProphecy */ - private $tagService; + private CommandTester $commandTester; + private ObjectProphecy $tagService; public function setUp(): void { diff --git a/module/CLI/test/Command/Visit/LocateVisitsCommandTest.php b/module/CLI/test/Command/Visit/LocateVisitsCommandTest.php index e01bf85f..c1a09b08 100644 --- a/module/CLI/test/Command/Visit/LocateVisitsCommandTest.php +++ b/module/CLI/test/Command/Visit/LocateVisitsCommandTest.php @@ -29,18 +29,12 @@ use function sprintf; class LocateVisitsCommandTest extends TestCase { - /** @var CommandTester */ - private $commandTester; - /** @var ObjectProphecy */ - private $visitService; - /** @var ObjectProphecy */ - private $ipResolver; - /** @var ObjectProphecy */ - private $locker; - /** @var ObjectProphecy */ - private $lock; - /** @var ObjectProphecy */ - private $dbUpdater; + private CommandTester $commandTester; + private ObjectProphecy $visitService; + private ObjectProphecy $ipResolver; + private ObjectProphecy $locker; + private ObjectProphecy $lock; + private ObjectProphecy $dbUpdater; public function setUp(): void { diff --git a/module/CLI/test/Command/Visit/UpdateDbCommandTest.php b/module/CLI/test/Command/Visit/UpdateDbCommandTest.php index dc343efd..2d6fc478 100644 --- a/module/CLI/test/Command/Visit/UpdateDbCommandTest.php +++ b/module/CLI/test/Command/Visit/UpdateDbCommandTest.php @@ -16,10 +16,8 @@ use Symfony\Component\Console\Tester\CommandTester; class UpdateDbCommandTest extends TestCase { - /** @var CommandTester */ - private $commandTester; - /** @var ObjectProphecy */ - private $dbUpdater; + private CommandTester $commandTester; + private ObjectProphecy $dbUpdater; public function setUp(): void { diff --git a/module/CLI/test/ConfigProviderTest.php b/module/CLI/test/ConfigProviderTest.php index 48931551..96e2d2b4 100644 --- a/module/CLI/test/ConfigProviderTest.php +++ b/module/CLI/test/ConfigProviderTest.php @@ -9,8 +9,7 @@ use Shlinkio\Shlink\CLI\ConfigProvider; class ConfigProviderTest extends TestCase { - /** @var ConfigProvider */ - private $configProvider; + private ConfigProvider $configProvider; public function setUp(): void { diff --git a/module/CLI/test/Factory/ApplicationFactoryTest.php b/module/CLI/test/Factory/ApplicationFactoryTest.php index 7f8ca6ea..0dd9dc01 100644 --- a/module/CLI/test/Factory/ApplicationFactoryTest.php +++ b/module/CLI/test/Factory/ApplicationFactoryTest.php @@ -15,8 +15,7 @@ use Zend\ServiceManager\ServiceManager; class ApplicationFactoryTest extends TestCase { - /** @var ApplicationFactory */ - private $factory; + private ApplicationFactory $factory; public function setUp(): void { @@ -36,7 +35,6 @@ class ApplicationFactoryTest extends TestCase $sm->setService('foo', $this->createCommandMock('foo')->reveal()); $sm->setService('bar', $this->createCommandMock('bar')->reveal()); - /** @var Application $instance */ $instance = ($this->factory)($sm); $this->assertTrue($instance->has('foo')); diff --git a/module/CLI/test/Util/GeolocationDbUpdaterTest.php b/module/CLI/test/Util/GeolocationDbUpdaterTest.php index f2b0f98c..7120c735 100644 --- a/module/CLI/test/Util/GeolocationDbUpdaterTest.php +++ b/module/CLI/test/Util/GeolocationDbUpdaterTest.php @@ -22,16 +22,11 @@ use function range; class GeolocationDbUpdaterTest extends TestCase { - /** @var GeolocationDbUpdater */ - private $geolocationDbUpdater; - /** @var ObjectProphecy */ - private $dbUpdater; - /** @var ObjectProphecy */ - private $geoLiteDbReader; - /** @var ObjectProphecy */ - private $locker; - /** @var ObjectProphecy */ - private $lock; + private GeolocationDbUpdater $geolocationDbUpdater; + private ObjectProphecy $dbUpdater; + private ObjectProphecy $geoLiteDbReader; + private ObjectProphecy $locker; + private ObjectProphecy $lock; public function setUp(): void { diff --git a/module/CLI/test/Util/ShlinkTableTest.php b/module/CLI/test/Util/ShlinkTableTest.php index c67ebe47..2f679191 100644 --- a/module/CLI/test/Util/ShlinkTableTest.php +++ b/module/CLI/test/Util/ShlinkTableTest.php @@ -15,10 +15,8 @@ use Symfony\Component\Console\Output\OutputInterface; class ShlinkTableTest extends TestCase { - /** @var ShlinkTable */ - private $shlinkTable; - /** @var ObjectProphecy */ - private $baseTable; + private ShlinkTable $shlinkTable; + private ObjectProphecy $baseTable; public function setUp(): void { diff --git a/module/Core/src/Action/AbstractTrackingAction.php b/module/Core/src/Action/AbstractTrackingAction.php index ff8d91f2..d60b888e 100644 --- a/module/Core/src/Action/AbstractTrackingAction.php +++ b/module/Core/src/Action/AbstractTrackingAction.php @@ -25,14 +25,10 @@ use function http_build_query; abstract class AbstractTrackingAction implements MiddlewareInterface { - /** @var UrlShortenerInterface */ - private $urlShortener; - /** @var VisitsTrackerInterface */ - private $visitTracker; - /** @var AppOptions */ - private $appOptions; - /** @var LoggerInterface */ - private $logger; + private UrlShortenerInterface $urlShortener; + private VisitsTrackerInterface $visitTracker; + private AppOptions $appOptions; + private LoggerInterface $logger; public function __construct( UrlShortenerInterface $urlShortener, diff --git a/module/Core/src/Action/QrCodeAction.php b/module/Core/src/Action/QrCodeAction.php index 3cdee70e..083b1119 100644 --- a/module/Core/src/Action/QrCodeAction.php +++ b/module/Core/src/Action/QrCodeAction.php @@ -23,12 +23,9 @@ class QrCodeAction implements MiddlewareInterface private const MIN_SIZE = 50; private const MAX_SIZE = 1000; - /** @var RouterInterface */ - private $router; - /** @var UrlShortenerInterface */ - private $urlShortener; - /** @var LoggerInterface */ - private $logger; + private RouterInterface $router; + private UrlShortenerInterface $urlShortener; + private LoggerInterface $logger; public function __construct( RouterInterface $router, diff --git a/module/Core/src/Domain/Resolver/PersistenceDomainResolver.php b/module/Core/src/Domain/Resolver/PersistenceDomainResolver.php index 6532a1c3..ca679d96 100644 --- a/module/Core/src/Domain/Resolver/PersistenceDomainResolver.php +++ b/module/Core/src/Domain/Resolver/PersistenceDomainResolver.php @@ -9,8 +9,7 @@ use Shlinkio\Shlink\Core\Entity\Domain; class PersistenceDomainResolver implements DomainResolverInterface { - /** @var EntityManagerInterface */ - private $em; + private EntityManagerInterface $em; public function __construct(EntityManagerInterface $em) { diff --git a/module/Core/src/Entity/Domain.php b/module/Core/src/Entity/Domain.php index 8be40c00..924b50e5 100644 --- a/module/Core/src/Entity/Domain.php +++ b/module/Core/src/Entity/Domain.php @@ -8,8 +8,7 @@ use Shlinkio\Shlink\Common\Entity\AbstractEntity; class Domain extends AbstractEntity { - /** @var string */ - private $authority; + private string $authority; public function __construct(string $authority) { diff --git a/module/Core/src/Entity/ShortUrl.php b/module/Core/src/Entity/ShortUrl.php index 6cf6378a..ef8a3b2f 100644 --- a/module/Core/src/Entity/ShortUrl.php +++ b/module/Core/src/Entity/ShortUrl.php @@ -22,26 +22,18 @@ use function Shlinkio\Shlink\Core\generateRandomShortCode; class ShortUrl extends AbstractEntity { - /** @var string */ - private $longUrl; - /** @var string */ - private $shortCode; - /** @var Chronos */ - private $dateCreated; + private string $longUrl; + private string $shortCode; + private Chronos $dateCreated; /** @var Collection|Visit[] */ - private $visits; + private Collection $visits; /** @var Collection|Tag[] */ - private $tags; - /** @var Chronos|null */ - private $validSince; - /** @var Chronos|null */ - private $validUntil; - /** @var integer|null */ - private $maxVisits; - /** @var Domain|null */ - private $domain; - /** @var bool */ - private $customSlugWasProvided; + private Collection $tags; + private ?Chronos $validSince; + private ?Chronos $validUntil; + private ?int $maxVisits; + private ?Domain $domain; + private bool $customSlugWasProvided; public function __construct( string $longUrl, diff --git a/module/Core/src/Entity/Tag.php b/module/Core/src/Entity/Tag.php index a703ebab..7530b70a 100644 --- a/module/Core/src/Entity/Tag.php +++ b/module/Core/src/Entity/Tag.php @@ -9,8 +9,7 @@ use Shlinkio\Shlink\Common\Entity\AbstractEntity; class Tag extends AbstractEntity implements JsonSerializable { - /** @var string */ - private $name; + private string $name; public function __construct(string $name) { diff --git a/module/Core/src/Entity/Visit.php b/module/Core/src/Entity/Visit.php index b2ce3640..227f32a4 100644 --- a/module/Core/src/Entity/Visit.php +++ b/module/Core/src/Entity/Visit.php @@ -15,18 +15,12 @@ use Shlinkio\Shlink\Core\Visit\Model\VisitLocationInterface; class Visit extends AbstractEntity implements JsonSerializable { - /** @var string */ - private $referer; - /** @var Chronos */ - private $date; - /** @var string|null */ - private $remoteAddr; - /** @var string */ - private $userAgent; - /** @var ShortUrl */ - private $shortUrl; - /** @var VisitLocation */ - private $visitLocation; + private string $referer; + private Chronos $date; + private ?string $remoteAddr; + private string $userAgent; + private ShortUrl $shortUrl; + private ?VisitLocation $visitLocation = null; public function __construct(ShortUrl $shortUrl, Visitor $visitor, ?Chronos $date = null) { diff --git a/module/Core/src/Entity/VisitLocation.php b/module/Core/src/Entity/VisitLocation.php index 9108a719..ebc8829a 100644 --- a/module/Core/src/Entity/VisitLocation.php +++ b/module/Core/src/Entity/VisitLocation.php @@ -10,20 +10,13 @@ use Shlinkio\Shlink\IpGeolocation\Model\Location; class VisitLocation extends AbstractEntity implements VisitLocationInterface { - /** @var string */ - private $countryCode; - /** @var string */ - private $countryName; - /** @var string */ - private $regionName; - /** @var string */ - private $cityName; - /** @var string */ - private $latitude; - /** @var string */ - private $longitude; - /** @var string */ - private $timezone; + private string $countryCode; + private string $countryName; + private string $regionName; + private string $cityName; + private string $latitude; // FIXME Should be float + private string $longitude; // FIXME Should be float + private string $timezone; public function __construct(Location $location) { diff --git a/module/Core/src/ErrorHandler/NotFoundRedirectHandler.php b/module/Core/src/ErrorHandler/NotFoundRedirectHandler.php index f6a03395..54dc9cac 100644 --- a/module/Core/src/ErrorHandler/NotFoundRedirectHandler.php +++ b/module/Core/src/ErrorHandler/NotFoundRedirectHandler.php @@ -18,10 +18,8 @@ use function rtrim; class NotFoundRedirectHandler implements MiddlewareInterface { - /** @var NotFoundRedirectOptions */ - private $redirectOptions; - /** @var string */ - private $shlinkBasePath; + private NotFoundRedirectOptions $redirectOptions; + private string $shlinkBasePath; public function __construct(NotFoundRedirectOptions $redirectOptions, string $shlinkBasePath) { diff --git a/module/Core/src/ErrorHandler/NotFoundTemplateHandler.php b/module/Core/src/ErrorHandler/NotFoundTemplateHandler.php index 7b84043d..69cc8036 100644 --- a/module/Core/src/ErrorHandler/NotFoundTemplateHandler.php +++ b/module/Core/src/ErrorHandler/NotFoundTemplateHandler.php @@ -18,8 +18,7 @@ class NotFoundTemplateHandler implements RequestHandlerInterface public const NOT_FOUND_TEMPLATE = 'ShlinkCore::error/404'; public const INVALID_SHORT_CODE_TEMPLATE = 'ShlinkCore::invalid-short-code'; - /** @var TemplateRendererInterface */ - private $renderer; + private TemplateRendererInterface $renderer; public function __construct(TemplateRendererInterface $renderer) { diff --git a/module/Core/src/EventDispatcher/LocateShortUrlVisit.php b/module/Core/src/EventDispatcher/LocateShortUrlVisit.php index 4d767272..0dd6b56f 100644 --- a/module/Core/src/EventDispatcher/LocateShortUrlVisit.php +++ b/module/Core/src/EventDispatcher/LocateShortUrlVisit.php @@ -19,16 +19,11 @@ use function sprintf; class LocateShortUrlVisit { - /** @var IpLocationResolverInterface */ - private $ipLocationResolver; - /** @var EntityManagerInterface */ - private $em; - /** @var LoggerInterface */ - private $logger; - /** @var GeolocationDbUpdaterInterface */ - private $dbUpdater; - /** @var EventDispatcherInterface */ - private $eventDispatcher; + private IpLocationResolverInterface $ipLocationResolver; + private EntityManagerInterface $em; + private LoggerInterface $logger; + private GeolocationDbUpdaterInterface $dbUpdater; + private EventDispatcherInterface $eventDispatcher; public function __construct( IpLocationResolverInterface $ipLocationResolver, diff --git a/module/Core/src/EventDispatcher/NotifyVisitToWebHooks.php b/module/Core/src/EventDispatcher/NotifyVisitToWebHooks.php index d99defb5..7f901d33 100644 --- a/module/Core/src/EventDispatcher/NotifyVisitToWebHooks.php +++ b/module/Core/src/EventDispatcher/NotifyVisitToWebHooks.php @@ -22,18 +22,13 @@ use function GuzzleHttp\Promise\settle; class NotifyVisitToWebHooks { - /** @var ClientInterface */ - private $httpClient; - /** @var EntityManagerInterface */ - private $em; - /** @var LoggerInterface */ - private $logger; - /** @var array */ - private $webhooks; - /** @var ShortUrlDataTransformer */ - private $transformer; - /** @var AppOptions */ - private $appOptions; + private ClientInterface $httpClient; + private EntityManagerInterface $em; + private LoggerInterface $logger; + /** @var string[] */ + private array $webhooks; + private ShortUrlDataTransformer $transformer; + private AppOptions $appOptions; public function __construct( ClientInterface $httpClient, diff --git a/module/Core/src/EventDispatcher/ShortUrlVisited.php b/module/Core/src/EventDispatcher/ShortUrlVisited.php index d12cdaf7..1f0b5b5c 100644 --- a/module/Core/src/EventDispatcher/ShortUrlVisited.php +++ b/module/Core/src/EventDispatcher/ShortUrlVisited.php @@ -8,8 +8,7 @@ use JsonSerializable; final class ShortUrlVisited implements JsonSerializable { - /** @var string */ - private $visitId; + private string $visitId; public function __construct(string $visitId) { diff --git a/module/Core/src/EventDispatcher/VisitLocated.php b/module/Core/src/EventDispatcher/VisitLocated.php index 4873ffa7..0e1c1176 100644 --- a/module/Core/src/EventDispatcher/VisitLocated.php +++ b/module/Core/src/EventDispatcher/VisitLocated.php @@ -8,8 +8,7 @@ use JsonSerializable; final class VisitLocated implements JsonSerializable { - /** @var string */ - private $visitId; + private string $visitId; public function __construct(string $visitId) { diff --git a/module/Core/src/Exception/IpCannotBeLocatedException.php b/module/Core/src/Exception/IpCannotBeLocatedException.php index 8c0b220f..b1ba731c 100644 --- a/module/Core/src/Exception/IpCannotBeLocatedException.php +++ b/module/Core/src/Exception/IpCannotBeLocatedException.php @@ -8,32 +8,24 @@ use Throwable; class IpCannotBeLocatedException extends RuntimeException { - /** @var bool */ - private $isNonLocatableAddress; - - public function __construct( - bool $isNonLocatableAddress, - string $message, - int $code = 0, - ?Throwable $previous = null - ) { - $this->isNonLocatableAddress = $isNonLocatableAddress; - parent::__construct($message, $code, $previous); - } + private bool $isNonLocatableAddress = true; public static function forEmptyAddress(): self { - return new self(true, 'Ignored visit with no IP address'); + return new self('Ignored visit with no IP address'); } public static function forLocalhost(): self { - return new self(true, 'Ignored localhost address'); + return new self('Ignored localhost address'); } public static function forError(Throwable $e): self { - return new self(false, 'An error occurred while locating IP', $e->getCode(), $e); + $e = new self('An error occurred while locating IP', $e->getCode(), $e); + $e->isNonLocatableAddress = false; + + return $e; } /** diff --git a/module/Core/src/Exception/ValidationException.php b/module/Core/src/Exception/ValidationException.php index abceec91..c2308f06 100644 --- a/module/Core/src/Exception/ValidationException.php +++ b/module/Core/src/Exception/ValidationException.php @@ -25,8 +25,7 @@ class ValidationException extends InvalidArgumentException implements ProblemDet private const TITLE = 'Invalid data'; private const TYPE = 'INVALID_ARGUMENT'; - /** @var array */ - private $invalidElements; + private array $invalidElements; public static function fromInputFilter(InputFilterInterface $inputFilter, ?Throwable $prev = null): self { diff --git a/module/Core/src/Middleware/QrCodeCacheMiddleware.php b/module/Core/src/Middleware/QrCodeCacheMiddleware.php index 2036d687..14554e8c 100644 --- a/module/Core/src/Middleware/QrCodeCacheMiddleware.php +++ b/module/Core/src/Middleware/QrCodeCacheMiddleware.php @@ -13,8 +13,7 @@ use Zend\Diactoros\Response as DiactResp; class QrCodeCacheMiddleware implements MiddlewareInterface { - /** @var Cache */ - private $cache; + private Cache $cache; public function __construct(Cache $cache) { diff --git a/module/Core/src/Model/CreateShortUrlData.php b/module/Core/src/Model/CreateShortUrlData.php index 125f379a..3bd2cb7f 100644 --- a/module/Core/src/Model/CreateShortUrlData.php +++ b/module/Core/src/Model/CreateShortUrlData.php @@ -8,12 +8,9 @@ use Psr\Http\Message\UriInterface; final class CreateShortUrlData { - /** @var UriInterface */ - private $longUrl; - /** @var array */ - private $tags; - /** @var ShortUrlMeta */ - private $meta; + private UriInterface $longUrl; + private array $tags; + private ShortUrlMeta $meta; public function __construct( UriInterface $longUrl, diff --git a/module/Core/src/Model/ShortUrlMeta.php b/module/Core/src/Model/ShortUrlMeta.php index 24e770c6..1f8b0a7d 100644 --- a/module/Core/src/Model/ShortUrlMeta.php +++ b/module/Core/src/Model/ShortUrlMeta.php @@ -11,18 +11,12 @@ use Shlinkio\Shlink\Core\Validation\ShortUrlMetaInputFilter; final class ShortUrlMeta { - /** @var Chronos|null */ - private $validSince; - /** @var Chronos|null */ - private $validUntil; - /** @var string|null */ - private $customSlug; - /** @var int|null */ - private $maxVisits; - /** @var bool|null */ - private $findIfExists; - /** @var string|null */ - private $domain; + private ?Chronos $validSince = null; + private ?Chronos $validUntil = null; + private ?string $customSlug = null; + private ?int $maxVisits = null; + private ?bool $findIfExists = null; + private ?string $domain = null; // Force named constructors private function __construct() @@ -90,8 +84,8 @@ final class ShortUrlMeta $this->validSince = $this->parseDateField($inputFilter->getValue(ShortUrlMetaInputFilter::VALID_SINCE)); $this->validUntil = $this->parseDateField($inputFilter->getValue(ShortUrlMetaInputFilter::VALID_UNTIL)); $this->customSlug = $inputFilter->getValue(ShortUrlMetaInputFilter::CUSTOM_SLUG); - $this->maxVisits = $inputFilter->getValue(ShortUrlMetaInputFilter::MAX_VISITS); - $this->maxVisits = $this->maxVisits !== null ? (int) $this->maxVisits : null; + $maxVisits = $inputFilter->getValue(ShortUrlMetaInputFilter::MAX_VISITS); + $this->maxVisits = $maxVisits !== null ? (int) $maxVisits : null; $this->findIfExists = $inputFilter->getValue(ShortUrlMetaInputFilter::FIND_IF_EXISTS); $this->domain = $inputFilter->getValue(ShortUrlMetaInputFilter::DOMAIN); } diff --git a/module/Core/src/Model/Visitor.php b/module/Core/src/Model/Visitor.php index 584e8956..de9bb791 100644 --- a/module/Core/src/Model/Visitor.php +++ b/module/Core/src/Model/Visitor.php @@ -15,12 +15,9 @@ final class Visitor public const REFERER_MAX_LENGTH = 1024; public const REMOTE_ADDRESS_MAX_LENGTH = 256; - /** @var string */ - private $userAgent; - /** @var string */ - private $referer; - /** @var string|null */ - private $remoteAddress; + private string $userAgent; + private string $referer; + private ?string $remoteAddress; public function __construct(string $userAgent, string $referer, ?string $remoteAddress) { diff --git a/module/Core/src/Model/VisitsParams.php b/module/Core/src/Model/VisitsParams.php index f5af1c67..ffc13dc7 100644 --- a/module/Core/src/Model/VisitsParams.php +++ b/module/Core/src/Model/VisitsParams.php @@ -12,12 +12,9 @@ final class VisitsParams private const FIRST_PAGE = 1; private const ALL_ITEMS = -1; - /** @var null|DateRange */ - private $dateRange; - /** @var int */ - private $page; - /** @var int */ - private $itemsPerPage; + private ?DateRange $dateRange; + private int $page; + private int $itemsPerPage; public function __construct(?DateRange $dateRange = null, int $page = self::FIRST_PAGE, ?int $itemsPerPage = null) { diff --git a/module/Core/src/Options/AppOptions.php b/module/Core/src/Options/AppOptions.php index a26998d4..36b6d58b 100644 --- a/module/Core/src/Options/AppOptions.php +++ b/module/Core/src/Options/AppOptions.php @@ -13,17 +13,11 @@ class AppOptions extends AbstractOptions { use StringUtilsTrait; - /** @var string */ - private $name = ''; - /** @var string */ - private $version = '1.0'; - /** - * @var string - * @deprecated - */ - private $secretKey = ''; - /** @var string|null */ - private $disableTrackParam; + private string $name = ''; + private string $version = '1.0'; + /** @deprecated */ + private string $secretKey = ''; + private ?string $disableTrackParam = null; public function getName(): string { diff --git a/module/Core/src/Options/NotFoundRedirectOptions.php b/module/Core/src/Options/NotFoundRedirectOptions.php index 0165f8fc..611c144c 100644 --- a/module/Core/src/Options/NotFoundRedirectOptions.php +++ b/module/Core/src/Options/NotFoundRedirectOptions.php @@ -8,12 +8,9 @@ use Zend\Stdlib\AbstractOptions; class NotFoundRedirectOptions extends AbstractOptions { - /** @var string|null */ - private $invalidShortUrl; - /** @var string|null */ - private $regular404; - /** @var string|null */ - private $baseUrl; + private ?string $invalidShortUrl = null; + private ?string $regular404 = null; + private ?string $baseUrl = null; public function getInvalidShortUrlRedirect(): ?string { diff --git a/module/Core/src/Paginator/Adapter/ShortUrlRepositoryAdapter.php b/module/Core/src/Paginator/Adapter/ShortUrlRepositoryAdapter.php index de382d17..2534e3f4 100644 --- a/module/Core/src/Paginator/Adapter/ShortUrlRepositoryAdapter.php +++ b/module/Core/src/Paginator/Adapter/ShortUrlRepositoryAdapter.php @@ -15,16 +15,12 @@ class ShortUrlRepositoryAdapter implements AdapterInterface { public const ITEMS_PER_PAGE = 10; - /** @var ShortUrlRepositoryInterface */ - private $repository; - /** @var null|string */ - private $searchTerm; + private ShortUrlRepositoryInterface $repository; + private ?string $searchTerm; /** @var null|array|string */ private $orderBy; - /** @var array */ - private $tags; - /** @var DateRange|null */ - private $dateRange; + private array $tags; + private ?DateRange $dateRange; public function __construct( ShortUrlRepositoryInterface $repository, diff --git a/module/Core/src/Paginator/Adapter/VisitsPaginatorAdapter.php b/module/Core/src/Paginator/Adapter/VisitsPaginatorAdapter.php index cffa2f3d..83aff355 100644 --- a/module/Core/src/Paginator/Adapter/VisitsPaginatorAdapter.php +++ b/module/Core/src/Paginator/Adapter/VisitsPaginatorAdapter.php @@ -10,12 +10,9 @@ use Zend\Paginator\Adapter\AdapterInterface; class VisitsPaginatorAdapter implements AdapterInterface { - /** @var VisitRepositoryInterface */ - private $visitRepository; - /** @var string */ - private $shortCode; - /** @var VisitsParams */ - private $params; + private VisitRepositoryInterface $visitRepository; + private string $shortCode; + private VisitsParams $params; public function __construct(VisitRepositoryInterface $visitRepository, string $shortCode, VisitsParams $params) { diff --git a/module/Core/src/Service/ShortUrl/DeleteShortUrlService.php b/module/Core/src/Service/ShortUrl/DeleteShortUrlService.php index c7cfb9c4..b6d574ee 100644 --- a/module/Core/src/Service/ShortUrl/DeleteShortUrlService.php +++ b/module/Core/src/Service/ShortUrl/DeleteShortUrlService.php @@ -13,10 +13,8 @@ class DeleteShortUrlService implements DeleteShortUrlServiceInterface { use FindShortCodeTrait; - /** @var EntityManagerInterface */ - private $em; - /** @var DeleteShortUrlsOptions */ - private $deleteShortUrlsOptions; + private EntityManagerInterface $em; + private DeleteShortUrlsOptions $deleteShortUrlsOptions; public function __construct(EntityManagerInterface $em, DeleteShortUrlsOptions $deleteShortUrlsOptions) { diff --git a/module/Core/src/Service/ShortUrlService.php b/module/Core/src/Service/ShortUrlService.php index 15a3b432..65dc57bd 100644 --- a/module/Core/src/Service/ShortUrlService.php +++ b/module/Core/src/Service/ShortUrlService.php @@ -20,8 +20,7 @@ class ShortUrlService implements ShortUrlServiceInterface use FindShortCodeTrait; use TagManagerTrait; - /** @var ORM\EntityManagerInterface */ - private $em; + private ORM\EntityManagerInterface $em; public function __construct(ORM\EntityManagerInterface $em) { diff --git a/module/Core/src/Service/Tag/TagService.php b/module/Core/src/Service/Tag/TagService.php index 672f0b05..b95ddf82 100644 --- a/module/Core/src/Service/Tag/TagService.php +++ b/module/Core/src/Service/Tag/TagService.php @@ -16,8 +16,7 @@ class TagService implements TagServiceInterface { use TagManagerTrait; - /** @var ORM\EntityManagerInterface */ - private $em; + private ORM\EntityManagerInterface $em; public function __construct(ORM\EntityManagerInterface $em) { diff --git a/module/Core/src/Service/UrlShortener.php b/module/Core/src/Service/UrlShortener.php index 70112bd7..be61d15b 100644 --- a/module/Core/src/Service/UrlShortener.php +++ b/module/Core/src/Service/UrlShortener.php @@ -24,12 +24,9 @@ class UrlShortener implements UrlShortenerInterface { use TagManagerTrait; - /** @var EntityManagerInterface */ - private $em; - /** @var UrlShortenerOptions */ - private $options; - /** @var UrlValidatorInterface */ - private $urlValidator; + private EntityManagerInterface $em; + private UrlShortenerOptions $options; + private UrlValidatorInterface $urlValidator; public function __construct( UrlValidatorInterface $urlValidator, diff --git a/module/Core/src/Service/VisitService.php b/module/Core/src/Service/VisitService.php index 582a10fe..20a30f4c 100644 --- a/module/Core/src/Service/VisitService.php +++ b/module/Core/src/Service/VisitService.php @@ -13,8 +13,7 @@ use Shlinkio\Shlink\IpGeolocation\Model\Location; class VisitService implements VisitServiceInterface { - /** @var EntityManagerInterface */ - private $em; + private EntityManagerInterface $em; public function __construct(EntityManagerInterface $em) { diff --git a/module/Core/src/Service/VisitsTracker.php b/module/Core/src/Service/VisitsTracker.php index 612ad4ee..f3c8c448 100644 --- a/module/Core/src/Service/VisitsTracker.php +++ b/module/Core/src/Service/VisitsTracker.php @@ -18,10 +18,8 @@ use Zend\Paginator\Paginator; class VisitsTracker implements VisitsTrackerInterface { - /** @var ORM\EntityManagerInterface */ - private $em; - /** @var EventDispatcherInterface */ - private $eventDispatcher; + private ORM\EntityManagerInterface $em; + private EventDispatcherInterface $eventDispatcher; public function __construct(ORM\EntityManagerInterface $em, EventDispatcherInterface $eventDispatcher) { diff --git a/module/Core/src/Transformer/ShortUrlDataTransformer.php b/module/Core/src/Transformer/ShortUrlDataTransformer.php index 348ff0d5..f734cf01 100644 --- a/module/Core/src/Transformer/ShortUrlDataTransformer.php +++ b/module/Core/src/Transformer/ShortUrlDataTransformer.php @@ -12,8 +12,7 @@ use function Functional\invoke_if; class ShortUrlDataTransformer implements DataTransformerInterface { - /** @var array */ - private $domainConfig; + private array $domainConfig; public function __construct(array $domainConfig) { diff --git a/module/Core/src/Util/UrlValidator.php b/module/Core/src/Util/UrlValidator.php index db7c6c2a..dca037cd 100644 --- a/module/Core/src/Util/UrlValidator.php +++ b/module/Core/src/Util/UrlValidator.php @@ -14,8 +14,7 @@ class UrlValidator implements UrlValidatorInterface, RequestMethodInterface { private const MAX_REDIRECTS = 15; - /** @var ClientInterface */ - private $httpClient; + private ClientInterface $httpClient; public function __construct(ClientInterface $httpClient) { diff --git a/module/Core/test-db/Repository/ShortUrlRepositoryTest.php b/module/Core/test-db/Repository/ShortUrlRepositoryTest.php index 2006623a..9cd92dc0 100644 --- a/module/Core/test-db/Repository/ShortUrlRepositoryTest.php +++ b/module/Core/test-db/Repository/ShortUrlRepositoryTest.php @@ -28,8 +28,7 @@ class ShortUrlRepositoryTest extends DatabaseTestCase Domain::class, ]; - /** @var ShortUrlRepository */ - private $repo; + private ShortUrlRepository $repo; public function setUp(): void { diff --git a/module/Core/test-db/Repository/TagRepositoryTest.php b/module/Core/test-db/Repository/TagRepositoryTest.php index 6e4ae404..9c5ab574 100644 --- a/module/Core/test-db/Repository/TagRepositoryTest.php +++ b/module/Core/test-db/Repository/TagRepositoryTest.php @@ -14,8 +14,7 @@ class TagRepositoryTest extends DatabaseTestCase Tag::class, ]; - /** @var TagRepository */ - private $repo; + private TagRepository $repo; protected function setUp(): void { diff --git a/module/Core/test-db/Repository/VisitRepositoryTest.php b/module/Core/test-db/Repository/VisitRepositoryTest.php index 23fa4c7a..51ffbc3c 100644 --- a/module/Core/test-db/Repository/VisitRepositoryTest.php +++ b/module/Core/test-db/Repository/VisitRepositoryTest.php @@ -26,8 +26,7 @@ class VisitRepositoryTest extends DatabaseTestCase ShortUrl::class, ]; - /** @var VisitRepository */ - private $repo; + private VisitRepository $repo; protected function setUp(): void { diff --git a/module/Core/test/Action/PixelActionTest.php b/module/Core/test/Action/PixelActionTest.php index df39f1df..682d5e17 100644 --- a/module/Core/test/Action/PixelActionTest.php +++ b/module/Core/test/Action/PixelActionTest.php @@ -10,7 +10,6 @@ use Prophecy\Prophecy\ObjectProphecy; use Psr\Http\Server\RequestHandlerInterface; use Shlinkio\Shlink\Common\Response\PixelResponse; use Shlinkio\Shlink\Core\Action\PixelAction; -use Shlinkio\Shlink\Core\Action\RedirectAction; use Shlinkio\Shlink\Core\Entity\ShortUrl; use Shlinkio\Shlink\Core\Options\AppOptions; use Shlinkio\Shlink\Core\Service\UrlShortener; @@ -19,12 +18,9 @@ use Zend\Diactoros\ServerRequest; class PixelActionTest extends TestCase { - /** @var RedirectAction */ - private $action; - /** @var ObjectProphecy */ - private $urlShortener; - /** @var ObjectProphecy */ - private $visitTracker; + private PixelAction $action; + private ObjectProphecy $urlShortener; + private ObjectProphecy $visitTracker; public function setUp(): void { diff --git a/module/Core/test/Action/PreviewActionTest.php b/module/Core/test/Action/PreviewActionTest.php index e2cb089c..0725c957 100644 --- a/module/Core/test/Action/PreviewActionTest.php +++ b/module/Core/test/Action/PreviewActionTest.php @@ -21,6 +21,7 @@ use function filesize; use const FILEINFO_MIME; +/** @deprecated */ class PreviewActionTest extends TestCase { /** @var PreviewAction */ diff --git a/module/Core/test/Action/QrCodeActionTest.php b/module/Core/test/Action/QrCodeActionTest.php index 6327ad69..0f5a0c7d 100644 --- a/module/Core/test/Action/QrCodeActionTest.php +++ b/module/Core/test/Action/QrCodeActionTest.php @@ -19,10 +19,8 @@ use Zend\Expressive\Router\RouterInterface; class QrCodeActionTest extends TestCase { - /** @var QrCodeAction */ - private $action; - /** @var ObjectProphecy */ - private $urlShortener; + private QrCodeAction $action; + private ObjectProphecy $urlShortener; public function setUp(): void { diff --git a/module/Core/test/Action/RedirectActionTest.php b/module/Core/test/Action/RedirectActionTest.php index 55342cb5..812857d4 100644 --- a/module/Core/test/Action/RedirectActionTest.php +++ b/module/Core/test/Action/RedirectActionTest.php @@ -21,12 +21,9 @@ use function array_key_exists; class RedirectActionTest extends TestCase { - /** @var RedirectAction */ - private $action; - /** @var ObjectProphecy */ - private $urlShortener; - /** @var ObjectProphecy */ - private $visitTracker; + private RedirectAction $action; + private ObjectProphecy $urlShortener; + private ObjectProphecy $visitTracker; public function setUp(): void { diff --git a/module/Core/test/ConfigProviderTest.php b/module/Core/test/ConfigProviderTest.php index f38fe6bd..5077c61e 100644 --- a/module/Core/test/ConfigProviderTest.php +++ b/module/Core/test/ConfigProviderTest.php @@ -9,8 +9,7 @@ use Shlinkio\Shlink\Core\ConfigProvider; class ConfigProviderTest extends TestCase { - /** @var ConfigProvider */ - private $configProvider; + private ConfigProvider $configProvider; public function setUp(): void { diff --git a/module/Core/test/Exception/IpCannotBeLocatedExceptionTest.php b/module/Core/test/Exception/IpCannotBeLocatedExceptionTest.php index 47246e99..84ee433c 100644 --- a/module/Core/test/Exception/IpCannotBeLocatedExceptionTest.php +++ b/module/Core/test/Exception/IpCannotBeLocatedExceptionTest.php @@ -11,10 +11,6 @@ use Shlinkio\Shlink\Core\Exception\IpCannotBeLocatedException; use Shlinkio\Shlink\Core\Exception\RuntimeException; use Throwable; -use function count; -use function func_get_args; -use function random_int; - class IpCannotBeLocatedExceptionTest extends TestCase { /** @test */ @@ -59,39 +55,4 @@ class IpCannotBeLocatedExceptionTest extends TestCase yield 'Runtime exception with negative code' => [new RuntimeException('Something went wrong', -50)]; yield 'Logic exception with default code' => [new LogicException('Conditions unmet')]; } - - /** - * @test - * @dataProvider provideConstructorArgs - */ - public function constructorInitializesException(): void - { - $args = func_get_args(); - [$isNonLocatableAddress, $message] = $args; - $code = $args[2] ?? 0; - $prev = $args[3] ?? null; - - switch (count($args)) { - case 2: - $e = new IpCannotBeLocatedException($isNonLocatableAddress, $message); - break; - case 3: - $e = new IpCannotBeLocatedException($isNonLocatableAddress, $message, $code); - break; - default: - $e = new IpCannotBeLocatedException($isNonLocatableAddress, $message, $code, $prev); - } - - $this->assertEquals($isNonLocatableAddress, $e->isNonLocatableAddress()); - $this->assertEquals($message, $e->getMessage()); - $this->assertEquals($code, $e->getCode()); - $this->assertEquals($prev, $e->getPrevious()); - } - - public function provideConstructorArgs(): iterable - { - yield 'without default args' => [true, 'Message']; - yield 'without prev' => [true, 'Message', random_int(1, 100)]; - yield 'without all args' => [false, 'Foo', random_int(1, 100), new RuntimeException('Foo')]; - } } diff --git a/module/Core/test/Service/VisitServiceTest.php b/module/Core/test/Service/VisitServiceTest.php index 3e8d1627..e7983254 100644 --- a/module/Core/test/Service/VisitServiceTest.php +++ b/module/Core/test/Service/VisitServiceTest.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace ShlinkioTest\Shlink\Core\Service; use Doctrine\ORM\EntityManager; +use Exception; use PHPUnit\Framework\TestCase; use Prophecy\Argument; use Prophecy\Prophecy\ObjectProphecy; @@ -94,7 +95,9 @@ class VisitServiceTest extends TestCase }); $this->visitService->locateUnlocatedVisits(function () use ($isNonLocatableAddress) { - throw new IpCannotBeLocatedException($isNonLocatableAddress, 'Cannot be located'); + throw $isNonLocatableAddress + ? new IpCannotBeLocatedException('Cannot be located') + : IpCannotBeLocatedException::forError(new Exception('')); }); $findUnlocatedVisits->shouldHaveBeenCalledOnce();