diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8509912e..7baed2b4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,7 +13,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this
#### Changed
-* *Nothing*
+* [#592](https://github.com/shlinkio/shlink/issues/592) Updated coding styles to use [shlinkio/php-coding-standard](https://github.com/shlinkio/php-coding-standard) v2.1.0.
#### Deprecated
diff --git a/composer.json b/composer.json
index 0b2c1d93..549b6465 100644
--- a/composer.json
+++ b/composer.json
@@ -63,7 +63,7 @@
"phpstan/phpstan": "^0.12.3",
"phpunit/phpunit": "^8.3",
"roave/security-advisories": "dev-master",
- "shlinkio/php-coding-standard": "~2.0.0",
+ "shlinkio/php-coding-standard": "~2.1.0",
"shlinkio/shlink-test-utils": "^1.2",
"symfony/var-dumper": "^5.0"
},
diff --git a/data/migrations/Version20180801183328.php b/data/migrations/Version20180801183328.php
index 80ebbfe8..24bcd825 100644
--- a/data/migrations/Version20180801183328.php
+++ b/data/migrations/Version20180801183328.php
@@ -17,7 +17,6 @@ final class Version20180801183328 extends AbstractMigration
private const OLD_SIZE = 10;
/**
- * @param Schema $schema
* @throws SchemaException
*/
public function up(Schema $schema): void
@@ -26,7 +25,6 @@ final class Version20180801183328 extends AbstractMigration
}
/**
- * @param Schema $schema
* @throws SchemaException
*/
public function down(Schema $schema): void
@@ -35,8 +33,6 @@ final class Version20180801183328 extends AbstractMigration
}
/**
- * @param Schema $schema
- * @param int $size
* @throws SchemaException
*/
private function setSize(Schema $schema, int $size): void
diff --git a/data/migrations/Version20180913205455.php b/data/migrations/Version20180913205455.php
index 9f81578a..8afa316b 100644
--- a/data/migrations/Version20180913205455.php
+++ b/data/migrations/Version20180913205455.php
@@ -17,7 +17,6 @@ use Shlinkio\Shlink\Common\Util\IpAddress;
final class Version20180913205455 extends AbstractMigration
{
/**
- * @param Schema $schema
*/
public function up(Schema $schema): void
{
@@ -25,7 +24,6 @@ final class Version20180913205455 extends AbstractMigration
}
/**
- * @param Schema $schema
* @throws DBALException
*/
public function postUp(Schema $schema): void
@@ -67,7 +65,6 @@ final class Version20180913205455 extends AbstractMigration
}
/**
- * @param Schema $schema
*/
public function down(Schema $schema): void
{
diff --git a/data/migrations/Version20180915110857.php b/data/migrations/Version20180915110857.php
index c08d59eb..73a36597 100644
--- a/data/migrations/Version20180915110857.php
+++ b/data/migrations/Version20180915110857.php
@@ -19,7 +19,6 @@ final class Version20180915110857 extends AbstractMigration
];
/**
- * @param Schema $schema
* @throws SchemaException
*/
public function up(Schema $schema): void
@@ -39,7 +38,7 @@ final class Version20180915110857 extends AbstractMigration
[
'onDelete' => self::ON_DELETE_MAP[$foreignTable],
'onUpdate' => 'RESTRICT',
- ]
+ ],
);
}
}
diff --git a/data/migrations/Version20181020060559.php b/data/migrations/Version20181020060559.php
index e60b7fc8..86d46358 100644
--- a/data/migrations/Version20181020060559.php
+++ b/data/migrations/Version20181020060559.php
@@ -24,7 +24,6 @@ final class Version20181020060559 extends AbstractMigration
];
/**
- * @param Schema $schema
* @throws SchemaException
*/
public function up(Schema $schema): void
diff --git a/module/CLI/src/Command/Api/GenerateKeyCommand.php b/module/CLI/src/Command/Api/GenerateKeyCommand.php
index cadc1fc1..889556b2 100644
--- a/module/CLI/src/Command/Api/GenerateKeyCommand.php
+++ b/module/CLI/src/Command/Api/GenerateKeyCommand.php
@@ -36,7 +36,7 @@ class GenerateKeyCommand extends Command
'expirationDate',
'e',
InputOption::VALUE_REQUIRED,
- 'The date in which the API key should expire. Use any valid PHP format.'
+ 'The date in which the API key should expire. Use any valid PHP format.',
);
}
diff --git a/module/CLI/src/Command/Api/ListKeysCommand.php b/module/CLI/src/Command/Api/ListKeysCommand.php
index 2d8b8cd6..f54ad8dd 100644
--- a/module/CLI/src/Command/Api/ListKeysCommand.php
+++ b/module/CLI/src/Command/Api/ListKeysCommand.php
@@ -42,7 +42,7 @@ class ListKeysCommand extends Command
'enabledOnly',
'e',
InputOption::VALUE_NONE,
- 'Tells if only enabled API keys should be returned.'
+ 'Tells if only enabled API keys should be returned.',
);
}
@@ -81,8 +81,6 @@ class ListKeysCommand extends Command
}
/**
- * @param ApiKey $apiKey
- * @return string
*/
private function getEnabledSymbol(ApiKey $apiKey): string
{
diff --git a/module/CLI/src/Command/Db/CreateDatabaseCommand.php b/module/CLI/src/Command/Db/CreateDatabaseCommand.php
index 30043f72..b8e88688 100644
--- a/module/CLI/src/Command/Db/CreateDatabaseCommand.php
+++ b/module/CLI/src/Command/Db/CreateDatabaseCommand.php
@@ -41,7 +41,7 @@ class CreateDatabaseCommand extends AbstractDatabaseCommand
$this
->setName(self::NAME)
->setDescription(
- 'Creates the database needed for shlink to work. It will do nothing if the database already exists'
+ 'Creates the database needed for shlink to work. It will do nothing if the database already exists',
);
}
diff --git a/module/CLI/src/Command/ShortUrl/DeleteShortUrlCommand.php b/module/CLI/src/Command/ShortUrl/DeleteShortUrlCommand.php
index 91c37663..bee66c34 100644
--- a/module/CLI/src/Command/ShortUrl/DeleteShortUrlCommand.php
+++ b/module/CLI/src/Command/ShortUrl/DeleteShortUrlCommand.php
@@ -39,7 +39,7 @@ class DeleteShortUrlCommand extends Command
'i',
InputOption::VALUE_NONE,
'Ignores the safety visits threshold check, which could make short URLs with many visits to be '
- . 'accidentally deleted'
+ . 'accidentally deleted',
);
}
diff --git a/module/CLI/src/Command/ShortUrl/GenerateShortUrlCommand.php b/module/CLI/src/Command/ShortUrl/GenerateShortUrlCommand.php
index 3e66658d..9a4f4139 100644
--- a/module/CLI/src/Command/ShortUrl/GenerateShortUrlCommand.php
+++ b/module/CLI/src/Command/ShortUrl/GenerateShortUrlCommand.php
@@ -47,45 +47,45 @@ class GenerateShortUrlCommand extends Command
'tags',
't',
InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED,
- 'Tags to apply to the new short URL'
+ 'Tags to apply to the new short URL',
)
->addOption(
'validSince',
's',
InputOption::VALUE_REQUIRED,
'The date from which this short URL will be valid. '
- . 'If someone tries to access it before this date, it will not be found.'
+ . 'If someone tries to access it before this date, it will not be found.',
)
->addOption(
'validUntil',
'u',
InputOption::VALUE_REQUIRED,
'The date until which this short URL will be valid. '
- . 'If someone tries to access it after this date, it will not be found.'
+ . 'If someone tries to access it after this date, it will not be found.',
)
->addOption(
'customSlug',
'c',
InputOption::VALUE_REQUIRED,
- 'If provided, this slug will be used instead of generating a short code'
+ 'If provided, this slug will be used instead of generating a short code',
)
->addOption(
'maxVisits',
'm',
InputOption::VALUE_REQUIRED,
- 'This will limit the number of visits for this short URL.'
+ 'This will limit the number of visits for this short URL.',
)
->addOption(
'findIfExists',
'f',
InputOption::VALUE_NONE,
- 'This will force existing matching URL to be returned if found, instead of creating a new one.'
+ 'This will force existing matching URL to be returned if found, instead of creating a new one.',
)
->addOption(
'domain',
'd',
InputOption::VALUE_REQUIRED,
- 'The domain to which this short URL will be attached.'
+ 'The domain to which this short URL will be attached.',
);
}
@@ -127,8 +127,8 @@ class GenerateShortUrlCommand extends Command
$customSlug,
$maxVisits !== null ? (int) $maxVisits : null,
$input->getOption('findIfExists'),
- $input->getOption('domain')
- )
+ $input->getOption('domain'),
+ ),
);
$io->writeln([
diff --git a/module/CLI/src/Command/ShortUrl/ListShortUrlsCommand.php b/module/CLI/src/Command/ShortUrl/ListShortUrlsCommand.php
index 62d44445..6cb6f1b9 100644
--- a/module/CLI/src/Command/ShortUrl/ListShortUrlsCommand.php
+++ b/module/CLI/src/Command/ShortUrl/ListShortUrlsCommand.php
@@ -61,25 +61,25 @@ class ListShortUrlsCommand extends AbstractWithDateRangeCommand
'p',
InputOption::VALUE_REQUIRED,
sprintf('The first page to list (%s items per page)', ShortUrlRepositoryAdapter::ITEMS_PER_PAGE),
- '1'
+ '1',
)
->addOption(
'searchTerm',
'st',
InputOption::VALUE_REQUIRED,
- 'A query used to filter results by searching for it on the longUrl and shortCode fields'
+ 'A query used to filter results by searching for it on the longUrl and shortCode fields',
)
->addOption(
'tags',
't',
InputOption::VALUE_REQUIRED,
- 'A comma-separated list of tags to filter results'
+ 'A comma-separated list of tags to filter results',
)
->addOption(
'orderBy',
'o',
InputOption::VALUE_REQUIRED,
- 'The field from which we want to order by. Pass ASC or DESC separated by a comma'
+ 'The field from which we want to order by. Pass ASC or DESC separated by a comma',
)
->addOption('showTags', null, InputOption::VALUE_NONE, 'Whether to display the tags or not');
}
@@ -122,6 +122,9 @@ class ListShortUrlsCommand extends AbstractWithDateRangeCommand
return ExitCodes::EXIT_SUCCESS;
}
+ /**
+ * @param string|array|null $orderBy
+ */
private function renderPage(
OutputInterface $output,
int $page,
@@ -137,7 +140,7 @@ class ListShortUrlsCommand extends AbstractWithDateRangeCommand
$searchTerm,
$tags,
$orderBy,
- new DateRange($startDate, $endDate)
+ new DateRange($startDate, $endDate),
);
$headers = ['Short code', 'Short URL', 'Long URL', 'Date created', 'Visits count'];
@@ -159,7 +162,7 @@ class ListShortUrlsCommand extends AbstractWithDateRangeCommand
ShlinkTable::fromOutput($output)->render($headers, $rows, $this->formatCurrentPageMessage(
$result,
- 'Page %s of %s'
+ 'Page %s of %s',
));
return $result;
diff --git a/module/CLI/src/Command/Tag/CreateTagCommand.php b/module/CLI/src/Command/Tag/CreateTagCommand.php
index 18aba957..5fe56d46 100644
--- a/module/CLI/src/Command/Tag/CreateTagCommand.php
+++ b/module/CLI/src/Command/Tag/CreateTagCommand.php
@@ -33,7 +33,7 @@ class CreateTagCommand extends Command
'name',
't',
InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY,
- 'The name of the tags to create'
+ 'The name of the tags to create',
);
}
diff --git a/module/CLI/src/Command/Tag/DeleteTagsCommand.php b/module/CLI/src/Command/Tag/DeleteTagsCommand.php
index a3dd81e1..1cebe895 100644
--- a/module/CLI/src/Command/Tag/DeleteTagsCommand.php
+++ b/module/CLI/src/Command/Tag/DeleteTagsCommand.php
@@ -33,7 +33,7 @@ class DeleteTagsCommand extends Command
'name',
't',
InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY,
- 'The name of the tags to delete'
+ 'The name of the tags to delete',
);
}
diff --git a/module/CLI/src/Command/Util/AbstractLockedCommand.php b/module/CLI/src/Command/Util/AbstractLockedCommand.php
index eab43436..8a43653d 100644
--- a/module/CLI/src/Command/Util/AbstractLockedCommand.php
+++ b/module/CLI/src/Command/Util/AbstractLockedCommand.php
@@ -29,7 +29,7 @@ abstract class AbstractLockedCommand extends Command
if (! $lock->acquire($lockConfig->isBlocking())) {
$output->writeln(
- sprintf('Command "%s" is already in progress. Skipping.', $lockConfig->lockName())
+ sprintf('Command "%s" is already in progress. Skipping.', $lockConfig->lockName()),
);
return ExitCodes::EXIT_WARNING;
}
diff --git a/module/CLI/src/Command/Util/AbstractWithDateRangeCommand.php b/module/CLI/src/Command/Util/AbstractWithDateRangeCommand.php
index c6b10be6..bd64701a 100644
--- a/module/CLI/src/Command/Util/AbstractWithDateRangeCommand.php
+++ b/module/CLI/src/Command/Util/AbstractWithDateRangeCommand.php
@@ -36,7 +36,7 @@ abstract class AbstractWithDateRangeCommand extends Command
$output->writeln(sprintf(
'> Ignored provided "%s" since its value "%s" is not a valid date. <',
$key,
- $value
+ $value,
));
if ($output->isVeryVerbose()) {
diff --git a/module/CLI/src/Command/Visit/LocateVisitsCommand.php b/module/CLI/src/Command/Visit/LocateVisitsCommand.php
index 432ac1bd..b19e8b19 100644
--- a/module/CLI/src/Command/Visit/LocateVisitsCommand.php
+++ b/module/CLI/src/Command/Visit/LocateVisitsCommand.php
@@ -66,13 +66,13 @@ class LocateVisitsCommand extends AbstractLockedCommand
$this->visitService->locateUnlocatedVisits(
[$this, 'getGeolocationDataForVisit'],
- static function (VisitLocation $location) use ($output) {
+ static function (VisitLocation $location) use ($output): void {
if (!$location->isEmpty()) {
$output->writeln(
- sprintf(' [Address located at "%s"]', $location->getCountryName())
+ sprintf(' [Address located at "%s"]', $location->getCountryName()),
);
}
- }
+ },
);
$this->io->success('Finished processing all IPs');
@@ -92,7 +92,7 @@ class LocateVisitsCommand extends AbstractLockedCommand
if (! $visit->hasRemoteAddr()) {
$this->io->writeln(
'Ignored visit with no IP address',
- OutputInterface::VERBOSITY_VERBOSE
+ OutputInterface::VERBOSITY_VERBOSE,
);
throw IpCannotBeLocatedException::forEmptyAddress();
}
@@ -119,12 +119,12 @@ class LocateVisitsCommand extends AbstractLockedCommand
private function checkDbUpdate(): void
{
try {
- $this->dbUpdater->checkDbUpdate(function (bool $olderDbExists) {
+ $this->dbUpdater->checkDbUpdate(function (bool $olderDbExists): void {
$this->io->writeln(
- sprintf('%s GeoLite2 database...>', $olderDbExists ? 'Updating' : 'Downloading')
+ sprintf('%s GeoLite2 database...>', $olderDbExists ? 'Updating' : 'Downloading'),
);
$this->progressBar = new ProgressBar($this->io);
- }, function (int $total, int $downloaded) {
+ }, function (int $total, int $downloaded): void {
$this->progressBar->setMaxSteps($total);
$this->progressBar->setProgress($downloaded);
});
@@ -141,7 +141,7 @@ class LocateVisitsCommand extends AbstractLockedCommand
$this->io->newLine();
$this->io->writeln(
- '[Warning] GeoLite2 database update failed. Proceeding with old version.>'
+ '[Warning] GeoLite2 database update failed. Proceeding with old version.>',
);
}
}
diff --git a/module/CLI/src/ConfigProvider.php b/module/CLI/src/ConfigProvider.php
index 0bc0a25f..40dcf775 100644
--- a/module/CLI/src/ConfigProvider.php
+++ b/module/CLI/src/ConfigProvider.php
@@ -8,7 +8,7 @@ use function Shlinkio\Shlink\Common\loadConfigFromGlob;
class ConfigProvider
{
- public function __invoke()
+ public function __invoke(): array
{
return loadConfigFromGlob(__DIR__ . '/../config/{,*.}config.php');
}
diff --git a/module/CLI/src/Exception/GeolocationDbUpdateFailedException.php b/module/CLI/src/Exception/GeolocationDbUpdateFailedException.php
index 42707d9b..8ddee216 100644
--- a/module/CLI/src/Exception/GeolocationDbUpdateFailedException.php
+++ b/module/CLI/src/Exception/GeolocationDbUpdateFailedException.php
@@ -16,7 +16,7 @@ class GeolocationDbUpdateFailedException extends RuntimeException implements Exc
$e = new self(
'An error occurred while updating geolocation database, and an older version could not be found',
0,
- $prev
+ $prev,
);
$e->olderDbExists = $olderDbExists;
diff --git a/module/CLI/test/Command/Api/GenerateKeyCommandTest.php b/module/CLI/test/Command/Api/GenerateKeyCommandTest.php
index fe5bc137..8ddd9f0b 100644
--- a/module/CLI/test/Command/Api/GenerateKeyCommandTest.php
+++ b/module/CLI/test/Command/Api/GenerateKeyCommandTest.php
@@ -29,7 +29,7 @@ class GenerateKeyCommandTest extends TestCase
}
/** @test */
- public function noExpirationDateIsDefinedIfNotProvided()
+ public function noExpirationDateIsDefinedIfNotProvided(): void
{
$create = $this->apiKeyService->create(null)->willReturn(new ApiKey());
@@ -41,7 +41,7 @@ class GenerateKeyCommandTest extends TestCase
}
/** @test */
- public function expirationDateIsDefinedIfProvided()
+ public function expirationDateIsDefinedIfProvided(): void
{
$this->apiKeyService->create(Argument::type(Chronos::class))->shouldBeCalledOnce()
->willReturn(new ApiKey());
diff --git a/module/CLI/test/Command/Db/CreateDatabaseCommandTest.php b/module/CLI/test/Command/Db/CreateDatabaseCommandTest.php
index 700b96bb..c88e28fa 100644
--- a/module/CLI/test/Command/Db/CreateDatabaseCommandTest.php
+++ b/module/CLI/test/Command/Db/CreateDatabaseCommandTest.php
@@ -33,7 +33,7 @@ class CreateDatabaseCommandTest extends TestCase
$locker = $this->prophesize(LockFactory::class);
$lock = $this->prophesize(LockInterface::class);
$lock->acquire(Argument::any())->willReturn(true);
- $lock->release()->will(function () {
+ $lock->release()->will(function (): void {
});
$locker->createLock(Argument::cetera())->willReturn($lock->reveal());
@@ -55,7 +55,7 @@ class CreateDatabaseCommandTest extends TestCase
$this->processHelper->reveal(),
$phpExecutableFinder->reveal(),
$this->regularConn->reveal(),
- $this->noDbNameConn->reveal()
+ $this->noDbNameConn->reveal(),
);
$app = new Application();
$app->add($command);
@@ -69,7 +69,7 @@ class CreateDatabaseCommandTest extends TestCase
$shlinkDatabase = 'shlink_database';
$getDatabase = $this->regularConn->getDatabase()->willReturn($shlinkDatabase);
$listDatabases = $this->schemaManager->listDatabases()->willReturn(['foo', $shlinkDatabase, 'bar']);
- $createDatabase = $this->schemaManager->createDatabase($shlinkDatabase)->will(function () {
+ $createDatabase = $this->schemaManager->createDatabase($shlinkDatabase)->will(function (): void {
});
$listTables = $this->schemaManager->listTableNames()->willReturn(['foo_table', 'bar_table']);
@@ -89,7 +89,7 @@ class CreateDatabaseCommandTest extends TestCase
$shlinkDatabase = 'shlink_database';
$getDatabase = $this->regularConn->getDatabase()->willReturn($shlinkDatabase);
$listDatabases = $this->schemaManager->listDatabases()->willReturn(['foo', 'bar']);
- $createDatabase = $this->schemaManager->createDatabase($shlinkDatabase)->will(function () {
+ $createDatabase = $this->schemaManager->createDatabase($shlinkDatabase)->will(function (): void {
});
$listTables = $this->schemaManager->listTableNames()->willReturn(['foo_table', 'bar_table']);
@@ -107,7 +107,7 @@ class CreateDatabaseCommandTest extends TestCase
$shlinkDatabase = 'shlink_database';
$getDatabase = $this->regularConn->getDatabase()->willReturn($shlinkDatabase);
$listDatabases = $this->schemaManager->listDatabases()->willReturn(['foo', $shlinkDatabase, 'bar']);
- $createDatabase = $this->schemaManager->createDatabase($shlinkDatabase)->will(function () {
+ $createDatabase = $this->schemaManager->createDatabase($shlinkDatabase)->will(function (): void {
});
$listTables = $this->schemaManager->listTableNames()->willReturn([]);
$runCommand = $this->processHelper->mustRun(Argument::type(OutputInterface::class), [
@@ -136,7 +136,7 @@ class CreateDatabaseCommandTest extends TestCase
$shlinkDatabase = 'shlink_database';
$getDatabase = $this->regularConn->getDatabase()->willReturn($shlinkDatabase);
$listDatabases = $this->schemaManager->listDatabases()->willReturn(['foo', 'bar']);
- $createDatabase = $this->schemaManager->createDatabase($shlinkDatabase)->will(function () {
+ $createDatabase = $this->schemaManager->createDatabase($shlinkDatabase)->will(function (): void {
});
$listTables = $this->schemaManager->listTableNames()->willReturn(['foo_table', 'bar_table']);
diff --git a/module/CLI/test/Command/Db/MigrateDatabaseCommandTest.php b/module/CLI/test/Command/Db/MigrateDatabaseCommandTest.php
index 70dce5cc..15f756a7 100644
--- a/module/CLI/test/Command/Db/MigrateDatabaseCommandTest.php
+++ b/module/CLI/test/Command/Db/MigrateDatabaseCommandTest.php
@@ -26,7 +26,7 @@ class MigrateDatabaseCommandTest extends TestCase
$locker = $this->prophesize(LockFactory::class);
$lock = $this->prophesize(LockInterface::class);
$lock->acquire(Argument::any())->willReturn(true);
- $lock->release()->will(function () {
+ $lock->release()->will(function (): void {
});
$locker->createLock(Argument::cetera())->willReturn($lock->reveal());
@@ -38,7 +38,7 @@ class MigrateDatabaseCommandTest extends TestCase
$command = new MigrateDatabaseCommand(
$locker->reveal(),
$this->processHelper->reveal(),
- $phpExecutableFinder->reveal()
+ $phpExecutableFinder->reveal(),
);
$app = new Application();
$app->add($command);
diff --git a/module/CLI/test/Command/ShortUrl/DeleteShortUrlCommandTest.php b/module/CLI/test/Command/ShortUrl/DeleteShortUrlCommandTest.php
index 989277b8..7fd727ca 100644
--- a/module/CLI/test/Command/ShortUrl/DeleteShortUrlCommandTest.php
+++ b/module/CLI/test/Command/ShortUrl/DeleteShortUrlCommandTest.php
@@ -38,7 +38,7 @@ class DeleteShortUrlCommandTest extends TestCase
public function successMessageIsPrintedIfUrlIsProperlyDeleted(): void
{
$shortCode = 'abc123';
- $deleteByShortCode = $this->service->deleteByShortCode($shortCode, false)->will(function () {
+ $deleteByShortCode = $this->service->deleteByShortCode($shortCode, false)->will(function (): void {
});
$this->commandTester->execute(['shortCode' => $shortCode]);
@@ -46,7 +46,7 @@ class DeleteShortUrlCommandTest extends TestCase
$this->assertStringContainsString(
sprintf('Short URL with short code "%s" successfully deleted.', $shortCode),
- $output
+ $output,
);
$deleteByShortCode->shouldHaveBeenCalledOnce();
}
@@ -56,7 +56,7 @@ class DeleteShortUrlCommandTest extends TestCase
{
$shortCode = 'abc123';
$deleteByShortCode = $this->service->deleteByShortCode($shortCode, false)->willThrow(
- Exception\ShortUrlNotFoundException::fromNotFoundShortCode($shortCode)
+ Exception\ShortUrlNotFoundException::fromNotFoundShortCode($shortCode),
);
$this->commandTester->execute(['shortCode' => $shortCode]);
@@ -77,13 +77,13 @@ class DeleteShortUrlCommandTest extends TestCase
): void {
$shortCode = 'abc123';
$deleteByShortCode = $this->service->deleteByShortCode($shortCode, Argument::type('bool'))->will(
- function (array $args) use ($shortCode) {
+ function (array $args) use ($shortCode): void {
$ignoreThreshold = array_pop($args);
if (!$ignoreThreshold) {
throw Exception\DeleteShortUrlException::fromVisitsThreshold(10, $shortCode);
}
- }
+ },
);
$this->commandTester->setInputs($retryAnswer);
@@ -92,7 +92,7 @@ class DeleteShortUrlCommandTest extends TestCase
$this->assertStringContainsString(sprintf(
'Impossible to delete short URL with short code "%s" since it has more than "10" visits.',
- $shortCode
+ $shortCode,
), $output);
$this->assertStringContainsString($expectedMessage, $output);
$deleteByShortCode->shouldHaveBeenCalledTimes($expectedDeleteCalls);
@@ -110,7 +110,7 @@ class DeleteShortUrlCommandTest extends TestCase
{
$shortCode = 'abc123';
$deleteByShortCode = $this->service->deleteByShortCode($shortCode, false)->willThrow(
- Exception\DeleteShortUrlException::fromVisitsThreshold(10, $shortCode)
+ Exception\DeleteShortUrlException::fromVisitsThreshold(10, $shortCode),
);
$this->commandTester->setInputs(['no']);
@@ -119,7 +119,7 @@ class DeleteShortUrlCommandTest extends TestCase
$this->assertStringContainsString(sprintf(
'Impossible to delete short URL with short code "%s" since it has more than "10" visits.',
- $shortCode
+ $shortCode,
), $output);
$this->assertStringContainsString('Short URL was not deleted.', $output);
$deleteByShortCode->shouldHaveBeenCalledOnce();
diff --git a/module/CLI/test/Command/ShortUrl/GenerateShortUrlCommandTest.php b/module/CLI/test/Command/ShortUrl/GenerateShortUrlCommandTest.php
index 4f55e7c8..df1019b1 100644
--- a/module/CLI/test/Command/ShortUrl/GenerateShortUrlCommandTest.php
+++ b/module/CLI/test/Command/ShortUrl/GenerateShortUrlCommandTest.php
@@ -72,7 +72,7 @@ class GenerateShortUrlCommandTest extends TestCase
public function providingNonUniqueSlugOutputsError(): void
{
$urlToShortCode = $this->urlShortener->urlToShortCode(Argument::cetera())->willThrow(
- NonUniqueSlugException::fromSlug('my-slug')
+ NonUniqueSlugException::fromSlug('my-slug'),
);
$this->commandTester->execute(['longUrl' => 'http://domain.com/invalid', '--customSlug' => 'my-slug']);
@@ -93,7 +93,7 @@ class GenerateShortUrlCommandTest extends TestCase
Assert::assertEquals(['foo', 'bar', 'baz', 'boo', 'zar'], $tags);
return $tags;
}),
- Argument::cetera()
+ Argument::cetera(),
)->willReturn($shortUrl);
$this->commandTester->execute([
diff --git a/module/CLI/test/Command/ShortUrl/GetVisitsCommandTest.php b/module/CLI/test/Command/ShortUrl/GetVisitsCommandTest.php
index 1fd0c229..b3309772 100644
--- a/module/CLI/test/Command/ShortUrl/GetVisitsCommandTest.php
+++ b/module/CLI/test/Command/ShortUrl/GetVisitsCommandTest.php
@@ -43,7 +43,7 @@ class GetVisitsCommandTest extends TestCase
{
$shortCode = 'abc123';
$this->visitsTracker->info($shortCode, new VisitsParams(new DateRange(null, null)))->willReturn(
- new Paginator(new ArrayAdapter([]))
+ new Paginator(new ArrayAdapter([])),
)->shouldBeCalledOnce();
$this->commandTester->execute(['shortCode' => $shortCode]);
@@ -57,7 +57,7 @@ class GetVisitsCommandTest extends TestCase
$endDate = '2016-02-01';
$this->visitsTracker->info(
$shortCode,
- new VisitsParams(new DateRange(Chronos::parse($startDate), Chronos::parse($endDate)))
+ new VisitsParams(new DateRange(Chronos::parse($startDate), Chronos::parse($endDate))),
)
->willReturn(new Paginator(new ArrayAdapter([])))
->shouldBeCalledOnce();
@@ -86,7 +86,7 @@ class GetVisitsCommandTest extends TestCase
$info->shouldHaveBeenCalledOnce();
$this->assertStringContainsString(
sprintf('Ignored provided "startDate" since its value "%s" is not a valid date', $startDate),
- $output
+ $output,
);
}
@@ -97,9 +97,9 @@ class GetVisitsCommandTest extends TestCase
$this->visitsTracker->info($shortCode, Argument::any())->willReturn(
new Paginator(new ArrayAdapter([
(new Visit(new ShortUrl(''), new Visitor('bar', 'foo', '')))->locate(
- new VisitLocation(new Location('', 'Spain', '', '', 0, 0, ''))
+ new VisitLocation(new Location('', 'Spain', '', '', 0, 0, '')),
),
- ]))
+ ])),
)->shouldBeCalledOnce();
$this->commandTester->execute(['shortCode' => $shortCode]);
diff --git a/module/CLI/test/Command/ShortUrl/ListShortUrlsCommandTest.php b/module/CLI/test/Command/ShortUrl/ListShortUrlsCommandTest.php
index a704111d..8c90050b 100644
--- a/module/CLI/test/Command/ShortUrl/ListShortUrlsCommandTest.php
+++ b/module/CLI/test/Command/ShortUrl/ListShortUrlsCommandTest.php
@@ -162,6 +162,7 @@ class ListShortUrlsCommandTest extends TestCase
}
/**
+ * @param string|array|null $expectedOrderBy
* @test
* @dataProvider provideOrderBy
*/
diff --git a/module/CLI/test/Command/Tag/DeleteTagsCommandTest.php b/module/CLI/test/Command/Tag/DeleteTagsCommandTest.php
index f526f37f..060e5aac 100644
--- a/module/CLI/test/Command/Tag/DeleteTagsCommandTest.php
+++ b/module/CLI/test/Command/Tag/DeleteTagsCommandTest.php
@@ -40,7 +40,7 @@ class DeleteTagsCommandTest extends TestCase
public function serviceIsInvokedOnSuccess(): void
{
$tagNames = ['foo', 'bar'];
- $deleteTags = $this->tagService->deleteTags($tagNames)->will(function () {
+ $deleteTags = $this->tagService->deleteTags($tagNames)->will(function (): void {
});
$this->commandTester->execute([
diff --git a/module/CLI/test/Command/Visit/LocateVisitsCommandTest.php b/module/CLI/test/Command/Visit/LocateVisitsCommandTest.php
index c1a09b08..90073f10 100644
--- a/module/CLI/test/Command/Visit/LocateVisitsCommandTest.php
+++ b/module/CLI/test/Command/Visit/LocateVisitsCommandTest.php
@@ -45,7 +45,7 @@ class LocateVisitsCommandTest extends TestCase
$this->locker = $this->prophesize(Lock\LockFactory::class);
$this->lock = $this->prophesize(Lock\LockInterface::class);
$this->lock->acquire(false)->willReturn(true);
- $this->lock->release()->will(function () {
+ $this->lock->release()->will(function (): void {
});
$this->locker->createLock(Argument::type('string'), 90.0, false)->willReturn($this->lock->reveal());
@@ -53,7 +53,7 @@ class LocateVisitsCommandTest extends TestCase
$this->visitService->reveal(),
$this->ipResolver->reveal(),
$this->locker->reveal(),
- $this->dbUpdater->reveal()
+ $this->dbUpdater->reveal(),
);
$app = new Application();
$app->add($command);
@@ -68,16 +68,16 @@ class LocateVisitsCommandTest extends TestCase
$location = new VisitLocation(Location::emptyInstance());
$locateVisits = $this->visitService->locateUnlocatedVisits(Argument::cetera())->will(
- function (array $args) use ($visit, $location) {
+ function (array $args) use ($visit, $location): void {
$firstCallback = array_shift($args);
$firstCallback($visit);
$secondCallback = array_shift($args);
$secondCallback($location, $visit);
- }
+ },
);
$resolveIpLocation = $this->ipResolver->resolveIpLocation(Argument::any())->willReturn(
- Location::emptyInstance()
+ Location::emptyInstance(),
);
$this->commandTester->execute([]);
@@ -98,16 +98,16 @@ class LocateVisitsCommandTest extends TestCase
$location = new VisitLocation(Location::emptyInstance());
$locateVisits = $this->visitService->locateUnlocatedVisits(Argument::cetera())->will(
- function (array $args) use ($visit, $location) {
+ function (array $args) use ($visit, $location): void {
$firstCallback = array_shift($args);
$firstCallback($visit);
$secondCallback = array_shift($args);
$secondCallback($location, $visit);
- }
+ },
);
$resolveIpLocation = $this->ipResolver->resolveIpLocation(Argument::any())->willReturn(
- Location::emptyInstance()
+ Location::emptyInstance(),
);
$this->commandTester->execute([], ['verbosity' => OutputInterface::VERBOSITY_VERBOSE]);
@@ -137,13 +137,13 @@ class LocateVisitsCommandTest extends TestCase
$location = new VisitLocation(Location::emptyInstance());
$locateVisits = $this->visitService->locateUnlocatedVisits(Argument::cetera())->will(
- function (array $args) use ($visit, $location) {
+ function (array $args) use ($visit, $location): void {
$firstCallback = array_shift($args);
$firstCallback($visit);
$secondCallback = array_shift($args);
$secondCallback($location, $visit);
- }
+ },
);
$resolveIpLocation = $this->ipResolver->resolveIpLocation(Argument::any())->willThrow(WrongIpException::class);
@@ -161,7 +161,7 @@ class LocateVisitsCommandTest extends TestCase
{
$this->lock->acquire(false)->willReturn(false);
- $locateVisits = $this->visitService->locateUnlocatedVisits(Argument::cetera())->will(function () {
+ $locateVisits = $this->visitService->locateUnlocatedVisits(Argument::cetera())->will(function (): void {
});
$resolveIpLocation = $this->ipResolver->resolveIpLocation(Argument::any())->willReturn([]);
@@ -170,7 +170,7 @@ class LocateVisitsCommandTest extends TestCase
$this->assertStringContainsString(
sprintf('Command "%s" is already in progress. Skipping.', LocateVisitsCommand::NAME),
- $output
+ $output,
);
$locateVisits->shouldNotHaveBeenCalled();
$resolveIpLocation->shouldNotHaveBeenCalled();
@@ -182,17 +182,17 @@ class LocateVisitsCommandTest extends TestCase
*/
public function showsProperMessageWhenGeoLiteUpdateFails(bool $olderDbExists, string $expectedMessage): void
{
- $locateVisits = $this->visitService->locateUnlocatedVisits(Argument::cetera())->will(function () {
+ $locateVisits = $this->visitService->locateUnlocatedVisits(Argument::cetera())->will(function (): void {
});
$checkDbUpdate = $this->dbUpdater->checkDbUpdate(Argument::cetera())->will(
- function (array $args) use ($olderDbExists) {
+ function (array $args) use ($olderDbExists): void {
[$mustBeUpdated, $handleProgress] = $args;
$mustBeUpdated($olderDbExists);
$handleProgress(100, 50);
throw GeolocationDbUpdateFailedException::create($olderDbExists);
- }
+ },
);
$this->commandTester->execute([]);
@@ -200,7 +200,7 @@ class LocateVisitsCommandTest extends TestCase
$this->assertStringContainsString(
sprintf('%s GeoLite2 database...', $olderDbExists ? 'Updating' : 'Downloading'),
- $output
+ $output,
);
$this->assertStringContainsString($expectedMessage, $output);
$locateVisits->shouldHaveBeenCalledTimes((int) $olderDbExists);
diff --git a/module/CLI/test/ConfigProviderTest.php b/module/CLI/test/ConfigProviderTest.php
index 96e2d2b4..baa4f311 100644
--- a/module/CLI/test/ConfigProviderTest.php
+++ b/module/CLI/test/ConfigProviderTest.php
@@ -17,7 +17,7 @@ class ConfigProviderTest extends TestCase
}
/** @test */
- public function confiIsProperlyReturned()
+ public function confiIsProperlyReturned(): void
{
$config = ($this->configProvider)();
diff --git a/module/CLI/test/Exception/GeolocationDbUpdateFailedExceptionTest.php b/module/CLI/test/Exception/GeolocationDbUpdateFailedExceptionTest.php
index 70a8cc6f..21a1e006 100644
--- a/module/CLI/test/Exception/GeolocationDbUpdateFailedExceptionTest.php
+++ b/module/CLI/test/Exception/GeolocationDbUpdateFailedExceptionTest.php
@@ -23,7 +23,7 @@ class GeolocationDbUpdateFailedExceptionTest extends TestCase
$this->assertEquals($olderDbExists, $e->olderDbExists());
$this->assertEquals(
'An error occurred while updating geolocation database, and an older version could not be found',
- $e->getMessage()
+ $e->getMessage(),
);
$this->assertEquals(0, $e->getCode());
$this->assertEquals($prev, $e->getPrevious());
diff --git a/module/CLI/test/Factory/ApplicationFactoryTest.php b/module/CLI/test/Factory/ApplicationFactoryTest.php
index 0dd9dc01..5e1dd472 100644
--- a/module/CLI/test/Factory/ApplicationFactoryTest.php
+++ b/module/CLI/test/Factory/ApplicationFactoryTest.php
@@ -59,7 +59,7 @@ class ApplicationFactoryTest extends TestCase
$command->getDefinition()->willReturn($name);
$command->isEnabled()->willReturn(true);
$command->getAliases()->willReturn([]);
- $command->setApplication(Argument::type(Application::class))->willReturn(function () {
+ $command->setApplication(Argument::type(Application::class))->willReturn(function (): void {
});
return $command;
diff --git a/module/CLI/test/Util/GeolocationDbUpdaterTest.php b/module/CLI/test/Util/GeolocationDbUpdaterTest.php
index 640c0e7c..b5346629 100644
--- a/module/CLI/test/Util/GeolocationDbUpdaterTest.php
+++ b/module/CLI/test/Util/GeolocationDbUpdaterTest.php
@@ -36,14 +36,14 @@ class GeolocationDbUpdaterTest extends TestCase
$this->locker = $this->prophesize(Lock\LockFactory::class);
$this->lock = $this->prophesize(Lock\LockInterface::class);
$this->lock->acquire(true)->willReturn(true);
- $this->lock->release()->will(function () {
+ $this->lock->release()->will(function (): void {
});
$this->locker->createLock(Argument::type('string'))->willReturn($this->lock->reveal());
$this->geolocationDbUpdater = new GeolocationDbUpdater(
$this->dbUpdater->reveal(),
$this->geoLiteDbReader->reveal(),
- $this->locker->reveal()
+ $this->locker->reveal(),
);
}
@@ -134,7 +134,7 @@ class GeolocationDbUpdaterTest extends TestCase
'node_count' => 1,
'record_size' => 4,
]));
- $download = $this->dbUpdater->downloadFreshCopy(null)->will(function () {
+ $download = $this->dbUpdater->downloadFreshCopy(null)->will(function (): void {
});
$this->geolocationDbUpdater->checkDbUpdate();
diff --git a/module/CLI/test/Util/ShlinkTableTest.php b/module/CLI/test/Util/ShlinkTableTest.php
index 2f679191..23c4eb32 100644
--- a/module/CLI/test/Util/ShlinkTableTest.php
+++ b/module/CLI/test/Util/ShlinkTableTest.php
@@ -33,7 +33,7 @@ class ShlinkTableTest extends TestCase
$footerTitle = 'Footer';
$setStyle = $this->baseTable->setStyle(Argument::type(TableStyle::class))->willReturn(
- $this->baseTable->reveal()
+ $this->baseTable->reveal(),
);
$setHeaders = $this->baseTable->setHeaders($headers)->willReturn($this->baseTable->reveal());
$setRows = $this->baseTable->setRows($rows)->willReturn($this->baseTable->reveal());
diff --git a/module/Core/src/Action/AbstractTrackingAction.php b/module/Core/src/Action/AbstractTrackingAction.php
index d60b888e..243fc081 100644
--- a/module/Core/src/Action/AbstractTrackingAction.php
+++ b/module/Core/src/Action/AbstractTrackingAction.php
@@ -46,10 +46,7 @@ abstract class AbstractTrackingAction implements MiddlewareInterface
* Process an incoming server request and return a response, optionally delegating
* to the next middleware component to create the response.
*
- * @param ServerRequestInterface $request
- * @param RequestHandlerInterface $handler
*
- * @return ResponseInterface
*/
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
diff --git a/module/Core/src/Action/QrCodeAction.php b/module/Core/src/Action/QrCodeAction.php
index 083b1119..d9480db4 100644
--- a/module/Core/src/Action/QrCodeAction.php
+++ b/module/Core/src/Action/QrCodeAction.php
@@ -41,10 +41,7 @@ class QrCodeAction implements MiddlewareInterface
* Process an incoming server request and return a response, optionally delegating
* to the next middleware component to create the response.
*
- * @param Request $request
- * @param RequestHandlerInterface $handler
*
- * @return Response
* @throws \InvalidArgumentException
* @throws RuntimeException
*/
@@ -71,8 +68,6 @@ class QrCodeAction implements MiddlewareInterface
}
/**
- * @param Request $request
- * @return int
*/
private function getSizeParam(Request $request): int
{
diff --git a/module/Core/src/Config/SimplifiedConfigParser.php b/module/Core/src/Config/SimplifiedConfigParser.php
index 19fe4fb4..a48a34e6 100644
--- a/module/Core/src/Config/SimplifiedConfigParser.php
+++ b/module/Core/src/Config/SimplifiedConfigParser.php
@@ -76,7 +76,7 @@ class SimplifiedConfigParser
$simplifiedConfigOrder = array_flip(array_keys(self::SIMPLIFIED_CONFIG_MAPPING));
uksort(
$configForExistingKeys,
- fn (string $a, string $b): int => $simplifiedConfigOrder[$a] - $simplifiedConfigOrder[$b]
+ fn (string $a, string $b): int => $simplifiedConfigOrder[$a] - $simplifiedConfigOrder[$b],
);
return $configForExistingKeys;
diff --git a/module/Core/src/ConfigProvider.php b/module/Core/src/ConfigProvider.php
index c5ee793a..086d093d 100644
--- a/module/Core/src/ConfigProvider.php
+++ b/module/Core/src/ConfigProvider.php
@@ -8,7 +8,7 @@ use function Shlinkio\Shlink\Common\loadConfigFromGlob;
class ConfigProvider
{
- public function __invoke()
+ public function __invoke(): array
{
return loadConfigFromGlob(__DIR__ . '/../config/{,*.}config.php');
}
diff --git a/module/Core/src/Entity/ShortUrl.php b/module/Core/src/Entity/ShortUrl.php
index 64d6d4b5..858568f3 100644
--- a/module/Core/src/Entity/ShortUrl.php
+++ b/module/Core/src/Entity/ShortUrl.php
@@ -189,7 +189,7 @@ class ShortUrl extends AbstractEntity
$hasAllTags = count($shortUrlTags) === count($tags) && array_reduce(
$tags,
fn (bool $hasAllTags, string $tag) => $hasAllTags && contains($shortUrlTags, $tag),
- true
+ true,
);
return $hasAllTags;
diff --git a/module/Core/src/ErrorHandler/NotFoundTemplateHandler.php b/module/Core/src/ErrorHandler/NotFoundTemplateHandler.php
index 69cc8036..45c8ee62 100644
--- a/module/Core/src/ErrorHandler/NotFoundTemplateHandler.php
+++ b/module/Core/src/ErrorHandler/NotFoundTemplateHandler.php
@@ -28,9 +28,7 @@ class NotFoundTemplateHandler implements RequestHandlerInterface
/**
* Dispatch the next available middleware and return the response.
*
- * @param ServerRequestInterface $request
*
- * @return ResponseInterface
* @throws InvalidArgumentException
*/
public function handle(ServerRequestInterface $request): ResponseInterface
diff --git a/module/Core/src/EventDispatcher/LocateShortUrlVisit.php b/module/Core/src/EventDispatcher/LocateShortUrlVisit.php
index 0dd6b56f..a0f8d033 100644
--- a/module/Core/src/EventDispatcher/LocateShortUrlVisit.php
+++ b/module/Core/src/EventDispatcher/LocateShortUrlVisit.php
@@ -62,14 +62,14 @@ class LocateShortUrlVisit
private function downloadOrUpdateGeoLiteDb(string $visitId): bool
{
try {
- $this->dbUpdater->checkDbUpdate(function (bool $olderDbExists) {
+ $this->dbUpdater->checkDbUpdate(function (bool $olderDbExists): void {
$this->logger->notice(sprintf('%s GeoLite2 database...', $olderDbExists ? 'Updating' : 'Downloading'));
});
} catch (GeolocationDbUpdateFailedException $e) {
if (! $e->olderDbExists()) {
$this->logger->error(
'GeoLite2 database download failed. It is not possible to locate visit with id {visitId}. {e}',
- ['e' => $e, 'visitId' => $visitId]
+ ['e' => $e, 'visitId' => $visitId],
);
return false;
}
@@ -92,7 +92,7 @@ class LocateShortUrlVisit
} catch (WrongIpException $e) {
$this->logger->warning(
'Tried to locate visit with id "{visitId}", but its address seems to be wrong. {e}',
- ['e' => $e, 'visitId' => $visitId]
+ ['e' => $e, 'visitId' => $visitId],
);
}
}
diff --git a/module/Core/src/EventDispatcher/NotifyVisitToWebHooks.php b/module/Core/src/EventDispatcher/NotifyVisitToWebHooks.php
index 646f1757..de07d5ef 100644
--- a/module/Core/src/EventDispatcher/NotifyVisitToWebHooks.php
+++ b/module/Core/src/EventDispatcher/NotifyVisitToWebHooks.php
@@ -92,7 +92,7 @@ class NotifyVisitToWebHooks
return map($this->webhooks, function (string $webhook) use ($requestOptions, $visitId) {
$promise = $this->httpClient->requestAsync(RequestMethodInterface::METHOD_POST, $webhook, $requestOptions);
return $promise->otherwise(
- partial_left(Closure::fromCallable([$this, 'logWebhookFailure']), $webhook, $visitId)
+ partial_left(Closure::fromCallable([$this, 'logWebhookFailure']), $webhook, $visitId),
);
});
}
diff --git a/module/Core/src/Exception/DeleteShortUrlException.php b/module/Core/src/Exception/DeleteShortUrlException.php
index ddd77418..e152aa23 100644
--- a/module/Core/src/Exception/DeleteShortUrlException.php
+++ b/module/Core/src/Exception/DeleteShortUrlException.php
@@ -22,7 +22,7 @@ class DeleteShortUrlException extends DomainException implements ProblemDetailsE
$e = new self(sprintf(
'Impossible to delete short URL with short code "%s" since it has more than "%s" visits.',
$shortCode,
- $threshold
+ $threshold,
));
$e->detail = $e->getMessage();
diff --git a/module/Core/src/Exception/ValidationException.php b/module/Core/src/Exception/ValidationException.php
index 8710b737..b9d23082 100644
--- a/module/Core/src/Exception/ValidationException.php
+++ b/module/Core/src/Exception/ValidationException.php
@@ -63,7 +63,7 @@ class ValidationException extends InvalidArgumentException implements ProblemDet
$this->invalidElementsToString(),
PHP_EOL,
PHP_EOL,
- $this->getTraceAsString()
+ $this->getTraceAsString(),
);
}
@@ -72,7 +72,7 @@ class ValidationException extends InvalidArgumentException implements ProblemDet
return reduce_left($this->getInvalidElements(), fn ($messages, string $name, $_, string $acc) => $acc . sprintf(
"\n '%s' => %s",
$name,
- is_array($messages) ? print_r($messages, true) : $messages
+ is_array($messages) ? print_r($messages, true) : $messages,
), '');
}
}
diff --git a/module/Core/src/Middleware/QrCodeCacheMiddleware.php b/module/Core/src/Middleware/QrCodeCacheMiddleware.php
index 14554e8c..66ed5382 100644
--- a/module/Core/src/Middleware/QrCodeCacheMiddleware.php
+++ b/module/Core/src/Middleware/QrCodeCacheMiddleware.php
@@ -24,10 +24,7 @@ class QrCodeCacheMiddleware implements MiddlewareInterface
* Process an incoming server request and return a response, optionally delegating
* to the next middleware component to create the response.
*
- * @param Request $request
- * @param RequestHandlerInterface $handler
*
- * @return Response
*/
public function process(Request $request, RequestHandlerInterface $handler): Response
{
diff --git a/module/Core/src/Model/CreateShortUrlData.php b/module/Core/src/Model/CreateShortUrlData.php
index 3bd2cb7f..24ed90a6 100644
--- a/module/Core/src/Model/CreateShortUrlData.php
+++ b/module/Core/src/Model/CreateShortUrlData.php
@@ -23,7 +23,6 @@ final class CreateShortUrlData
}
/**
- * @return UriInterface
*/
public function getLongUrl(): UriInterface
{
@@ -39,7 +38,6 @@ final class CreateShortUrlData
}
/**
- * @return ShortUrlMeta
*/
public function getMeta(): ShortUrlMeta
{
diff --git a/module/Core/src/Model/ShortUrlMeta.php b/module/Core/src/Model/ShortUrlMeta.php
index 1f8b0a7d..f9491d02 100644
--- a/module/Core/src/Model/ShortUrlMeta.php
+++ b/module/Core/src/Model/ShortUrlMeta.php
@@ -48,7 +48,7 @@ final class ShortUrlMeta
* @param string|null $domain
* @throws ValidationException
*/
- public static function createFromParams(
+ public static function createFromParams( // phpcs:ignore
$validSince = null,
$validUntil = null,
$customSlug = null,
diff --git a/module/Core/src/Model/Visitor.php b/module/Core/src/Model/Visitor.php
index de9bb791..8c24ab26 100644
--- a/module/Core/src/Model/Visitor.php
+++ b/module/Core/src/Model/Visitor.php
@@ -36,7 +36,7 @@ final class Visitor
return new self(
$request->getHeaderLine('User-Agent'),
$request->getHeaderLine('Referer'),
- $request->getAttribute(IpAddressMiddlewareFactory::REQUEST_ATTR)
+ $request->getAttribute(IpAddressMiddlewareFactory::REQUEST_ATTR),
);
}
diff --git a/module/Core/src/Model/VisitsParams.php b/module/Core/src/Model/VisitsParams.php
index ffc13dc7..98fcbe82 100644
--- a/module/Core/src/Model/VisitsParams.php
+++ b/module/Core/src/Model/VisitsParams.php
@@ -40,7 +40,7 @@ final class VisitsParams
return new self(
new DateRange($startDate, $endDate),
(int) ($query['page'] ?? 1),
- isset($query['itemsPerPage']) ? (int) $query['itemsPerPage'] : null
+ isset($query['itemsPerPage']) ? (int) $query['itemsPerPage'] : null,
);
}
diff --git a/module/Core/src/Options/AppOptions.php b/module/Core/src/Options/AppOptions.php
index 06810a68..347e41b2 100644
--- a/module/Core/src/Options/AppOptions.php
+++ b/module/Core/src/Options/AppOptions.php
@@ -40,7 +40,6 @@ class AppOptions extends AbstractOptions
}
/**
- * @return string|null
*/
public function getDisableTrackParam(): ?string
{
diff --git a/module/Core/src/Options/DeleteShortUrlsOptions.php b/module/Core/src/Options/DeleteShortUrlsOptions.php
index e2923e19..566ac819 100644
--- a/module/Core/src/Options/DeleteShortUrlsOptions.php
+++ b/module/Core/src/Options/DeleteShortUrlsOptions.php
@@ -8,8 +8,8 @@ use Zend\Stdlib\AbstractOptions;
class DeleteShortUrlsOptions extends AbstractOptions
{
- private $visitsThreshold = 15;
- private $checkVisitsThreshold = true;
+ private int $visitsThreshold = 15;
+ private bool $checkVisitsThreshold = true;
public function getVisitsThreshold(): int
{
diff --git a/module/Core/src/Options/UrlShortenerOptions.php b/module/Core/src/Options/UrlShortenerOptions.php
index 6816ba6e..d08c0483 100644
--- a/module/Core/src/Options/UrlShortenerOptions.php
+++ b/module/Core/src/Options/UrlShortenerOptions.php
@@ -8,20 +8,18 @@ use Zend\Stdlib\AbstractOptions;
class UrlShortenerOptions extends AbstractOptions
{
- // phpcs:disable
- protected $__strictMode__ = false;
- // phpcs:enable
+ protected $__strictMode__ = false; // phpcs:ignore
- private $validateUrl = true;
+ private bool $validateUrl = true;
public function isUrlValidationEnabled(): bool
{
return $this->validateUrl;
}
- protected function setValidateUrl($validateUrl): self
+ protected function setValidateUrl(bool $validateUrl): self
{
- $this->validateUrl = (bool) $validateUrl;
+ $this->validateUrl = $validateUrl;
return $this;
}
}
diff --git a/module/Core/src/Paginator/Adapter/ShortUrlRepositoryAdapter.php b/module/Core/src/Paginator/Adapter/ShortUrlRepositoryAdapter.php
index 2534e3f4..de6c4805 100644
--- a/module/Core/src/Paginator/Adapter/ShortUrlRepositoryAdapter.php
+++ b/module/Core/src/Paginator/Adapter/ShortUrlRepositoryAdapter.php
@@ -22,9 +22,12 @@ class ShortUrlRepositoryAdapter implements AdapterInterface
private array $tags;
private ?DateRange $dateRange;
+ /**
+ * @param string|array|null $orderBy
+ */
public function __construct(
ShortUrlRepositoryInterface $repository,
- $searchTerm = null,
+ ?string $searchTerm = null,
array $tags = [],
$orderBy = null,
?DateRange $dateRange = null
@@ -41,9 +44,8 @@ class ShortUrlRepositoryAdapter implements AdapterInterface
*
* @param int $offset Page offset
* @param int $itemCountPerPage Number of items per page
- * @return array
*/
- public function getItems($offset, $itemCountPerPage): array
+ public function getItems($offset, $itemCountPerPage): array // phpcs:ignore
{
return $this->repository->findList(
$itemCountPerPage,
@@ -51,7 +53,7 @@ class ShortUrlRepositoryAdapter implements AdapterInterface
$this->searchTerm,
$this->tags,
$this->orderBy,
- $this->dateRange
+ $this->dateRange,
);
}
diff --git a/module/Core/src/Paginator/Adapter/VisitsPaginatorAdapter.php b/module/Core/src/Paginator/Adapter/VisitsPaginatorAdapter.php
index 83aff355..e9646c4b 100644
--- a/module/Core/src/Paginator/Adapter/VisitsPaginatorAdapter.php
+++ b/module/Core/src/Paginator/Adapter/VisitsPaginatorAdapter.php
@@ -21,13 +21,13 @@ class VisitsPaginatorAdapter implements AdapterInterface
$this->params = $params;
}
- public function getItems($offset, $itemCountPerPage): array
+ public function getItems($offset, $itemCountPerPage): array // phpcs:ignore
{
return $this->visitRepository->findVisitsByShortCode(
$this->shortCode,
$this->params->getDateRange(),
$itemCountPerPage,
- $offset
+ $offset,
);
}
diff --git a/module/Core/src/Repository/ShortUrlRepository.php b/module/Core/src/Repository/ShortUrlRepository.php
index ac7b5f50..dafc841f 100644
--- a/module/Core/src/Repository/ShortUrlRepository.php
+++ b/module/Core/src/Repository/ShortUrlRepository.php
@@ -52,6 +52,9 @@ class ShortUrlRepository extends EntityRepository implements ShortUrlRepositoryI
return $qb->getQuery()->getResult();
}
+ /**
+ * @param string|array|null $orderBy
+ */
private function processOrderByForList(QueryBuilder $qb, $orderBy): array
{
$isArray = is_array($orderBy);
@@ -117,7 +120,7 @@ class ShortUrlRepository extends EntityRepository implements ShortUrlRepositoryI
$qb->andWhere($qb->expr()->orX(
$qb->expr()->like('s.longUrl', ':searchPattern'),
$qb->expr()->like('s.shortCode', ':searchPattern'),
- $qb->expr()->like('t.name', ':searchPattern')
+ $qb->expr()->like('t.name', ':searchPattern'),
));
$qb->setParameter('searchPattern', '%' . $searchTerm . '%');
}
diff --git a/module/Core/src/Service/ShortUrl/DeleteShortUrlService.php b/module/Core/src/Service/ShortUrl/DeleteShortUrlService.php
index b6d574ee..c9624bf3 100644
--- a/module/Core/src/Service/ShortUrl/DeleteShortUrlService.php
+++ b/module/Core/src/Service/ShortUrl/DeleteShortUrlService.php
@@ -32,7 +32,7 @@ class DeleteShortUrlService implements DeleteShortUrlServiceInterface
if (! $ignoreThreshold && $this->isThresholdReached($shortUrl)) {
throw Exception\DeleteShortUrlException::fromVisitsThreshold(
$this->deleteShortUrlsOptions->getVisitsThreshold(),
- $shortUrl->getShortCode()
+ $shortUrl->getShortCode(),
);
}
diff --git a/module/Core/src/Service/ShortUrl/FindShortCodeTrait.php b/module/Core/src/Service/ShortUrl/FindShortCodeTrait.php
index 81cc0e84..95009704 100644
--- a/module/Core/src/Service/ShortUrl/FindShortCodeTrait.php
+++ b/module/Core/src/Service/ShortUrl/FindShortCodeTrait.php
@@ -11,8 +11,6 @@ use Shlinkio\Shlink\Core\Exception\ShortUrlNotFoundException;
trait FindShortCodeTrait
{
/**
- * @param string $shortCode
- * @return ShortUrl
* @throws ShortUrlNotFoundException
*/
private function findByShortCode(EntityManagerInterface $em, string $shortCode): ShortUrl
diff --git a/module/Core/src/Transformer/ShortUrlDataTransformer.php b/module/Core/src/Transformer/ShortUrlDataTransformer.php
index bb19f997..532fa122 100644
--- a/module/Core/src/Transformer/ShortUrlDataTransformer.php
+++ b/module/Core/src/Transformer/ShortUrlDataTransformer.php
@@ -22,7 +22,7 @@ class ShortUrlDataTransformer implements DataTransformerInterface
/**
* @param ShortUrl $shortUrl
*/
- public function transform($shortUrl): array
+ public function transform($shortUrl): array // phpcs:ignore
{
$longUrl = $shortUrl->getLongUrl();
diff --git a/module/Core/src/Util/TagManagerTrait.php b/module/Core/src/Util/TagManagerTrait.php
index f227afef..27fb22b5 100644
--- a/module/Core/src/Util/TagManagerTrait.php
+++ b/module/Core/src/Util/TagManagerTrait.php
@@ -16,7 +16,6 @@ use function trim;
trait TagManagerTrait
{
/**
- * @param EntityManagerInterface $em
* @param string[] $tags
* @return Collections\Collection|Tag[]
*/
diff --git a/module/Core/test-db/Repository/ShortUrlRepositoryTest.php b/module/Core/test-db/Repository/ShortUrlRepositoryTest.php
index 9cd92dc0..81f32bd8 100644
--- a/module/Core/test-db/Repository/ShortUrlRepositoryTest.php
+++ b/module/Core/test-db/Repository/ShortUrlRepositoryTest.php
@@ -43,7 +43,7 @@ class ShortUrlRepositoryTest extends DatabaseTestCase
$notYetValid = new ShortUrl(
'bar',
- ShortUrlMeta::createFromParams(Chronos::now()->addMonth(), null, 'bar_very_long_text')
+ ShortUrlMeta::createFromParams(Chronos::now()->addMonth(), null, 'bar_very_long_text'),
);
$this->getEntityManager()->persist($notYetValid);
@@ -82,11 +82,11 @@ class ShortUrlRepositoryTest extends DatabaseTestCase
$this->assertSame($withDomain, $this->repo->findOneByShortCode($withDomain->getShortCode(), 'example.com'));
$this->assertSame(
$withDomainDuplicatingRegular,
- $this->repo->findOneByShortCode($withDomainDuplicatingRegular->getShortCode(), 'doma.in')
+ $this->repo->findOneByShortCode($withDomainDuplicatingRegular->getShortCode(), 'doma.in'),
);
$this->assertSame(
$regularOne,
- $this->repo->findOneByShortCode($withDomainDuplicatingRegular->getShortCode(), 'other-domain.com')
+ $this->repo->findOneByShortCode($withDomainDuplicatingRegular->getShortCode(), 'other-domain.com'),
);
$this->assertNull($this->repo->findOneByShortCode('invalid'));
$this->assertNull($this->repo->findOneByShortCode($withDomain->getShortCode()));
@@ -160,7 +160,7 @@ class ShortUrlRepositoryTest extends DatabaseTestCase
$this->assertCount(
2,
- $this->repo->findList(null, null, null, [], null, new DateRange(Chronos::now()->subDays(2)))
+ $this->repo->findList(null, null, null, [], null, new DateRange(Chronos::now()->subDays(2))),
);
$this->assertEquals(2, $this->repo->countList(null, [], new DateRange(Chronos::now()->subDays(2))));
}
@@ -192,7 +192,7 @@ class ShortUrlRepositoryTest extends DatabaseTestCase
$shortUrlWithDomain = new ShortUrl(
'foo',
- ShortUrlMeta::createFromRawData(['domain' => 'doma.in', 'customSlug' => 'another-slug'])
+ ShortUrlMeta::createFromRawData(['domain' => 'doma.in', 'customSlug' => 'another-slug']),
);
$this->getEntityManager()->persist($shortUrlWithDomain);
diff --git a/module/Core/test-db/Repository/TagRepositoryTest.php b/module/Core/test-db/Repository/TagRepositoryTest.php
index 9c5ab574..94e38f53 100644
--- a/module/Core/test-db/Repository/TagRepositoryTest.php
+++ b/module/Core/test-db/Repository/TagRepositoryTest.php
@@ -22,13 +22,13 @@ class TagRepositoryTest extends DatabaseTestCase
}
/** @test */
- public function deleteByNameDoesNothingWhenEmptyListIsProvided()
+ public function deleteByNameDoesNothingWhenEmptyListIsProvided(): void
{
$this->assertEquals(0, $this->repo->deleteByName([]));
}
/** @test */
- public function allTagsWhichMatchNameAreDeleted()
+ public function allTagsWhichMatchNameAreDeleted(): void
{
$names = ['foo', 'bar', 'baz'];
$toDelete = ['foo', 'baz'];
diff --git a/module/Core/test-db/Repository/VisitRepositoryTest.php b/module/Core/test-db/Repository/VisitRepositoryTest.php
index bbccea41..80207d5a 100644
--- a/module/Core/test-db/Repository/VisitRepositoryTest.php
+++ b/module/Core/test-db/Repository/VisitRepositoryTest.php
@@ -85,10 +85,10 @@ class VisitRepositoryTest extends DatabaseTestCase
$this->assertCount(6, $this->repo->findVisitsByShortCode($shortUrl->getShortCode()));
$this->assertCount(2, $this->repo->findVisitsByShortCode($shortUrl->getShortCode(), new DateRange(
Chronos::parse('2016-01-02'),
- Chronos::parse('2016-01-03')
+ Chronos::parse('2016-01-03'),
)));
$this->assertCount(4, $this->repo->findVisitsByShortCode($shortUrl->getShortCode(), new DateRange(
- Chronos::parse('2016-01-03')
+ Chronos::parse('2016-01-03'),
)));
$this->assertCount(3, $this->repo->findVisitsByShortCode($shortUrl->getShortCode(), null, 3, 2));
$this->assertCount(2, $this->repo->findVisitsByShortCode($shortUrl->getShortCode(), null, 5, 4));
@@ -110,10 +110,10 @@ class VisitRepositoryTest extends DatabaseTestCase
$this->assertEquals(6, $this->repo->countVisitsByShortCode($shortUrl->getShortCode()));
$this->assertEquals(2, $this->repo->countVisitsByShortCode($shortUrl->getShortCode(), new DateRange(
Chronos::parse('2016-01-02'),
- Chronos::parse('2016-01-03')
+ Chronos::parse('2016-01-03'),
)));
$this->assertEquals(4, $this->repo->countVisitsByShortCode($shortUrl->getShortCode(), new DateRange(
- Chronos::parse('2016-01-03')
+ Chronos::parse('2016-01-03'),
)));
}
}
diff --git a/module/Core/test/Action/PixelActionTest.php b/module/Core/test/Action/PixelActionTest.php
index 682d5e17..e527e501 100644
--- a/module/Core/test/Action/PixelActionTest.php
+++ b/module/Core/test/Action/PixelActionTest.php
@@ -30,7 +30,7 @@ class PixelActionTest extends TestCase
$this->action = new PixelAction(
$this->urlShortener->reveal(),
$this->visitTracker->reveal(),
- new AppOptions()
+ new AppOptions(),
);
}
@@ -39,7 +39,7 @@ class PixelActionTest extends TestCase
{
$shortCode = 'abc123';
$this->urlShortener->shortCodeToUrl($shortCode, '')->willReturn(
- new ShortUrl('http://domain.com/foo/bar')
+ new ShortUrl('http://domain.com/foo/bar'),
)->shouldBeCalledOnce();
$this->visitTracker->track(Argument::cetera())->shouldBeCalledOnce();
diff --git a/module/Core/test/Action/QrCodeActionTest.php b/module/Core/test/Action/QrCodeActionTest.php
index 0f5a0c7d..ace004a8 100644
--- a/module/Core/test/Action/QrCodeActionTest.php
+++ b/module/Core/test/Action/QrCodeActionTest.php
@@ -70,7 +70,7 @@ class QrCodeActionTest extends TestCase
$resp = $this->action->process(
(new ServerRequest())->withAttribute('shortCode', $shortCode),
- $delegate->reveal()
+ $delegate->reveal(),
);
$this->assertInstanceOf(QrCodeResponse::class, $resp);
diff --git a/module/Core/test/Action/RedirectActionTest.php b/module/Core/test/Action/RedirectActionTest.php
index 812857d4..a6b0dbdd 100644
--- a/module/Core/test/Action/RedirectActionTest.php
+++ b/module/Core/test/Action/RedirectActionTest.php
@@ -33,7 +33,7 @@ class RedirectActionTest extends TestCase
$this->action = new RedirectAction(
$this->urlShortener->reveal(),
$this->visitTracker->reveal(),
- new Options\AppOptions(['disableTrackParam' => 'foobar'])
+ new Options\AppOptions(['disableTrackParam' => 'foobar']),
);
}
@@ -46,7 +46,7 @@ class RedirectActionTest extends TestCase
$shortCode = 'abc123';
$shortUrl = new ShortUrl('http://domain.com/foo/bar?some=thing');
$shortCodeToUrl = $this->urlShortener->shortCodeToUrl($shortCode, '')->willReturn($shortUrl);
- $track = $this->visitTracker->track(Argument::cetera())->will(function () {
+ $track = $this->visitTracker->track(Argument::cetera())->will(function (): void {
});
$request = (new ServerRequest())->withAttribute('shortCode', $shortCode)->withQueryParams($query);
diff --git a/module/Core/test/ConfigProviderTest.php b/module/Core/test/ConfigProviderTest.php
index 5077c61e..df3a38e4 100644
--- a/module/Core/test/ConfigProviderTest.php
+++ b/module/Core/test/ConfigProviderTest.php
@@ -17,7 +17,7 @@ class ConfigProviderTest extends TestCase
}
/** @test */
- public function properConfigIsReturned()
+ public function properConfigIsReturned(): void
{
$config = $this->configProvider->__invoke();
diff --git a/module/Core/test/Entity/TagTest.php b/module/Core/test/Entity/TagTest.php
index 06a921e7..01b2f6ea 100644
--- a/module/Core/test/Entity/TagTest.php
+++ b/module/Core/test/Entity/TagTest.php
@@ -10,7 +10,7 @@ use Shlinkio\Shlink\Core\Entity\Tag;
class TagTest extends TestCase
{
/** @test */
- public function jsonSerializationOfTagsReturnsItsStringRepresentation()
+ public function jsonSerializationOfTagsReturnsItsStringRepresentation(): void
{
$tag = new Tag('This is my name');
$this->assertEquals((string) $tag, $tag->jsonSerialize());
diff --git a/module/Core/test/ErrorHandler/NotFoundRedirectHandlerTest.php b/module/Core/test/ErrorHandler/NotFoundRedirectHandlerTest.php
index 7672fbab..0dca53c4 100644
--- a/module/Core/test/ErrorHandler/NotFoundRedirectHandlerTest.php
+++ b/module/Core/test/ErrorHandler/NotFoundRedirectHandlerTest.php
@@ -73,9 +73,9 @@ class NotFoundRedirectHandlerTest extends TestCase
'',
$this->prophesize(MiddlewareInterface::class)->reveal(),
['GET'],
- RedirectAction::class
- )
- )
+ RedirectAction::class,
+ ),
+ ),
)
->withUri(new Uri('/abc123')),
'invalidShortUrl',
diff --git a/module/Core/test/ErrorHandler/NotFoundTemplateHandlerTest.php b/module/Core/test/ErrorHandler/NotFoundTemplateHandlerTest.php
index a9e2c4af..bf978c9e 100644
--- a/module/Core/test/ErrorHandler/NotFoundTemplateHandlerTest.php
+++ b/module/Core/test/ErrorHandler/NotFoundTemplateHandlerTest.php
@@ -49,7 +49,7 @@ class NotFoundTemplateHandlerTest extends TestCase
yield [
$request->withAttribute(
RouteResult::class,
- RouteResult::fromRoute(new Route('', $this->prophesize(MiddlewareInterface::class)->reveal()))
+ RouteResult::fromRoute(new Route('', $this->prophesize(MiddlewareInterface::class)->reveal())),
),
NotFoundTemplateHandler::INVALID_SHORT_CODE_TEMPLATE,
];
diff --git a/module/Core/test/EventDispatcher/LocateShortUrlVisitTest.php b/module/Core/test/EventDispatcher/LocateShortUrlVisitTest.php
index 0d79539e..5f40bb7b 100644
--- a/module/Core/test/EventDispatcher/LocateShortUrlVisitTest.php
+++ b/module/Core/test/EventDispatcher/LocateShortUrlVisitTest.php
@@ -47,7 +47,7 @@ class LocateShortUrlVisitTest extends TestCase
$this->em->reveal(),
$this->logger->reveal(),
$this->dbUpdater->reveal(),
- $this->eventDispatcher->reveal()
+ $this->eventDispatcher->reveal(),
);
}
@@ -59,7 +59,7 @@ class LocateShortUrlVisitTest extends TestCase
$logWarning = $this->logger->warning('Tried to locate visit with id "{visitId}", but it does not exist.', [
'visitId' => 123,
]);
- $dispatch = $this->eventDispatcher->dispatch(new VisitLocated('123'))->will(function () {
+ $dispatch = $this->eventDispatcher->dispatch(new VisitLocated('123'))->will(function (): void {
});
($this->locateVisit)($event);
@@ -76,16 +76,16 @@ class LocateShortUrlVisitTest extends TestCase
{
$event = new ShortUrlVisited('123');
$findVisit = $this->em->find(Visit::class, '123')->willReturn(
- new Visit(new ShortUrl(''), new Visitor('', '', '1.2.3.4'))
+ new Visit(new ShortUrl(''), new Visitor('', '', '1.2.3.4')),
);
$resolveLocation = $this->ipLocationResolver->resolveIpLocation(Argument::cetera())->willThrow(
- WrongIpException::class
+ WrongIpException::class,
);
$logWarning = $this->logger->warning(
Argument::containingString('Tried to locate visit with id "{visitId}", but its address seems to be wrong.'),
- Argument::type('array')
+ Argument::type('array'),
);
- $dispatch = $this->eventDispatcher->dispatch(new VisitLocated('123'))->will(function () {
+ $dispatch = $this->eventDispatcher->dispatch(new VisitLocated('123'))->will(function (): void {
});
($this->locateVisit)($event);
@@ -105,10 +105,10 @@ class LocateShortUrlVisitTest extends TestCase
{
$event = new ShortUrlVisited('123');
$findVisit = $this->em->find(Visit::class, '123')->willReturn($visit);
- $flush = $this->em->flush()->will(function () {
+ $flush = $this->em->flush()->will(function (): void {
});
$resolveIp = $this->ipLocationResolver->resolveIpLocation(Argument::any());
- $dispatch = $this->eventDispatcher->dispatch(new VisitLocated('123'))->will(function () {
+ $dispatch = $this->eventDispatcher->dispatch(new VisitLocated('123'))->will(function (): void {
});
($this->locateVisit)($event);
@@ -139,10 +139,10 @@ class LocateShortUrlVisitTest extends TestCase
$event = new ShortUrlVisited('123');
$findVisit = $this->em->find(Visit::class, '123')->willReturn($visit);
- $flush = $this->em->flush()->will(function () {
+ $flush = $this->em->flush()->will(function (): void {
});
$resolveIp = $this->ipLocationResolver->resolveIpLocation($ipAddr)->willReturn($location);
- $dispatch = $this->eventDispatcher->dispatch(new VisitLocated('123'))->will(function () {
+ $dispatch = $this->eventDispatcher->dispatch(new VisitLocated('123'))->will(function (): void {
});
($this->locateVisit)($event);
@@ -165,11 +165,11 @@ class LocateShortUrlVisitTest extends TestCase
$event = new ShortUrlVisited('123');
$findVisit = $this->em->find(Visit::class, '123')->willReturn($visit);
- $flush = $this->em->flush()->will(function () {
+ $flush = $this->em->flush()->will(function (): void {
});
$resolveIp = $this->ipLocationResolver->resolveIpLocation($ipAddr)->willReturn($location);
$checkUpdateDb = $this->dbUpdater->checkDbUpdate(Argument::cetera())->willThrow($e);
- $dispatch = $this->eventDispatcher->dispatch(new VisitLocated('123'))->will(function () {
+ $dispatch = $this->eventDispatcher->dispatch(new VisitLocated('123'))->will(function (): void {
});
($this->locateVisit)($event);
@@ -181,7 +181,7 @@ class LocateShortUrlVisitTest extends TestCase
$checkUpdateDb->shouldHaveBeenCalledOnce();
$this->logger->warning(
'GeoLite2 database update failed. Proceeding with old version. {e}',
- ['e' => $e]
+ ['e' => $e],
)->shouldHaveBeenCalledOnce();
$dispatch->shouldHaveBeenCalledOnce();
}
@@ -196,15 +196,15 @@ class LocateShortUrlVisitTest extends TestCase
$event = new ShortUrlVisited('123');
$findVisit = $this->em->find(Visit::class, '123')->willReturn($visit);
- $flush = $this->em->flush()->will(function () {
+ $flush = $this->em->flush()->will(function (): void {
});
$resolveIp = $this->ipLocationResolver->resolveIpLocation($ipAddr)->willReturn($location);
$checkUpdateDb = $this->dbUpdater->checkDbUpdate(Argument::cetera())->willThrow($e);
$logError = $this->logger->error(
'GeoLite2 database download failed. It is not possible to locate visit with id {visitId}. {e}',
- ['e' => $e, 'visitId' => 123]
+ ['e' => $e, 'visitId' => 123],
);
- $dispatch = $this->eventDispatcher->dispatch(new VisitLocated('123'))->will(function () {
+ $dispatch = $this->eventDispatcher->dispatch(new VisitLocated('123'))->will(function (): void {
});
($this->locateVisit)($event);
diff --git a/module/Core/test/Exception/DeleteShortUrlExceptionTest.php b/module/Core/test/Exception/DeleteShortUrlExceptionTest.php
index f2207c54..6e45521f 100644
--- a/module/Core/test/Exception/DeleteShortUrlExceptionTest.php
+++ b/module/Core/test/Exception/DeleteShortUrlExceptionTest.php
@@ -43,7 +43,7 @@ class DeleteShortUrlExceptionTest extends TestCase
return [$number, $shortCode = generateRandomShortCode(6), sprintf(
'Impossible to delete short URL with short code "%s" since it has more than "%s" visits.',
$shortCode,
- $number
+ $number,
)];
});
}
diff --git a/module/Core/test/Middleware/QrCodeCacheMiddlewareTest.php b/module/Core/test/Middleware/QrCodeCacheMiddlewareTest.php
index 6bda041f..10f6383e 100644
--- a/module/Core/test/Middleware/QrCodeCacheMiddlewareTest.php
+++ b/module/Core/test/Middleware/QrCodeCacheMiddlewareTest.php
@@ -26,7 +26,7 @@ class QrCodeCacheMiddlewareTest extends TestCase
}
/** @test */
- public function noCachedPathFallsBackToNextMiddleware()
+ public function noCachedPathFallsBackToNextMiddleware(): void
{
$delegate = $this->prophesize(RequestHandlerInterface::class);
$delegate->handle(Argument::any())->willReturn(new Response())->shouldBeCalledOnce();
@@ -37,7 +37,7 @@ class QrCodeCacheMiddlewareTest extends TestCase
}
/** @test */
- public function cachedPathReturnsCacheContent()
+ public function cachedPathReturnsCacheContent(): void
{
$isCalled = false;
$uri = (new Uri())->withPath('/foo');
diff --git a/module/Core/test/Paginator/Adapter/ShortUrlRepositoryAdapterTest.php b/module/Core/test/Paginator/Adapter/ShortUrlRepositoryAdapterTest.php
index f5192fde..dd2fa24a 100644
--- a/module/Core/test/Paginator/Adapter/ShortUrlRepositoryAdapterTest.php
+++ b/module/Core/test/Paginator/Adapter/ShortUrlRepositoryAdapterTest.php
@@ -21,11 +21,12 @@ class ShortUrlRepositoryAdapterTest extends TestCase
}
/**
+ * @param string|array|null $orderBy
* @test
* @dataProvider provideFilteringArgs
*/
public function getItemsFallsBackToFindList(
- $searchTerm = null,
+ ?string $searchTerm = null,
array $tags = [],
?DateRange $dateRange = null,
$orderBy = null
@@ -40,8 +41,11 @@ class ShortUrlRepositoryAdapterTest extends TestCase
* @test
* @dataProvider provideFilteringArgs
*/
- public function countFallsBackToCountList($searchTerm = null, array $tags = [], ?DateRange $dateRange = null): void
- {
+ public function countFallsBackToCountList(
+ ?string $searchTerm = null,
+ array $tags = [],
+ ?DateRange $dateRange = null
+ ): void {
$adapter = new ShortUrlRepositoryAdapter($this->repo->reveal(), $searchTerm, $tags, null, $dateRange);
$this->repo->countList($searchTerm, $tags, $dateRange)->shouldBeCalledOnce();
diff --git a/module/Core/test/Service/ShortUrl/DeleteShortUrlServiceTest.php b/module/Core/test/Service/ShortUrl/DeleteShortUrlServiceTest.php
index b708e465..e7aefd9d 100644
--- a/module/Core/test/Service/ShortUrl/DeleteShortUrlServiceTest.php
+++ b/module/Core/test/Service/ShortUrl/DeleteShortUrlServiceTest.php
@@ -29,7 +29,7 @@ class DeleteShortUrlServiceTest extends TestCase
public function setUp(): void
{
$shortUrl = (new ShortUrl(''))->setVisits(
- new ArrayCollection(map(range(0, 10), fn () => new Visit(new ShortUrl(''), Visitor::emptyInstance())))
+ new ArrayCollection(map(range(0, 10), fn () => new Visit(new ShortUrl(''), Visitor::emptyInstance()))),
);
$this->shortCode = $shortUrl->getShortCode();
@@ -48,7 +48,7 @@ class DeleteShortUrlServiceTest extends TestCase
$this->expectException(DeleteShortUrlException::class);
$this->expectExceptionMessage(sprintf(
'Impossible to delete short URL with short code "%s" since it has more than "5" visits.',
- $this->shortCode
+ $this->shortCode,
));
$service->deleteByShortCode($this->shortCode);
diff --git a/module/Core/test/Service/ShortUrlServiceTest.php b/module/Core/test/Service/ShortUrlServiceTest.php
index d1f8697b..93cb7ad0 100644
--- a/module/Core/test/Service/ShortUrlServiceTest.php
+++ b/module/Core/test/Service/ShortUrlServiceTest.php
@@ -97,7 +97,7 @@ class ShortUrlServiceTest extends TestCase
Chronos::parse('2017-01-01 00:00:00')->toAtomString(),
Chronos::parse('2017-01-05 00:00:00')->toAtomString(),
null,
- 5
+ 5,
));
$this->assertSame($shortUrl, $result);
diff --git a/module/Core/test/Service/UrlShortenerTest.php b/module/Core/test/Service/UrlShortenerTest.php
index 9d183381..73e4186a 100644
--- a/module/Core/test/Service/UrlShortenerTest.php
+++ b/module/Core/test/Service/UrlShortenerTest.php
@@ -42,7 +42,7 @@ class UrlShortenerTest extends TestCase
$this->em->flush()->willReturn(null);
$this->em->commit()->willReturn(null);
$this->em->beginTransaction()->willReturn(null);
- $this->em->persist(Argument::any())->will(function ($arguments) {
+ $this->em->persist(Argument::any())->will(function ($arguments): void {
/** @var ShortUrl $shortUrl */
[$shortUrl] = $arguments;
$shortUrl->setId('10');
@@ -59,7 +59,7 @@ class UrlShortenerTest extends TestCase
$this->urlShortener = new UrlShortener(
$this->urlValidator->reveal(),
$this->em->reveal(),
- new UrlShortenerOptions(['validate_url' => $urlValidationEnabled])
+ new UrlShortenerOptions(['validate_url' => $urlValidationEnabled]),
);
}
@@ -69,7 +69,7 @@ class UrlShortenerTest extends TestCase
$shortUrl = $this->urlShortener->urlToShortCode(
new Uri('http://foobar.com/12345/hello?foo=bar'),
[],
- ShortUrlMeta::createEmpty()
+ ShortUrlMeta::createEmpty(),
);
$this->assertEquals('http://foobar.com/12345/hello?foo=bar', $shortUrl->getLongUrl());
@@ -85,7 +85,7 @@ class UrlShortenerTest extends TestCase
function () use (&$callIndex, $expectedCalls) {
$callIndex++;
return $callIndex < $expectedCalls;
- }
+ },
);
$repo->findBy(Argument::cetera())->willReturn([]);
$getRepo = $this->em->getRepository(ShortUrl::class)->willReturn($repo->reveal());
@@ -93,7 +93,7 @@ class UrlShortenerTest extends TestCase
$shortUrl = $this->urlShortener->urlToShortCode(
new Uri('http://foobar.com/12345/hello?foo=bar'),
[],
- ShortUrlMeta::createEmpty()
+ ShortUrlMeta::createEmpty(),
);
$this->assertEquals('http://foobar.com/12345/hello?foo=bar', $shortUrl->getLongUrl());
@@ -116,7 +116,7 @@ class UrlShortenerTest extends TestCase
$this->urlShortener->urlToShortCode(
new Uri('http://foobar.com/12345/hello?foo=bar'),
[],
- ShortUrlMeta::createEmpty()
+ ShortUrlMeta::createEmpty(),
);
}
@@ -124,13 +124,15 @@ class UrlShortenerTest extends TestCase
public function validatorIsCalledWhenUrlValidationIsEnabled(): void
{
$this->setUrlShortener(true);
- $validateUrl = $this->urlValidator->validateUrl('http://foobar.com/12345/hello?foo=bar')->will(function () {
- });
+ $validateUrl = $this->urlValidator->validateUrl('http://foobar.com/12345/hello?foo=bar')->will(
+ function (): void {
+ },
+ );
$this->urlShortener->urlToShortCode(
new Uri('http://foobar.com/12345/hello?foo=bar'),
[],
- ShortUrlMeta::createEmpty()
+ ShortUrlMeta::createEmpty(),
);
$validateUrl->shouldHaveBeenCalledOnce();
@@ -151,7 +153,7 @@ class UrlShortenerTest extends TestCase
$this->urlShortener->urlToShortCode(
new Uri('http://foobar.com/12345/hello?foo=bar'),
[],
- ShortUrlMeta::createFromRawData(['customSlug' => 'custom-slug'])
+ ShortUrlMeta::createFromRawData(['customSlug' => 'custom-slug']),
);
}
@@ -183,7 +185,7 @@ class UrlShortenerTest extends TestCase
yield [$url, [], ShortUrlMeta::createFromRawData(['findIfExists' => true]), new ShortUrl($url)];
yield [$url, [], ShortUrlMeta::createFromRawData(
- ['findIfExists' => true, 'customSlug' => 'foo']
+ ['findIfExists' => true, 'customSlug' => 'foo'],
), new ShortUrl($url)];
yield [
$url,
diff --git a/module/Core/test/Service/VisitServiceTest.php b/module/Core/test/Service/VisitServiceTest.php
index e09b0a4c..26e95557 100644
--- a/module/Core/test/Service/VisitServiceTest.php
+++ b/module/Core/test/Service/VisitServiceTest.php
@@ -42,21 +42,21 @@ class VisitServiceTest extends TestCase
{
$unlocatedVisits = map(
range(1, 200),
- fn (int $i) => new Visit(new ShortUrl(sprintf('short_code_%s', $i)), Visitor::emptyInstance())
+ fn (int $i) => new Visit(new ShortUrl(sprintf('short_code_%s', $i)), Visitor::emptyInstance()),
);
$repo = $this->prophesize(VisitRepository::class);
$findUnlocatedVisits = $repo->findUnlocatedVisits(false)->willReturn($unlocatedVisits);
$getRepo = $this->em->getRepository(Visit::class)->willReturn($repo->reveal());
- $persist = $this->em->persist(Argument::type(Visit::class))->will(function () {
+ $persist = $this->em->persist(Argument::type(Visit::class))->will(function (): void {
});
- $flush = $this->em->flush()->will(function () {
+ $flush = $this->em->flush()->will(function (): void {
});
- $clear = $this->em->clear()->will(function () {
+ $clear = $this->em->clear()->will(function (): void {
});
- $this->visitService->locateUnlocatedVisits(fn () => Location::emptyInstance(), function () {
+ $this->visitService->locateUnlocatedVisits(fn () => Location::emptyInstance(), function (): void {
$args = func_get_args();
$this->assertInstanceOf(VisitLocation::class, array_shift($args));
@@ -84,14 +84,14 @@ class VisitServiceTest extends TestCase
$findUnlocatedVisits = $repo->findUnlocatedVisits(false)->willReturn($unlocatedVisits);
$getRepo = $this->em->getRepository(Visit::class)->willReturn($repo->reveal());
- $persist = $this->em->persist(Argument::type(Visit::class))->will(function () {
+ $persist = $this->em->persist(Argument::type(Visit::class))->will(function (): void {
});
- $flush = $this->em->flush()->will(function () {
+ $flush = $this->em->flush()->will(function (): void {
});
- $clear = $this->em->clear()->will(function () {
+ $clear = $this->em->clear()->will(function (): void {
});
- $this->visitService->locateUnlocatedVisits(function () use ($isNonLocatableAddress) {
+ $this->visitService->locateUnlocatedVisits(function () use ($isNonLocatableAddress): void {
throw $isNonLocatableAddress
? new IpCannotBeLocatedException('Cannot be located')
: IpCannotBeLocatedException::forError(new Exception(''));
diff --git a/module/Core/test/Util/UrlValidatorTest.php b/module/Core/test/Util/UrlValidatorTest.php
index e437c8e7..b519a2bb 100644
--- a/module/Core/test/Util/UrlValidatorTest.php
+++ b/module/Core/test/Util/UrlValidatorTest.php
@@ -45,7 +45,7 @@ class UrlValidatorTest extends TestCase
$request = $this->httpClient->request(
RequestMethodInterface::METHOD_GET,
$expectedUrl,
- [RequestOptions::ALLOW_REDIRECTS => ['max' => 15]]
+ [RequestOptions::ALLOW_REDIRECTS => ['max' => 15]],
)->willReturn(new Response());
$this->urlValidator->validateUrl($expectedUrl);
diff --git a/module/Rest/src/Action/ShortUrl/AbstractCreateShortUrlAction.php b/module/Rest/src/Action/ShortUrl/AbstractCreateShortUrlAction.php
index d6deae27..1e840a7f 100644
--- a/module/Rest/src/Action/ShortUrl/AbstractCreateShortUrlAction.php
+++ b/module/Rest/src/Action/ShortUrl/AbstractCreateShortUrlAction.php
@@ -43,8 +43,6 @@ abstract class AbstractCreateShortUrlAction extends AbstractRestAction
}
/**
- * @param Request $request
- * @return CreateShortUrlData
* @throws ValidationException
*/
abstract protected function buildShortUrlData(Request $request): CreateShortUrlData;
diff --git a/module/Rest/src/Action/ShortUrl/CreateShortUrlAction.php b/module/Rest/src/Action/ShortUrl/CreateShortUrlAction.php
index e0b0ddac..0335355f 100644
--- a/module/Rest/src/Action/ShortUrl/CreateShortUrlAction.php
+++ b/module/Rest/src/Action/ShortUrl/CreateShortUrlAction.php
@@ -16,8 +16,6 @@ class CreateShortUrlAction extends AbstractCreateShortUrlAction
protected const ROUTE_ALLOWED_METHODS = [self::METHOD_POST];
/**
- * @param Request $request
- * @return CreateShortUrlData
* @throws ValidationException
*/
protected function buildShortUrlData(Request $request): CreateShortUrlData
@@ -35,7 +33,7 @@ class CreateShortUrlAction extends AbstractCreateShortUrlAction
$postData['customSlug'] ?? null,
$postData['maxVisits'] ?? null,
$postData['findIfExists'] ?? null,
- $postData['domain'] ?? null
+ $postData['domain'] ?? null,
);
return new CreateShortUrlData(new Uri($postData['longUrl']), (array) ($postData['tags'] ?? []), $meta);
diff --git a/module/Rest/src/Action/ShortUrl/ListShortUrlsAction.php b/module/Rest/src/Action/ShortUrl/ListShortUrlsAction.php
index 98b48dc5..bd11c30d 100644
--- a/module/Rest/src/Action/ShortUrl/ListShortUrlsAction.php
+++ b/module/Rest/src/Action/ShortUrl/ListShortUrlsAction.php
@@ -37,8 +37,6 @@ class ListShortUrlsAction extends AbstractRestAction
}
/**
- * @param Request $request
- * @return Response
* @throws InvalidArgumentException
*/
public function handle(Request $request): Response
@@ -46,7 +44,7 @@ class ListShortUrlsAction extends AbstractRestAction
$params = $this->queryToListParams($request->getQueryParams());
$shortUrls = $this->shortUrlService->listShortUrls(...$params);
return new JsonResponse(['shortUrls' => $this->serializePaginator($shortUrls, new ShortUrlDataTransformer(
- $this->domainConfig
+ $this->domainConfig,
))]);
}
@@ -69,7 +67,7 @@ class ListShortUrlsAction extends AbstractRestAction
{
return new DateRange(
isset($query['startDate']) ? Chronos::parse($query['startDate']) : null,
- isset($query['endDate']) ? Chronos::parse($query['endDate']) : null
+ isset($query['endDate']) ? Chronos::parse($query['endDate']) : null,
);
}
}
diff --git a/module/Rest/src/Action/ShortUrl/ResolveShortUrlAction.php b/module/Rest/src/Action/ShortUrl/ResolveShortUrlAction.php
index 5089ff22..8408db22 100644
--- a/module/Rest/src/Action/ShortUrl/ResolveShortUrlAction.php
+++ b/module/Rest/src/Action/ShortUrl/ResolveShortUrlAction.php
@@ -32,8 +32,6 @@ class ResolveShortUrlAction extends AbstractRestAction
}
/**
- * @param Request $request
- * @return Response
* @throws InvalidArgumentException
*/
public function handle(Request $request): Response
diff --git a/module/Rest/src/Action/ShortUrl/SingleStepCreateShortUrlAction.php b/module/Rest/src/Action/ShortUrl/SingleStepCreateShortUrlAction.php
index 8a11d1d5..fd8973d9 100644
--- a/module/Rest/src/Action/ShortUrl/SingleStepCreateShortUrlAction.php
+++ b/module/Rest/src/Action/ShortUrl/SingleStepCreateShortUrlAction.php
@@ -30,8 +30,6 @@ class SingleStepCreateShortUrlAction extends AbstractCreateShortUrlAction
}
/**
- * @param Request $request
- * @return CreateShortUrlData
* @throws ValidationException
*/
protected function buildShortUrlData(Request $request): CreateShortUrlData
diff --git a/module/Rest/src/Action/Tag/CreateTagsAction.php b/module/Rest/src/Action/Tag/CreateTagsAction.php
index 645de78d..f603efdc 100644
--- a/module/Rest/src/Action/Tag/CreateTagsAction.php
+++ b/module/Rest/src/Action/Tag/CreateTagsAction.php
@@ -28,9 +28,7 @@ class CreateTagsAction extends AbstractRestAction
* Process an incoming server request and return a response, optionally delegating
* to the next middleware component to create the response.
*
- * @param ServerRequestInterface $request
*
- * @return ResponseInterface
* @throws \InvalidArgumentException
*/
public function handle(ServerRequestInterface $request): ResponseInterface
diff --git a/module/Rest/src/Action/Tag/DeleteTagsAction.php b/module/Rest/src/Action/Tag/DeleteTagsAction.php
index 941e51df..4a2ce881 100644
--- a/module/Rest/src/Action/Tag/DeleteTagsAction.php
+++ b/module/Rest/src/Action/Tag/DeleteTagsAction.php
@@ -28,9 +28,7 @@ class DeleteTagsAction extends AbstractRestAction
* Process an incoming server request and return a response, optionally delegating
* to the next middleware component to create the response.
*
- * @param ServerRequestInterface $request
*
- * @return ResponseInterface
*/
public function handle(ServerRequestInterface $request): ResponseInterface
{
diff --git a/module/Rest/src/Action/Tag/ListTagsAction.php b/module/Rest/src/Action/Tag/ListTagsAction.php
index 78f507e6..53c5272e 100644
--- a/module/Rest/src/Action/Tag/ListTagsAction.php
+++ b/module/Rest/src/Action/Tag/ListTagsAction.php
@@ -28,9 +28,7 @@ class ListTagsAction extends AbstractRestAction
* Process an incoming server request and return a response, optionally delegating
* to the next middleware component to create the response.
*
- * @param ServerRequestInterface $request
*
- * @return ResponseInterface
* @throws \InvalidArgumentException
*/
public function handle(ServerRequestInterface $request): ResponseInterface
diff --git a/module/Rest/src/Action/Tag/UpdateTagAction.php b/module/Rest/src/Action/Tag/UpdateTagAction.php
index b1a3a4b6..b432d29b 100644
--- a/module/Rest/src/Action/Tag/UpdateTagAction.php
+++ b/module/Rest/src/Action/Tag/UpdateTagAction.php
@@ -29,9 +29,7 @@ class UpdateTagAction extends AbstractRestAction
* Process an incoming server request and return a response, optionally delegating
* to the next middleware component to create the response.
*
- * @param ServerRequestInterface $request
*
- * @return ResponseInterface
* @throws \InvalidArgumentException
*/
public function handle(ServerRequestInterface $request): ResponseInterface
diff --git a/module/Rest/src/Authentication/AuthenticationPluginManager.php b/module/Rest/src/Authentication/AuthenticationPluginManager.php
index 16b8bbd1..9449c7c0 100644
--- a/module/Rest/src/Authentication/AuthenticationPluginManager.php
+++ b/module/Rest/src/Authentication/AuthenticationPluginManager.php
@@ -8,5 +8,5 @@ use Zend\ServiceManager\AbstractPluginManager;
class AuthenticationPluginManager extends AbstractPluginManager implements AuthenticationPluginManagerInterface
{
- protected $instanceOf = Plugin\AuthenticationPluginInterface::class;
+ protected $instanceOf = Plugin\AuthenticationPluginInterface::class; // phpcs:ignore
}
diff --git a/module/Rest/src/Authentication/RequestToHttpAuthPlugin.php b/module/Rest/src/Authentication/RequestToHttpAuthPlugin.php
index 91461704..c45bb9a5 100644
--- a/module/Rest/src/Authentication/RequestToHttpAuthPlugin.php
+++ b/module/Rest/src/Authentication/RequestToHttpAuthPlugin.php
@@ -43,7 +43,7 @@ class RequestToHttpAuthPlugin implements RequestToHttpAuthPluginInterface
return array_reduce(
self::SUPPORTED_AUTH_HEADERS,
fn (bool $carry, string $header) => $carry || $request->hasHeader($header),
- false
+ false,
);
}
diff --git a/module/Rest/src/ConfigProvider.php b/module/Rest/src/ConfigProvider.php
index 6352e3c7..b94991ca 100644
--- a/module/Rest/src/ConfigProvider.php
+++ b/module/Rest/src/ConfigProvider.php
@@ -21,7 +21,7 @@ class ConfigProvider
$this->loadConfig = Closure::fromCallable($loadConfig ?? fn (string $glob) => loadConfigFromGlob($glob));
}
- public function __invoke()
+ public function __invoke(): array
{
$config = ($this->loadConfig)(__DIR__ . '/../config/{,*.}config.php');
return $this->applyRoutesPrefix($config);
diff --git a/module/Rest/src/Exception/MissingAuthenticationException.php b/module/Rest/src/Exception/MissingAuthenticationException.php
index c00cb3e0..60636308 100644
--- a/module/Rest/src/Exception/MissingAuthenticationException.php
+++ b/module/Rest/src/Exception/MissingAuthenticationException.php
@@ -22,7 +22,7 @@ class MissingAuthenticationException extends RuntimeException implements Problem
{
$e = new self(sprintf(
'Expected one of the following authentication headers, ["%s"], but none were provided',
- implode('", "', $expectedTypes)
+ implode('", "', $expectedTypes),
));
$e->detail = $e->getMessage();
diff --git a/module/Rest/src/Middleware/BodyParserMiddleware.php b/module/Rest/src/Middleware/BodyParserMiddleware.php
index 5814753e..955041d9 100644
--- a/module/Rest/src/Middleware/BodyParserMiddleware.php
+++ b/module/Rest/src/Middleware/BodyParserMiddleware.php
@@ -23,10 +23,7 @@ class BodyParserMiddleware implements MiddlewareInterface, RequestMethodInterfac
* Process an incoming server request and return a response, optionally delegating
* to the next middleware component to create the response.
*
- * @param Request $request
- * @param RequestHandlerInterface $handler
*
- * @return Response
*/
public function process(Request $request, RequestHandlerInterface $handler): Response
{
@@ -55,8 +52,6 @@ class BodyParserMiddleware implements MiddlewareInterface, RequestMethodInterfac
}
/**
- * @param Request $request
- * @return string
*/
private function getRequestContentType(Request $request): string
{
@@ -66,8 +61,6 @@ class BodyParserMiddleware implements MiddlewareInterface, RequestMethodInterfac
}
/**
- * @param Request $request
- * @return Request
*/
private function parseFromJson(Request $request): Request
{
@@ -81,8 +74,6 @@ class BodyParserMiddleware implements MiddlewareInterface, RequestMethodInterfac
}
/**
- * @param Request $request
- * @return Request
*/
private function parseFromUrlEncoded(Request $request): Request
{
diff --git a/module/Rest/src/Middleware/EmptyResponseImplicitOptionsMiddlewareFactory.php b/module/Rest/src/Middleware/EmptyResponseImplicitOptionsMiddlewareFactory.php
index 5075e244..19995597 100644
--- a/module/Rest/src/Middleware/EmptyResponseImplicitOptionsMiddlewareFactory.php
+++ b/module/Rest/src/Middleware/EmptyResponseImplicitOptionsMiddlewareFactory.php
@@ -9,7 +9,7 @@ use Zend\Expressive\Router\Middleware\ImplicitOptionsMiddleware;
class EmptyResponseImplicitOptionsMiddlewareFactory
{
- public function __invoke()
+ public function __invoke(): ImplicitOptionsMiddleware
{
return new ImplicitOptionsMiddleware(fn () => new EmptyResponse());
}
diff --git a/module/Rest/test-api/Fixtures/ShortUrlsFixture.php b/module/Rest/test-api/Fixtures/ShortUrlsFixture.php
index cc359047..0b5a841a 100644
--- a/module/Rest/test-api/Fixtures/ShortUrlsFixture.php
+++ b/module/Rest/test-api/Fixtures/ShortUrlsFixture.php
@@ -16,37 +16,36 @@ class ShortUrlsFixture extends AbstractFixture
/**
* Load data fixtures with the passed EntityManager
*
- * @param ObjectManager $manager
*/
public function load(ObjectManager $manager): void
{
$abcShortUrl = $this->setShortUrlDate(
new ShortUrl('https://shlink.io', ShortUrlMeta::createFromRawData(['customSlug' => 'abc123'])),
- '2018-05-01'
+ '2018-05-01',
);
$manager->persist($abcShortUrl);
$defShortUrl = $this->setShortUrlDate(new ShortUrl(
'https://blog.alejandrocelaya.com/2017/12/09/acmailer-7-0-the-most-important-release-in-a-long-time/',
- ShortUrlMeta::createFromParams(Chronos::parse('2020-05-01'), null, 'def456')
+ ShortUrlMeta::createFromParams(Chronos::parse('2020-05-01'), null, 'def456'),
), '2019-01-01 00:00:10');
$manager->persist($defShortUrl);
$customShortUrl = $this->setShortUrlDate(new ShortUrl(
'https://shlink.io',
- ShortUrlMeta::createFromParams(null, null, 'custom', 2)
+ ShortUrlMeta::createFromParams(null, null, 'custom', 2),
), '2019-01-01 00:00:20');
$manager->persist($customShortUrl);
$withDomainShortUrl = $this->setShortUrlDate(new ShortUrl(
'https://blog.alejandrocelaya.com/2019/04/27/considerations-to-properly-use-open-source-software-projects/',
- ShortUrlMeta::createFromRawData(['domain' => 'example.com', 'customSlug' => 'ghi789'])
+ ShortUrlMeta::createFromRawData(['domain' => 'example.com', 'customSlug' => 'ghi789']),
), '2019-01-01 00:00:30');
$manager->persist($withDomainShortUrl);
$withDomainAndSlugShortUrl = $this->setShortUrlDate(new ShortUrl(
'https://google.com',
- ShortUrlMeta::createFromRawData(['domain' => 'some-domain.com', 'customSlug' => 'custom-with-domain'])
+ ShortUrlMeta::createFromRawData(['domain' => 'some-domain.com', 'customSlug' => 'custom-with-domain']),
), '2018-10-20');
$manager->persist($withDomainAndSlugShortUrl);
diff --git a/module/Rest/test-api/Middleware/AuthenticationTest.php b/module/Rest/test-api/Middleware/AuthenticationTest.php
index 58ab396d..aa90451f 100644
--- a/module/Rest/test-api/Middleware/AuthenticationTest.php
+++ b/module/Rest/test-api/Middleware/AuthenticationTest.php
@@ -18,7 +18,7 @@ class AuthenticationTest extends ApiTestCase
{
$expectedDetail = sprintf(
'Expected one of the following authentication headers, ["%s"], but none were provided',
- implode('", "', RequestToHttpAuthPlugin::SUPPORTED_AUTH_HEADERS)
+ implode('", "', RequestToHttpAuthPlugin::SUPPORTED_AUTH_HEADERS),
);
$resp = $this->callApi(self::METHOD_GET, '/short-urls');
diff --git a/module/Rest/test/Action/HealthActionTest.php b/module/Rest/test/Action/HealthActionTest.php
index 23d7dd88..ed92edc2 100644
--- a/module/Rest/test/Action/HealthActionTest.php
+++ b/module/Rest/test/Action/HealthActionTest.php
@@ -25,7 +25,7 @@ class HealthActionTest extends TestCase
}
/** @test */
- public function passResponseIsReturnedWhenConnectionSucceeds()
+ public function passResponseIsReturnedWhenConnectionSucceeds(): void
{
$ping = $this->conn->ping()->willReturn(true);
@@ -45,7 +45,7 @@ class HealthActionTest extends TestCase
}
/** @test */
- public function failResponseIsReturnedWhenConnectionFails()
+ public function failResponseIsReturnedWhenConnectionFails(): void
{
$ping = $this->conn->ping()->willReturn(false);
@@ -65,7 +65,7 @@ class HealthActionTest extends TestCase
}
/** @test */
- public function failResponseIsReturnedWhenConnectionThrowsException()
+ public function failResponseIsReturnedWhenConnectionThrowsException(): void
{
$ping = $this->conn->ping()->willThrow(Exception::class);
diff --git a/module/Rest/test/Action/ShortUrl/CreateShortUrlActionTest.php b/module/Rest/test/Action/ShortUrl/CreateShortUrlActionTest.php
index 5dd76142..416fcdf6 100644
--- a/module/Rest/test/Action/ShortUrl/CreateShortUrlActionTest.php
+++ b/module/Rest/test/Action/ShortUrl/CreateShortUrlActionTest.php
@@ -52,7 +52,7 @@ class CreateShortUrlActionTest extends TestCase
$shorten = $this->urlShortener->urlToShortCode(
Argument::type(Uri::class),
Argument::type('array'),
- $expectedMeta
+ $expectedMeta,
)->willReturn($shortUrl);
$request = ServerRequestFactory::fromGlobals()->withParsedBody($body);
diff --git a/module/Rest/test/Action/ShortUrl/DeleteShortUrlActionTest.php b/module/Rest/test/Action/ShortUrl/DeleteShortUrlActionTest.php
index df0cde37..198909c5 100644
--- a/module/Rest/test/Action/ShortUrl/DeleteShortUrlActionTest.php
+++ b/module/Rest/test/Action/ShortUrl/DeleteShortUrlActionTest.php
@@ -25,7 +25,7 @@ class DeleteShortUrlActionTest extends TestCase
/** @test */
public function emptyResponseIsReturnedIfProperlyDeleted(): void
{
- $deleteByShortCode = $this->service->deleteByShortCode(Argument::any())->will(function () {
+ $deleteByShortCode = $this->service->deleteByShortCode(Argument::any())->will(function (): void {
});
$resp = $this->action->handle(new ServerRequest());
diff --git a/module/Rest/test/Action/ShortUrl/EditShortUrlActionTest.php b/module/Rest/test/Action/ShortUrl/EditShortUrlActionTest.php
index e85c2f04..a43b0d95 100644
--- a/module/Rest/test/Action/ShortUrl/EditShortUrlActionTest.php
+++ b/module/Rest/test/Action/ShortUrl/EditShortUrlActionTest.php
@@ -44,7 +44,7 @@ class EditShortUrlActionTest extends TestCase
'maxVisits' => 5,
]);
$updateMeta = $this->shortUrlService->updateMetadataByShortCode(Argument::cetera())->willReturn(
- new ShortUrl('')
+ new ShortUrl(''),
);
$resp = $this->action->handle($request);
diff --git a/module/Rest/test/Action/ShortUrl/EditShortUrlTagsActionTest.php b/module/Rest/test/Action/ShortUrl/EditShortUrlTagsActionTest.php
index e8a398fb..95421d10 100644
--- a/module/Rest/test/Action/ShortUrl/EditShortUrlTagsActionTest.php
+++ b/module/Rest/test/Action/ShortUrl/EditShortUrlTagsActionTest.php
@@ -39,7 +39,7 @@ class EditShortUrlTagsActionTest extends TestCase
$response = $this->action->handle(
(new ServerRequest())->withAttribute('shortCode', 'abc123')
- ->withParsedBody(['tags' => []])
+ ->withParsedBody(['tags' => []]),
);
$this->assertEquals(200, $response->getStatusCode());
}
diff --git a/module/Rest/test/Action/ShortUrl/ListShortUrlsActionTest.php b/module/Rest/test/Action/ShortUrl/ListShortUrlsActionTest.php
index 1e083eb9..ce943107 100644
--- a/module/Rest/test/Action/ShortUrl/ListShortUrlsActionTest.php
+++ b/module/Rest/test/Action/ShortUrl/ListShortUrlsActionTest.php
@@ -50,7 +50,7 @@ class ListShortUrlsActionTest extends TestCase
$expectedSearchTerm,
$expectedTags,
$expectedOrderBy,
- $expectedDateRange
+ $expectedDateRange,
)->willReturn(new Paginator(new ArrayAdapter()));
/** @var JsonResponse $response */
diff --git a/module/Rest/test/Action/ShortUrl/ResolveShortUrlActionTest.php b/module/Rest/test/Action/ShortUrl/ResolveShortUrlActionTest.php
index 3fcc8e75..8c3d0270 100644
--- a/module/Rest/test/Action/ShortUrl/ResolveShortUrlActionTest.php
+++ b/module/Rest/test/Action/ShortUrl/ResolveShortUrlActionTest.php
@@ -29,7 +29,7 @@ class ResolveShortUrlActionTest extends TestCase
{
$shortCode = 'abc123';
$this->urlShortener->shortCodeToUrl($shortCode, null)->willReturn(
- new ShortUrl('http://domain.com/foo/bar')
+ new ShortUrl('http://domain.com/foo/bar'),
)->shouldBeCalledOnce();
$request = (new ServerRequest())->withAttribute('shortCode', $shortCode);
diff --git a/module/Rest/test/Action/ShortUrl/SingleStepCreateShortUrlActionTest.php b/module/Rest/test/Action/ShortUrl/SingleStepCreateShortUrlActionTest.php
index fe95b6ea..ec5daf27 100644
--- a/module/Rest/test/Action/ShortUrl/SingleStepCreateShortUrlActionTest.php
+++ b/module/Rest/test/Action/ShortUrl/SingleStepCreateShortUrlActionTest.php
@@ -34,7 +34,7 @@ class SingleStepCreateShortUrlActionTest extends TestCase
[
'schema' => 'http',
'hostname' => 'foo.com',
- ]
+ ],
);
}
@@ -76,7 +76,7 @@ class SingleStepCreateShortUrlActionTest extends TestCase
return $argument;
}),
[],
- ShortUrlMeta::createEmpty()
+ ShortUrlMeta::createEmpty(),
)->willReturn(new ShortUrl(''));
$resp = $this->action->handle($request);
diff --git a/module/Rest/test/Action/Tag/ListTagsActionTest.php b/module/Rest/test/Action/Tag/ListTagsActionTest.php
index 5209ba02..66175a5a 100644
--- a/module/Rest/test/Action/Tag/ListTagsActionTest.php
+++ b/module/Rest/test/Action/Tag/ListTagsActionTest.php
@@ -25,7 +25,7 @@ class ListTagsActionTest extends TestCase
}
/** @test */
- public function returnsDataFromService()
+ public function returnsDataFromService(): void
{
$listTags = $this->tagService->listTags()->willReturn([new Tag('foo'), new Tag('bar')]);
diff --git a/module/Rest/test/Action/Visit/GetVisitsActionTest.php b/module/Rest/test/Action/Visit/GetVisitsActionTest.php
index 767d095c..c2c7a3c4 100644
--- a/module/Rest/test/Action/Visit/GetVisitsActionTest.php
+++ b/module/Rest/test/Action/Visit/GetVisitsActionTest.php
@@ -32,7 +32,7 @@ class GetVisitsActionTest extends TestCase
{
$shortCode = 'abc123';
$this->visitsTracker->info($shortCode, Argument::type(VisitsParams::class))->willReturn(
- new Paginator(new ArrayAdapter([]))
+ new Paginator(new ArrayAdapter([])),
)->shouldBeCalledOnce();
$response = $this->action->handle((new ServerRequest())->withAttribute('shortCode', $shortCode));
@@ -46,7 +46,7 @@ class GetVisitsActionTest extends TestCase
$this->visitsTracker->info($shortCode, new VisitsParams(
new DateRange(null, Chronos::parse('2016-01-01 00:00:00')),
3,
- 10
+ 10,
))
->willReturn(new Paginator(new ArrayAdapter([])))
->shouldBeCalledOnce();
@@ -57,7 +57,7 @@ class GetVisitsActionTest extends TestCase
'endDate' => '2016-01-01 00:00:00',
'page' => '3',
'itemsPerPage' => '10',
- ])
+ ]),
);
$this->assertEquals(200, $response->getStatusCode());
}
diff --git a/module/Rest/test/Authentication/Plugin/ApiKeyHeaderPluginTest.php b/module/Rest/test/Authentication/Plugin/ApiKeyHeaderPluginTest.php
index 36210918..e27da5fb 100644
--- a/module/Rest/test/Authentication/Plugin/ApiKeyHeaderPluginTest.php
+++ b/module/Rest/test/Authentication/Plugin/ApiKeyHeaderPluginTest.php
@@ -25,7 +25,7 @@ class ApiKeyHeaderPluginTest extends TestCase
}
/** @test */
- public function verifyThrowsExceptionWhenApiKeyIsNotValid()
+ public function verifyThrowsExceptionWhenApiKeyIsNotValid(): void
{
$apiKey = 'abc-ABC';
$check = $this->apiKeyService->check($apiKey)->willReturn(false);
@@ -38,7 +38,7 @@ class ApiKeyHeaderPluginTest extends TestCase
}
/** @test */
- public function verifyDoesNotThrowExceptionWhenApiKeyIsValid()
+ public function verifyDoesNotThrowExceptionWhenApiKeyIsValid(): void
{
$apiKey = 'abc-ABC';
$check = $this->apiKeyService->check($apiKey)->willReturn(true);
@@ -49,7 +49,7 @@ class ApiKeyHeaderPluginTest extends TestCase
}
/** @test */
- public function updateReturnsResponseAsIs()
+ public function updateReturnsResponseAsIs(): void
{
$apiKey = 'abc-ABC';
$response = new Response();
diff --git a/module/Rest/test/Authentication/RequestToAuthPluginTest.php b/module/Rest/test/Authentication/RequestToAuthPluginTest.php
index 8b52f408..0e7938c8 100644
--- a/module/Rest/test/Authentication/RequestToAuthPluginTest.php
+++ b/module/Rest/test/Authentication/RequestToAuthPluginTest.php
@@ -35,7 +35,7 @@ class RequestToAuthPluginTest extends TestCase
$this->expectException(MissingAuthenticationException::class);
$this->expectExceptionMessage(sprintf(
'Expected one of the following authentication headers, ["%s"], but none were provided',
- implode('", "', RequestToHttpAuthPlugin::SUPPORTED_AUTH_HEADERS)
+ implode('", "', RequestToHttpAuthPlugin::SUPPORTED_AUTH_HEADERS),
));
$this->requestToPlugin->fromRequest($request);
diff --git a/module/Rest/test/EventDispatcher/NotifyVisitToWebHooksTest.php b/module/Rest/test/EventDispatcher/NotifyVisitToWebHooksTest.php
index bb043e66..369960e1 100644
--- a/module/Rest/test/EventDispatcher/NotifyVisitToWebHooksTest.php
+++ b/module/Rest/test/EventDispatcher/NotifyVisitToWebHooksTest.php
@@ -56,11 +56,11 @@ class NotifyVisitToWebHooksTest extends TestCase
$requestAsync = $this->httpClient->requestAsync(
RequestMethodInterface::METHOD_POST,
Argument::type('string'),
- Argument::type('array')
+ Argument::type('array'),
)->willReturn(new FulfilledPromise(''));
$logWarning = $this->logger->warning(
'Tried to notify webhooks for visit with id "{visitId}", but it does not exist.',
- ['visitId' => '1']
+ ['visitId' => '1'],
);
$this->createListener(['foo', 'bar'])(new VisitLocated('1'));
@@ -90,7 +90,7 @@ class NotifyVisitToWebHooksTest extends TestCase
Assert::assertArrayHasKey('visit', $requestOptions[RequestOptions::JSON]);
return $requestOptions;
- })
+ }),
)->will(function (array $args) use ($invalidWebhooks) {
[, $webhook] = $args;
$e = new Exception('');
@@ -105,7 +105,7 @@ class NotifyVisitToWebHooksTest extends TestCase
Assert::assertArrayHasKey('e', $extra);
return $extra;
- })
+ }),
);
$this->createListener($webhooks)(new VisitLocated('1'));
@@ -123,7 +123,7 @@ class NotifyVisitToWebHooksTest extends TestCase
$this->logger->reveal(),
$webhooks,
[],
- new AppOptions(['name' => 'Shlink', 'version' => '1.2.3'])
+ new AppOptions(['name' => 'Shlink', 'version' => '1.2.3']),
);
}
}
diff --git a/module/Rest/test/Exception/MissingAuthenticationExceptionTest.php b/module/Rest/test/Exception/MissingAuthenticationExceptionTest.php
index 84c72e75..eee6058e 100644
--- a/module/Rest/test/Exception/MissingAuthenticationExceptionTest.php
+++ b/module/Rest/test/Exception/MissingAuthenticationExceptionTest.php
@@ -20,7 +20,7 @@ class MissingAuthenticationExceptionTest extends TestCase
{
$expectedMessage = sprintf(
'Expected one of the following authentication headers, ["%s"], but none were provided',
- implode('", "', $expectedTypes)
+ implode('", "', $expectedTypes),
);
$e = MissingAuthenticationException::fromExpectedTypes($expectedTypes);
diff --git a/module/Rest/test/Middleware/AuthenticationMiddlewareTest.php b/module/Rest/test/Middleware/AuthenticationMiddlewareTest.php
index 1d306fdc..9b974140 100644
--- a/module/Rest/test/Middleware/AuthenticationMiddlewareTest.php
+++ b/module/Rest/test/Middleware/AuthenticationMiddlewareTest.php
@@ -38,7 +38,7 @@ class AuthenticationMiddlewareTest extends TestCase
$this->middleware = new AuthenticationMiddleware(
$this->requestToPlugin->reveal(),
[HealthAction::class],
- $this->logger->reveal()
+ $this->logger->reveal(),
);
}
@@ -51,7 +51,7 @@ class AuthenticationMiddlewareTest extends TestCase
$handler = $this->prophesize(RequestHandlerInterface::class);
$handle = $handler->handle($request)->willReturn(new Response());
$fromRequest = $this->requestToPlugin->fromRequest(Argument::any())->willReturn(
- $this->prophesize(AuthenticationPluginInterface::class)->reveal()
+ $this->prophesize(AuthenticationPluginInterface::class)->reveal(),
);
$this->middleware->process($request, $handler->reveal());
@@ -67,17 +67,17 @@ class AuthenticationMiddlewareTest extends TestCase
yield 'with no route result' => [new ServerRequest()];
yield 'with failure route result' => [(new ServerRequest())->withAttribute(
RouteResult::class,
- RouteResult::fromRouteFailure([RequestMethodInterface::METHOD_GET])
+ RouteResult::fromRouteFailure([RequestMethodInterface::METHOD_GET]),
)];
yield 'with whitelisted route' => [(new ServerRequest())->withAttribute(
RouteResult::class,
RouteResult::fromRoute(
- new Route('foo', $dummyMiddleware, Route::HTTP_METHOD_ANY, HealthAction::class)
- )
+ new Route('foo', $dummyMiddleware, Route::HTTP_METHOD_ANY, HealthAction::class),
+ ),
)];
yield 'with OPTIONS method' => [(new ServerRequest())->withAttribute(
RouteResult::class,
- RouteResult::fromRoute(new Route('bar', $dummyMiddleware), [])
+ RouteResult::fromRoute(new Route('bar', $dummyMiddleware), []),
)->withMethod(RequestMethodInterface::METHOD_OPTIONS)];
}
@@ -87,11 +87,11 @@ class AuthenticationMiddlewareTest extends TestCase
$newResponse = new Response();
$request = (new ServerRequest())->withAttribute(
RouteResult::class,
- RouteResult::fromRoute(new Route('bar', $this->getDummyMiddleware()), [])
+ RouteResult::fromRoute(new Route('bar', $this->getDummyMiddleware()), []),
);
$plugin = $this->prophesize(AuthenticationPluginInterface::class);
- $verify = $plugin->verify($request)->will(function () {
+ $verify = $plugin->verify($request)->will(function (): void {
});
$update = $plugin->update($request, Argument::type(ResponseInterface::class))->willReturn($newResponse);
$fromRequest = $this->requestToPlugin->fromRequest(Argument::any())->willReturn($plugin->reveal());
diff --git a/module/Rest/test/Middleware/BodyParserMiddlewareTest.php b/module/Rest/test/Middleware/BodyParserMiddlewareTest.php
index ba8f27ef..abed5a29 100644
--- a/module/Rest/test/Middleware/BodyParserMiddlewareTest.php
+++ b/module/Rest/test/Middleware/BodyParserMiddlewareTest.php
@@ -90,7 +90,7 @@ class BodyParserMiddlewareTest extends TestCase
], $req->getParsedBody());
return new Response();
- }
+ },
);
$this->middleware->process($request, $delegate->reveal());
@@ -118,7 +118,7 @@ class BodyParserMiddlewareTest extends TestCase
], $req->getParsedBody());
return new Response();
- }
+ },
);
$this->middleware->process($request, $delegate->reveal());
diff --git a/module/Rest/test/Middleware/CrossDomainMiddlewareTest.php b/module/Rest/test/Middleware/CrossDomainMiddlewareTest.php
index 28a85010..a6e0637f 100644
--- a/module/Rest/test/Middleware/CrossDomainMiddlewareTest.php
+++ b/module/Rest/test/Middleware/CrossDomainMiddlewareTest.php
@@ -54,7 +54,7 @@ class CrossDomainMiddlewareTest extends TestCase
$response = $this->middleware->process(
(new ServerRequest())->withHeader('Origin', 'local'),
- $this->handler->reveal()
+ $this->handler->reveal(),
);
$this->assertNotSame($originalResponse, $response);
@@ -63,7 +63,7 @@ class CrossDomainMiddlewareTest extends TestCase
$this->assertEquals('local', $response->getHeaderLine('Access-Control-Allow-Origin'));
$this->assertEquals(
Authentication\Plugin\ApiKeyHeaderPlugin::HEADER_NAME,
- $response->getHeaderLine('Access-Control-Expose-Headers')
+ $response->getHeaderLine('Access-Control-Expose-Headers'),
);
$this->assertArrayNotHasKey('Access-Control-Allow-Methods', $headers);
$this->assertArrayNotHasKey('Access-Control-Max-Age', $headers);
@@ -88,7 +88,7 @@ class CrossDomainMiddlewareTest extends TestCase
$this->assertEquals('local', $response->getHeaderLine('Access-Control-Allow-Origin'));
$this->assertEquals(
Authentication\Plugin\ApiKeyHeaderPlugin::HEADER_NAME,
- $response->getHeaderLine('Access-Control-Expose-Headers')
+ $response->getHeaderLine('Access-Control-Expose-Headers'),
);
$this->assertArrayHasKey('Access-Control-Allow-Methods', $headers);
$this->assertEquals('1000', $response->getHeaderLine('Access-Control-Max-Age'));
@@ -120,8 +120,8 @@ class CrossDomainMiddlewareTest extends TestCase
yield 'with failed route result' => [RouteResult::fromRouteFailure(['POST', 'GET']), 'POST,GET'];
yield 'with success route result' => [
RouteResult::fromRoute(
- new Route('/', middleware(function () {
- }), ['DELETE', 'PATCH', 'PUT'])
+ new Route('/', middleware(function (): void {
+ }), ['DELETE', 'PATCH', 'PUT']),
),
'DELETE,PATCH,PUT',
];
diff --git a/module/Rest/test/Middleware/ShortUrl/CreateShortUrlContentNegotiationMiddlewareTest.php b/module/Rest/test/Middleware/ShortUrl/CreateShortUrlContentNegotiationMiddlewareTest.php
index bfcb2bcc..1ad7ef25 100644
--- a/module/Rest/test/Middleware/ShortUrl/CreateShortUrlContentNegotiationMiddlewareTest.php
+++ b/module/Rest/test/Middleware/ShortUrl/CreateShortUrlContentNegotiationMiddlewareTest.php
@@ -49,7 +49,7 @@ class CreateShortUrlContentNegotiationMiddlewareTest extends TestCase
}
$handle = $this->requestHandler->handle(Argument::type(ServerRequestInterface::class))->willReturn(
- new JsonResponse(['shortUrl' => 'http://doma.in/foo'])
+ new JsonResponse(['shortUrl' => 'http://doma.in/foo']),
);
$response = $this->middleware->process($request, $this->requestHandler->reveal());
@@ -80,7 +80,7 @@ class CreateShortUrlContentNegotiationMiddlewareTest extends TestCase
$request = (new ServerRequest())->withQueryParams(['format' => 'txt']);
$handle = $this->requestHandler->handle(Argument::type(ServerRequestInterface::class))->willReturn(
- new JsonResponse($json)
+ new JsonResponse($json),
);
$response = $this->middleware->process($request, $this->requestHandler->reveal());
diff --git a/module/Rest/test/Service/ApiKeyServiceTest.php b/module/Rest/test/Service/ApiKeyServiceTest.php
index caa50bf1..c371beab 100644
--- a/module/Rest/test/Service/ApiKeyServiceTest.php
+++ b/module/Rest/test/Service/ApiKeyServiceTest.php
@@ -16,10 +16,8 @@ use Shlinkio\Shlink\Rest\Service\ApiKeyService;
class ApiKeyServiceTest extends TestCase
{
- /** @var ApiKeyService */
- private $service;
- /** @var ObjectProphecy */
- private $em;
+ private ApiKeyService $service;
+ private ObjectProphecy $em;
public function setUp(): void
{