From 95ea64980b1750d1ce3efde12c7ac154095574a8 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sat, 17 Feb 2024 10:46:29 +0100 Subject: [PATCH] Update to Symfony 7 --- CHANGELOG.md | 1 + composer.json | 16 ++++++++-------- module/CLI/src/Command/Api/DisableKeyCommand.php | 2 +- .../CLI/src/Command/Api/GenerateKeyCommand.php | 2 +- .../CLI/src/Command/Api/InitialApiKeyCommand.php | 2 +- module/CLI/src/Command/Api/ListKeysCommand.php | 2 +- .../Command/Domain/DomainRedirectsCommand.php | 2 +- .../src/Command/Domain/ListDomainsCommand.php | 2 +- .../Command/ShortUrl/CreateShortUrlCommand.php | 2 +- .../Command/ShortUrl/DeleteShortUrlCommand.php | 2 +- .../ShortUrl/DeleteShortUrlVisitsCommand.php | 2 +- .../Command/ShortUrl/ListShortUrlsCommand.php | 2 +- .../src/Command/ShortUrl/ResolveUrlCommand.php | 2 +- module/CLI/src/Command/Tag/DeleteTagsCommand.php | 2 +- module/CLI/src/Command/Tag/ListTagsCommand.php | 2 +- module/CLI/src/Command/Tag/RenameTagCommand.php | 2 +- .../src/Command/Util/AbstractLockedCommand.php | 2 +- .../Visit/AbstractDeleteVisitsCommand.php | 4 ++-- .../Command/Visit/AbstractVisitsListCommand.php | 2 +- .../Command/Visit/DeleteOrphanVisitsCommand.php | 2 +- .../Command/Visit/DownloadGeoLiteDbCommand.php | 2 +- .../Command/Db/CreateDatabaseCommandTest.php | 4 ++-- .../Command/Db/MigrateDatabaseCommandTest.php | 4 ++-- .../Command/Visit/LocateVisitsCommandTest.php | 2 +- .../test/GeoLite/GeolocationDbUpdaterTest.php | 2 +- 25 files changed, 35 insertions(+), 34 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 237fb29c..de9d6b1b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this * [#1909](https://github.com/shlinkio/shlink/issues/1909) Update docker image to PHP 8.3. * [#1786](https://github.com/shlinkio/shlink/issues/1786) Run API tests with RoadRunner by default. * [#2008](https://github.com/shlinkio/shlink/issues/2008) Update to Doctrine ORM 3.0. +* [#2010](https://github.com/shlinkio/shlink/issues/2010) Update to Symfony 7.0 components. ### Deprecated * *Nothing* diff --git a/composer.json b/composer.json index c2d30bda..9d646be0 100644 --- a/composer.json +++ b/composer.json @@ -45,19 +45,19 @@ "shlinkio/shlink-common": "dev-main#178b332 as 6.0", "shlinkio/shlink-config": "dev-main#6b287b3 as 2.6", "shlinkio/shlink-event-dispatcher": "dev-main#46f5e21 as 4.0", - "shlinkio/shlink-importer": "^5.2.1", + "shlinkio/shlink-importer": "dev-main#f0a1f1d as 5.3", "shlinkio/shlink-installer": "dev-develop#2dee7db as 9.0", - "shlinkio/shlink-ip-geolocation": "^3.4", + "shlinkio/shlink-ip-geolocation": "dev-main#c123a52 as 3.5", "shlinkio/shlink-json": "^1.1", "spiral/roadrunner": "^2023.3", "spiral/roadrunner-cli": "^2.6", "spiral/roadrunner-http": "^3.3", "spiral/roadrunner-jobs": "^4.3", - "symfony/console": "^6.4", - "symfony/filesystem": "^6.4", - "symfony/lock": "^6.4", - "symfony/process": "^6.4", - "symfony/string": "^6.4" + "symfony/console": "^7.0", + "symfony/filesystem": "^7.0", + "symfony/lock": "^7.0", + "symfony/process": "^7.0", + "symfony/string": "^7.0" }, "require-dev": { "devizzent/cebe-php-openapi": "^1.0.1", @@ -72,7 +72,7 @@ "roave/security-advisories": "dev-master", "shlinkio/php-coding-standard": "~2.3.0", "shlinkio/shlink-test-utils": "^3.11", - "symfony/var-dumper": "^6.4", + "symfony/var-dumper": "^7.0", "veewee/composer-run-parallel": "^1.3" }, "conflict": { diff --git a/module/CLI/src/Command/Api/DisableKeyCommand.php b/module/CLI/src/Command/Api/DisableKeyCommand.php index 4844121e..3da85e9e 100644 --- a/module/CLI/src/Command/Api/DisableKeyCommand.php +++ b/module/CLI/src/Command/Api/DisableKeyCommand.php @@ -31,7 +31,7 @@ class DisableKeyCommand extends Command ->addArgument('apiKey', InputArgument::REQUIRED, 'The API key to disable'); } - protected function execute(InputInterface $input, OutputInterface $output): ?int + protected function execute(InputInterface $input, OutputInterface $output): int { $apiKey = $input->getArgument('apiKey'); $io = new SymfonyStyle($input, $output); diff --git a/module/CLI/src/Command/Api/GenerateKeyCommand.php b/module/CLI/src/Command/Api/GenerateKeyCommand.php index 1fe2f996..0a35bef7 100644 --- a/module/CLI/src/Command/Api/GenerateKeyCommand.php +++ b/module/CLI/src/Command/Api/GenerateKeyCommand.php @@ -98,7 +98,7 @@ class GenerateKeyCommand extends Command ->setHelp($help); } - protected function execute(InputInterface $input, OutputInterface $output): ?int + protected function execute(InputInterface $input, OutputInterface $output): int { $expirationDate = $input->getOption('expiration-date'); diff --git a/module/CLI/src/Command/Api/InitialApiKeyCommand.php b/module/CLI/src/Command/Api/InitialApiKeyCommand.php index 1f5a1794..0f4945a9 100644 --- a/module/CLI/src/Command/Api/InitialApiKeyCommand.php +++ b/module/CLI/src/Command/Api/InitialApiKeyCommand.php @@ -29,7 +29,7 @@ class InitialApiKeyCommand extends Command ->addArgument('apiKey', InputArgument::REQUIRED, 'The initial API to create'); } - protected function execute(InputInterface $input, OutputInterface $output): ?int + protected function execute(InputInterface $input, OutputInterface $output): int { $key = $input->getArgument('apiKey'); $result = $this->apiKeyService->createInitial($key); diff --git a/module/CLI/src/Command/Api/ListKeysCommand.php b/module/CLI/src/Command/Api/ListKeysCommand.php index b55dcd7d..fab02087 100644 --- a/module/CLI/src/Command/Api/ListKeysCommand.php +++ b/module/CLI/src/Command/Api/ListKeysCommand.php @@ -45,7 +45,7 @@ class ListKeysCommand extends Command ); } - protected function execute(InputInterface $input, OutputInterface $output): ?int + protected function execute(InputInterface $input, OutputInterface $output): int { $enabledOnly = $input->getOption('enabled-only'); diff --git a/module/CLI/src/Command/Domain/DomainRedirectsCommand.php b/module/CLI/src/Command/Domain/DomainRedirectsCommand.php index bf08e7f3..c2e5e60d 100644 --- a/module/CLI/src/Command/Domain/DomainRedirectsCommand.php +++ b/module/CLI/src/Command/Domain/DomainRedirectsCommand.php @@ -68,7 +68,7 @@ class DomainRedirectsCommand extends Command $input->setArgument('domain', str_contains($selectedOption, 'New domain') ? $askNewDomain() : $selectedOption); } - protected function execute(InputInterface $input, OutputInterface $output): ?int + protected function execute(InputInterface $input, OutputInterface $output): int { $io = new SymfonyStyle($input, $output); $domainAuthority = $input->getArgument('domain'); diff --git a/module/CLI/src/Command/Domain/ListDomainsCommand.php b/module/CLI/src/Command/Domain/ListDomainsCommand.php index 50107292..7e6b8cc3 100644 --- a/module/CLI/src/Command/Domain/ListDomainsCommand.php +++ b/module/CLI/src/Command/Domain/ListDomainsCommand.php @@ -38,7 +38,7 @@ class ListDomainsCommand extends Command ); } - protected function execute(InputInterface $input, OutputInterface $output): ?int + protected function execute(InputInterface $input, OutputInterface $output): int { $domains = $this->domainService->listDomains(); $showRedirects = $input->getOption('show-redirects'); diff --git a/module/CLI/src/Command/ShortUrl/CreateShortUrlCommand.php b/module/CLI/src/Command/ShortUrl/CreateShortUrlCommand.php index 64418aa6..3377e649 100644 --- a/module/CLI/src/Command/ShortUrl/CreateShortUrlCommand.php +++ b/module/CLI/src/Command/ShortUrl/CreateShortUrlCommand.php @@ -134,7 +134,7 @@ class CreateShortUrlCommand extends Command } } - protected function execute(InputInterface $input, OutputInterface $output): ?int + protected function execute(InputInterface $input, OutputInterface $output): int { $io = $this->getIO($input, $output); $longUrl = $input->getArgument('longUrl'); diff --git a/module/CLI/src/Command/ShortUrl/DeleteShortUrlCommand.php b/module/CLI/src/Command/ShortUrl/DeleteShortUrlCommand.php index 11cfa270..8196bbfe 100644 --- a/module/CLI/src/Command/ShortUrl/DeleteShortUrlCommand.php +++ b/module/CLI/src/Command/ShortUrl/DeleteShortUrlCommand.php @@ -47,7 +47,7 @@ class DeleteShortUrlCommand extends Command ); } - protected function execute(InputInterface $input, OutputInterface $output): ?int + protected function execute(InputInterface $input, OutputInterface $output): int { $io = new SymfonyStyle($input, $output); $identifier = ShortUrlIdentifier::fromCli($input); diff --git a/module/CLI/src/Command/ShortUrl/DeleteShortUrlVisitsCommand.php b/module/CLI/src/Command/ShortUrl/DeleteShortUrlVisitsCommand.php index 6cd04bfe..5d122ea7 100644 --- a/module/CLI/src/Command/ShortUrl/DeleteShortUrlVisitsCommand.php +++ b/module/CLI/src/Command/ShortUrl/DeleteShortUrlVisitsCommand.php @@ -43,7 +43,7 @@ class DeleteShortUrlVisitsCommand extends AbstractDeleteVisitsCommand ); } - protected function doExecute(InputInterface $input, SymfonyStyle $io): ?int + protected function doExecute(InputInterface $input, SymfonyStyle $io): int { $identifier = ShortUrlIdentifier::fromCli($input); try { diff --git a/module/CLI/src/Command/ShortUrl/ListShortUrlsCommand.php b/module/CLI/src/Command/ShortUrl/ListShortUrlsCommand.php index 297c435e..a318e6e4 100644 --- a/module/CLI/src/Command/ShortUrl/ListShortUrlsCommand.php +++ b/module/CLI/src/Command/ShortUrl/ListShortUrlsCommand.php @@ -129,7 +129,7 @@ class ListShortUrlsCommand extends Command ); } - protected function execute(InputInterface $input, OutputInterface $output): ?int + protected function execute(InputInterface $input, OutputInterface $output): int { $io = new SymfonyStyle($input, $output); diff --git a/module/CLI/src/Command/ShortUrl/ResolveUrlCommand.php b/module/CLI/src/Command/ShortUrl/ResolveUrlCommand.php index aec0a843..d41d292e 100644 --- a/module/CLI/src/Command/ShortUrl/ResolveUrlCommand.php +++ b/module/CLI/src/Command/ShortUrl/ResolveUrlCommand.php @@ -49,7 +49,7 @@ class ResolveUrlCommand extends Command } } - protected function execute(InputInterface $input, OutputInterface $output): ?int + protected function execute(InputInterface $input, OutputInterface $output): int { $io = new SymfonyStyle($input, $output); diff --git a/module/CLI/src/Command/Tag/DeleteTagsCommand.php b/module/CLI/src/Command/Tag/DeleteTagsCommand.php index 151c5892..cf05f1b5 100644 --- a/module/CLI/src/Command/Tag/DeleteTagsCommand.php +++ b/module/CLI/src/Command/Tag/DeleteTagsCommand.php @@ -34,7 +34,7 @@ class DeleteTagsCommand extends Command ); } - protected function execute(InputInterface $input, OutputInterface $output): ?int + protected function execute(InputInterface $input, OutputInterface $output): int { $io = new SymfonyStyle($input, $output); $tagNames = $input->getOption('name'); diff --git a/module/CLI/src/Command/Tag/ListTagsCommand.php b/module/CLI/src/Command/Tag/ListTagsCommand.php index d56e4101..2efeac5c 100644 --- a/module/CLI/src/Command/Tag/ListTagsCommand.php +++ b/module/CLI/src/Command/Tag/ListTagsCommand.php @@ -31,7 +31,7 @@ class ListTagsCommand extends Command ->setDescription('Lists existing tags.'); } - protected function execute(InputInterface $input, OutputInterface $output): ?int + protected function execute(InputInterface $input, OutputInterface $output): int { ShlinkTable::default($output)->render(['Name', 'URLs amount', 'Visits amount'], $this->getTagsRows()); return ExitCode::EXIT_SUCCESS; diff --git a/module/CLI/src/Command/Tag/RenameTagCommand.php b/module/CLI/src/Command/Tag/RenameTagCommand.php index 1da3b983..fdc0f0ce 100644 --- a/module/CLI/src/Command/Tag/RenameTagCommand.php +++ b/module/CLI/src/Command/Tag/RenameTagCommand.php @@ -33,7 +33,7 @@ class RenameTagCommand extends Command ->addArgument('newName', InputArgument::REQUIRED, 'New name of the tag.'); } - protected function execute(InputInterface $input, OutputInterface $output): ?int + protected function execute(InputInterface $input, OutputInterface $output): int { $io = new SymfonyStyle($input, $output); $oldName = $input->getArgument('oldName'); diff --git a/module/CLI/src/Command/Util/AbstractLockedCommand.php b/module/CLI/src/Command/Util/AbstractLockedCommand.php index ae930496..8bd728cd 100644 --- a/module/CLI/src/Command/Util/AbstractLockedCommand.php +++ b/module/CLI/src/Command/Util/AbstractLockedCommand.php @@ -19,7 +19,7 @@ abstract class AbstractLockedCommand extends Command parent::__construct(); } - final protected function execute(InputInterface $input, OutputInterface $output): ?int + final protected function execute(InputInterface $input, OutputInterface $output): int { $lockConfig = $this->getLockConfig(); $lock = $this->locker->createLock($lockConfig->lockName, $lockConfig->ttl, $lockConfig->isBlocking); diff --git a/module/CLI/src/Command/Visit/AbstractDeleteVisitsCommand.php b/module/CLI/src/Command/Visit/AbstractDeleteVisitsCommand.php index f171d59a..7cb32698 100644 --- a/module/CLI/src/Command/Visit/AbstractDeleteVisitsCommand.php +++ b/module/CLI/src/Command/Visit/AbstractDeleteVisitsCommand.php @@ -12,7 +12,7 @@ use Symfony\Component\Console\Style\SymfonyStyle; abstract class AbstractDeleteVisitsCommand extends Command { - final protected function execute(InputInterface $input, OutputInterface $output): ?int + final protected function execute(InputInterface $input, OutputInterface $output): int { $io = new SymfonyStyle($input, $output); if (! $this->confirm($io)) { @@ -29,7 +29,7 @@ abstract class AbstractDeleteVisitsCommand extends Command return $io->confirm('Continue deleting visits?', false); } - abstract protected function doExecute(InputInterface $input, SymfonyStyle $io): ?int; + abstract protected function doExecute(InputInterface $input, SymfonyStyle $io): int; abstract protected function getWarningMessage(): string; } diff --git a/module/CLI/src/Command/Visit/AbstractVisitsListCommand.php b/module/CLI/src/Command/Visit/AbstractVisitsListCommand.php index a15eb5e7..bd20a4ae 100644 --- a/module/CLI/src/Command/Visit/AbstractVisitsListCommand.php +++ b/module/CLI/src/Command/Visit/AbstractVisitsListCommand.php @@ -34,7 +34,7 @@ abstract class AbstractVisitsListCommand extends Command $this->endDateOption = new EndDateOption($this, 'visits'); } - final protected function execute(InputInterface $input, OutputInterface $output): ?int + final protected function execute(InputInterface $input, OutputInterface $output): int { $startDate = $this->startDateOption->get($input, $output); $endDate = $this->endDateOption->get($input, $output); diff --git a/module/CLI/src/Command/Visit/DeleteOrphanVisitsCommand.php b/module/CLI/src/Command/Visit/DeleteOrphanVisitsCommand.php index af1b7c66..2b34ae52 100644 --- a/module/CLI/src/Command/Visit/DeleteOrphanVisitsCommand.php +++ b/module/CLI/src/Command/Visit/DeleteOrphanVisitsCommand.php @@ -27,7 +27,7 @@ class DeleteOrphanVisitsCommand extends AbstractDeleteVisitsCommand ->setDescription('Deletes all orphan visits'); } - protected function doExecute(InputInterface $input, SymfonyStyle $io): ?int + protected function doExecute(InputInterface $input, SymfonyStyle $io): int { $result = $this->deleter->deleteOrphanVisits(); $io->success(sprintf('Successfully deleted %s visits', $result->affectedItems)); diff --git a/module/CLI/src/Command/Visit/DownloadGeoLiteDbCommand.php b/module/CLI/src/Command/Visit/DownloadGeoLiteDbCommand.php index 8da6c753..ac8ee102 100644 --- a/module/CLI/src/Command/Visit/DownloadGeoLiteDbCommand.php +++ b/module/CLI/src/Command/Visit/DownloadGeoLiteDbCommand.php @@ -37,7 +37,7 @@ class DownloadGeoLiteDbCommand extends Command ); } - protected function execute(InputInterface $input, OutputInterface $output): ?int + protected function execute(InputInterface $input, OutputInterface $output): int { $io = new SymfonyStyle($input, $output); diff --git a/module/CLI/test/Command/Db/CreateDatabaseCommandTest.php b/module/CLI/test/Command/Db/CreateDatabaseCommandTest.php index e612dc1d..b4a5c840 100644 --- a/module/CLI/test/Command/Db/CreateDatabaseCommandTest.php +++ b/module/CLI/test/Command/Db/CreateDatabaseCommandTest.php @@ -22,7 +22,7 @@ use ShlinkioTest\Shlink\CLI\Util\CliTestUtils; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Tester\CommandTester; use Symfony\Component\Lock\LockFactory; -use Symfony\Component\Lock\LockInterface; +use Symfony\Component\Lock\SharedLockInterface; use Symfony\Component\Process\PhpExecutableFinder; class CreateDatabaseCommandTest extends TestCase @@ -37,7 +37,7 @@ class CreateDatabaseCommandTest extends TestCase protected function setUp(): void { $locker = $this->createMock(LockFactory::class); - $lock = $this->createMock(LockInterface::class); + $lock = $this->createMock(SharedLockInterface::class); $lock->method('acquire')->withAnyParameters()->willReturn(true); $locker->method('createLock')->withAnyParameters()->willReturn($lock); diff --git a/module/CLI/test/Command/Db/MigrateDatabaseCommandTest.php b/module/CLI/test/Command/Db/MigrateDatabaseCommandTest.php index ac4283d7..29932202 100644 --- a/module/CLI/test/Command/Db/MigrateDatabaseCommandTest.php +++ b/module/CLI/test/Command/Db/MigrateDatabaseCommandTest.php @@ -13,7 +13,7 @@ use ShlinkioTest\Shlink\CLI\Util\CliTestUtils; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Tester\CommandTester; use Symfony\Component\Lock\LockFactory; -use Symfony\Component\Lock\LockInterface; +use Symfony\Component\Lock\SharedLockInterface; use Symfony\Component\Process\PhpExecutableFinder; class MigrateDatabaseCommandTest extends TestCase @@ -24,7 +24,7 @@ class MigrateDatabaseCommandTest extends TestCase protected function setUp(): void { $locker = $this->createMock(LockFactory::class); - $lock = $this->createMock(LockInterface::class); + $lock = $this->createMock(SharedLockInterface::class); $lock->method('acquire')->withAnyParameters()->willReturn(true); $locker->method('createLock')->withAnyParameters()->willReturn($lock); diff --git a/module/CLI/test/Command/Visit/LocateVisitsCommandTest.php b/module/CLI/test/Command/Visit/LocateVisitsCommandTest.php index 031e8e45..59c6b72f 100644 --- a/module/CLI/test/Command/Visit/LocateVisitsCommandTest.php +++ b/module/CLI/test/Command/Visit/LocateVisitsCommandTest.php @@ -46,7 +46,7 @@ class LocateVisitsCommandTest extends TestCase $this->visitToLocation = $this->createMock(VisitToLocationHelperInterface::class); $locker = $this->createMock(Lock\LockFactory::class); - $this->lock = $this->createMock(Lock\LockInterface::class); + $this->lock = $this->createMock(Lock\SharedLockInterface::class); $locker->method('createLock')->with($this->isType('string'), 600.0, false)->willReturn($this->lock); $command = new LocateVisitsCommand($this->visitService, $this->visitToLocation, $locker); diff --git a/module/CLI/test/GeoLite/GeolocationDbUpdaterTest.php b/module/CLI/test/GeoLite/GeolocationDbUpdaterTest.php index 0f911db8..15db873e 100644 --- a/module/CLI/test/GeoLite/GeolocationDbUpdaterTest.php +++ b/module/CLI/test/GeoLite/GeolocationDbUpdaterTest.php @@ -34,7 +34,7 @@ class GeolocationDbUpdaterTest extends TestCase { $this->dbUpdater = $this->createMock(DbUpdaterInterface::class); $this->geoLiteDbReader = $this->createMock(Reader::class); - $this->lock = $this->createMock(Lock\LockInterface::class); + $this->lock = $this->createMock(Lock\SharedLockInterface::class); $this->lock->method('acquire')->with($this->isTrue())->willReturn(true); }