Updated to coding standard v2.2.0

This commit is contained in:
Alejandro Celaya 2021-08-05 19:47:17 +02:00
parent 60d6314262
commit 9a31f53d4d
38 changed files with 40 additions and 51 deletions

View File

@ -46,7 +46,7 @@
"predis/predis": "^1.1", "predis/predis": "^1.1",
"pugx/shortid-php": "^0.7", "pugx/shortid-php": "^0.7",
"ramsey/uuid": "^3.9", "ramsey/uuid": "^3.9",
"shlinkio/shlink-common": "dev-main#2832a4a as 4.0", "shlinkio/shlink-common": "dev-main#baef0ca as 4.0",
"shlinkio/shlink-config": "^1.2", "shlinkio/shlink-config": "^1.2",
"shlinkio/shlink-event-dispatcher": "^2.1", "shlinkio/shlink-event-dispatcher": "^2.1",
"shlinkio/shlink-importer": "^2.3.1", "shlinkio/shlink-importer": "^2.3.1",
@ -71,7 +71,7 @@
"phpunit/php-code-coverage": "^9.2", "phpunit/php-code-coverage": "^9.2",
"phpunit/phpunit": "^9.5", "phpunit/phpunit": "^9.5",
"roave/security-advisories": "dev-master", "roave/security-advisories": "dev-master",
"shlinkio/php-coding-standard": "~2.1.1", "shlinkio/php-coding-standard": "~2.2.0",
"shlinkio/shlink-test-utils": "^2.2", "shlinkio/shlink-test-utils": "^2.2",
"symfony/var-dumper": "^5.3", "symfony/var-dumper": "^5.3",
"veewee/composer-run-parallel": "^1.0" "veewee/composer-run-parallel": "^1.0"

View File

@ -60,10 +60,7 @@ final class Version20201102113208 extends AbstractMigration
->execute(); ->execute();
} }
/** private function resolveOneApiKeyId(Result $result): string|int|null
* @return string|int|null
*/
private function resolveOneApiKeyId(Result $result)
{ {
$results = []; $results = [];
while ($row = $result->fetchAssociative()) { while ($row = $result->fetchAssociative()) {

View File

@ -25,7 +25,7 @@ class GenerateKeyCommand extends BaseCommand
public function __construct( public function __construct(
private ApiKeyServiceInterface $apiKeyService, private ApiKeyServiceInterface $apiKeyService,
private RoleResolverInterface $roleResolver private RoleResolverInterface $roleResolver,
) { ) {
parent::__construct(); parent::__construct();
} }

View File

@ -18,7 +18,7 @@ abstract class AbstractDatabaseCommand extends AbstractLockedCommand
public function __construct( public function __construct(
LockFactory $locker, LockFactory $locker,
private ProcessRunnerInterface $processRunner, private ProcessRunnerInterface $processRunner,
PhpExecutableFinder $phpFinder PhpExecutableFinder $phpFinder,
) { ) {
parent::__construct($locker); parent::__construct($locker);
$this->phpBinary = $phpFinder->find(false) ?: 'php'; $this->phpBinary = $phpFinder->find(false) ?: 'php';

View File

@ -26,7 +26,7 @@ class CreateDatabaseCommand extends AbstractDatabaseCommand
ProcessRunnerInterface $processRunner, ProcessRunnerInterface $processRunner,
PhpExecutableFinder $phpFinder, PhpExecutableFinder $phpFinder,
private Connection $regularConn, private Connection $regularConn,
private Connection $noDbNameConn private Connection $noDbNameConn,
) { ) {
parent::__construct($locker, $processRunner, $phpFinder); parent::__construct($locker, $processRunner, $phpFinder);
} }

View File

@ -33,7 +33,7 @@ class GenerateShortUrlCommand extends BaseCommand
public function __construct( public function __construct(
private UrlShortenerInterface $urlShortener, private UrlShortenerInterface $urlShortener,
private ShortUrlStringifierInterface $stringifier, private ShortUrlStringifierInterface $stringifier,
private int $defaultShortCodeLength private int $defaultShortCodeLength,
) { ) {
parent::__construct(); parent::__construct();
} }

View File

@ -35,7 +35,7 @@ class ListShortUrlsCommand extends AbstractWithDateRangeCommand
public function __construct( public function __construct(
private ShortUrlServiceInterface $shortUrlService, private ShortUrlServiceInterface $shortUrlService,
private DataTransformerInterface $transformer private DataTransformerInterface $transformer,
) { ) {
parent::__construct(); parent::__construct();
} }

View File

@ -11,7 +11,7 @@ final class LockedCommandConfig
private function __construct( private function __construct(
private string $lockName, private string $lockName,
private bool $isBlocking, private bool $isBlocking,
private float $ttl = self::DEFAULT_TTL private float $ttl = self::DEFAULT_TTL,
) { ) {
} }

View File

@ -35,7 +35,7 @@ class LocateVisitsCommand extends AbstractLockedCommand implements VisitGeolocat
public function __construct( public function __construct(
private VisitLocatorInterface $visitLocator, private VisitLocatorInterface $visitLocator,
private IpLocationResolverInterface $ipLocationResolver, private IpLocationResolverInterface $ipLocationResolver,
LockFactory $locker LockFactory $locker,
) { ) {
parent::__construct($locker); parent::__construct($locker);
} }

View File

@ -23,7 +23,7 @@ class GeolocationDbUpdater implements GeolocationDbUpdaterInterface
private DbUpdaterInterface $dbUpdater, private DbUpdaterInterface $dbUpdater,
private Reader $geoLiteDbReader, private Reader $geoLiteDbReader,
private LockFactory $locker, private LockFactory $locker,
private TrackingOptions $trackingOptions private TrackingOptions $trackingOptions,
) { ) {
} }

View File

@ -238,11 +238,10 @@ class ListShortUrlsCommandTest extends TestCase
} }
/** /**
* @param string|array|null $expectedOrderBy
* @test * @test
* @dataProvider provideOrderBy * @dataProvider provideOrderBy
*/ */
public function orderByIsProperlyComputed(array $commandArgs, $expectedOrderBy): void public function orderByIsProperlyComputed(array $commandArgs, string|array|null $expectedOrderBy): void
{ {
$listShortUrls = $this->shortUrlService->listShortUrls(ShortUrlsParams::fromRawData([ $listShortUrls = $this->shortUrlService->listShortUrls(ShortUrlsParams::fromRawData([
'orderBy' => $expectedOrderBy, 'orderBy' => $expectedOrderBy,

View File

@ -116,9 +116,8 @@ class GeolocationDbUpdaterTest extends TestCase
/** /**
* @test * @test
* @dataProvider provideSmallDays * @dataProvider provideSmallDays
* @param string|int $buildEpoch
*/ */
public function databaseIsNotUpdatedIfItIsYoungerThanOneWeek($buildEpoch): void public function databaseIsNotUpdatedIfItIsYoungerThanOneWeek(string|int $buildEpoch): void
{ {
$fileExists = $this->dbUpdater->databaseFileExists()->willReturn(true); $fileExists = $this->dbUpdater->databaseFileExists()->willReturn(true);
$getMeta = $this->geoLiteDbReader->metadata()->willReturn($this->buildMetaWithBuildEpoch($buildEpoch)); $getMeta = $this->geoLiteDbReader->metadata()->willReturn($this->buildMetaWithBuildEpoch($buildEpoch));
@ -161,10 +160,7 @@ class GeolocationDbUpdaterTest extends TestCase
$this->geolocationDbUpdater->checkDbUpdate(); $this->geolocationDbUpdater->checkDbUpdate();
} }
/** private function buildMetaWithBuildEpoch(string|int $buildEpoch): Metadata
* @param string|int $buildEpoch
*/
private function buildMetaWithBuildEpoch($buildEpoch): Metadata
{ {
return new Metadata([ return new Metadata([
'binary_format_major_version' => '', 'binary_format_major_version' => '',

View File

@ -55,10 +55,7 @@ function parseDateRangeFromQuery(array $query, string $startDateName, string $en
return buildDateRange($startDate, $endDate); return buildDateRange($startDate, $endDate);
} }
/** function parseDateField(string|DateTimeInterface|Chronos|null $date): ?Chronos
* @param string|DateTimeInterface|Chronos|null $date
*/
function parseDateField($date): ?Chronos
{ {
if ($date === null || $date instanceof Chronos) { if ($date === null || $date instanceof Chronos) {
return $date; return $date;

View File

@ -28,7 +28,7 @@ final class QrCodeParams
private int $size, private int $size,
private int $margin, private int $margin,
private WriterInterface $writer, private WriterInterface $writer,
private ErrorCorrectionLevelInterface $errorCorrectionLevel private ErrorCorrectionLevelInterface $errorCorrectionLevel,
) { ) {
} }

View File

@ -22,7 +22,7 @@ class QrCodeAction implements MiddlewareInterface
public function __construct( public function __construct(
private ShortUrlResolverInterface $urlResolver, private ShortUrlResolverInterface $urlResolver,
private ShortUrlStringifierInterface $stringifier, private ShortUrlStringifierInterface $stringifier,
private LoggerInterface $logger private LoggerInterface $logger,
) { ) {
} }

View File

@ -16,7 +16,7 @@ class NotFoundRedirectResolver implements NotFoundRedirectResolverInterface
public function resolveRedirectResponse( public function resolveRedirectResponse(
NotFoundType $notFoundType, NotFoundType $notFoundType,
NotFoundRedirectConfigInterface $config NotFoundRedirectConfigInterface $config,
): ?ResponseInterface { ): ?ResponseInterface {
return match (true) { return match (true) {
$notFoundType->isBaseUrl() && $config->hasBaseUrlRedirect() => $notFoundType->isBaseUrl() && $config->hasBaseUrlRedirect() =>

View File

@ -11,6 +11,6 @@ interface NotFoundRedirectResolverInterface
{ {
public function resolveRedirectResponse( public function resolveRedirectResponse(
NotFoundType $notFoundType, NotFoundType $notFoundType,
NotFoundRedirectConfigInterface $config NotFoundRedirectConfigInterface $config,
): ?ResponseInterface; ): ?ResponseInterface;
} }

View File

@ -84,7 +84,7 @@ class DomainService implements DomainServiceInterface
public function configureNotFoundRedirects( public function configureNotFoundRedirects(
string $authority, string $authority,
NotFoundRedirects $notFoundRedirects, NotFoundRedirects $notFoundRedirects,
?ApiKey $apiKey = null ?ApiKey $apiKey = null,
): Domain { ): Domain {
if ($authority === $this->defaultDomain) { if ($authority === $this->defaultDomain) {
throw InvalidDomainException::forDefaultDomainRedirects(); throw InvalidDomainException::forDefaultDomainRedirects();

View File

@ -14,7 +14,7 @@ final class DomainItem implements JsonSerializable
private function __construct( private function __construct(
private string $authority, private string $authority,
private NotFoundRedirectConfigInterface $notFoundRedirectConfig, private NotFoundRedirectConfigInterface $notFoundRedirectConfig,
private bool $isDefault private bool $isDefault,
) { ) {
} }

View File

@ -24,7 +24,7 @@ class LocateVisit
private EntityManagerInterface $em, private EntityManagerInterface $em,
private LoggerInterface $logger, private LoggerInterface $logger,
private DbUpdaterInterface $dbUpdater, private DbUpdaterInterface $dbUpdater,
private EventDispatcherInterface $eventDispatcher private EventDispatcherInterface $eventDispatcher,
) { ) {
} }

View File

@ -21,7 +21,7 @@ class NotifyVisitToMercure
private HubInterface $hub, private HubInterface $hub,
private MercureUpdatesGeneratorInterface $updatesGenerator, private MercureUpdatesGeneratorInterface $updatesGenerator,
private EntityManagerInterface $em, private EntityManagerInterface $em,
private LoggerInterface $logger private LoggerInterface $logger,
) { ) {
} }

View File

@ -31,7 +31,7 @@ class NotifyVisitToWebHooks
/** @var string[] */ /** @var string[] */
private array $webhooks, private array $webhooks,
private DataTransformerInterface $transformer, private DataTransformerInterface $transformer,
private AppOptions $appOptions private AppOptions $appOptions,
) { ) {
} }

View File

@ -26,7 +26,7 @@ class ImportedLinksProcessor implements ImportedLinksProcessorInterface
private EntityManagerInterface $em, private EntityManagerInterface $em,
private ShortUrlRelationResolverInterface $relationResolver, private ShortUrlRelationResolverInterface $relationResolver,
private ShortCodeHelperInterface $shortCodeHelper, private ShortCodeHelperInterface $shortCodeHelper,
private DoctrineBatchHelperInterface $batchHelper private DoctrineBatchHelperInterface $batchHelper,
) { ) {
$this->shortUrlRepo = $this->em->getRepository(ShortUrl::class); $this->shortUrlRepo = $this->em->getRepository(ShortUrl::class);
} }

View File

@ -20,7 +20,7 @@ final class MercureUpdatesGenerator implements MercureUpdatesGeneratorInterface
public function __construct( public function __construct(
private DataTransformerInterface $shortUrlTransformer, private DataTransformerInterface $shortUrlTransformer,
private DataTransformerInterface $orphanVisitTransformer private DataTransformerInterface $orphanVisitTransformer,
) { ) {
} }

View File

@ -21,7 +21,7 @@ final class VisitsParams
?DateRange $dateRange = null, ?DateRange $dateRange = null,
int $page = self::FIRST_PAGE, int $page = self::FIRST_PAGE,
?int $itemsPerPage = null, ?int $itemsPerPage = null,
private bool $excludeBots = false private bool $excludeBots = false,
) { ) {
$this->dateRange = $dateRange ?? DateRange::emptyInstance(); $this->dateRange = $dateRange ?? DateRange::emptyInstance();
$this->page = $this->determinePage($page); $this->page = $this->determinePage($page);

View File

@ -14,7 +14,7 @@ class ShortUrlRepositoryAdapter implements AdapterInterface
public function __construct( public function __construct(
private ShortUrlRepositoryInterface $repository, private ShortUrlRepositoryInterface $repository,
private ShortUrlsParams $params, private ShortUrlsParams $params,
private ?ApiKey $apiKey private ?ApiKey $apiKey,
) { ) {
} }

View File

@ -16,7 +16,7 @@ class VisitsForTagPaginatorAdapter extends AbstractCacheableCountPaginatorAdapte
private VisitRepositoryInterface $visitRepository, private VisitRepositoryInterface $visitRepository,
private string $tag, private string $tag,
private VisitsParams $params, private VisitsParams $params,
private ?ApiKey $apiKey private ?ApiKey $apiKey,
) { ) {
} }

View File

@ -17,7 +17,7 @@ class VisitsPaginatorAdapter extends AbstractCacheableCountPaginatorAdapter
private VisitRepositoryInterface $visitRepository, private VisitRepositoryInterface $visitRepository,
private ShortUrlIdentifier $identifier, private ShortUrlIdentifier $identifier,
private VisitsParams $params, private VisitsParams $params,
private ?Specification $spec private ?Specification $spec,
) { ) {
} }

View File

@ -16,7 +16,7 @@ class DeleteShortUrlService implements DeleteShortUrlServiceInterface
public function __construct( public function __construct(
private EntityManagerInterface $em, private EntityManagerInterface $em,
private DeleteShortUrlsOptions $deleteShortUrlsOptions, private DeleteShortUrlsOptions $deleteShortUrlsOptions,
private ShortUrlResolverInterface $urlResolver private ShortUrlResolverInterface $urlResolver,
) { ) {
} }

View File

@ -25,7 +25,7 @@ class ShortUrlService implements ShortUrlServiceInterface
private ORM\EntityManagerInterface $em, private ORM\EntityManagerInterface $em,
private ShortUrlResolverInterface $urlResolver, private ShortUrlResolverInterface $urlResolver,
private ShortUrlTitleResolutionHelperInterface $titleResolutionHelper, private ShortUrlTitleResolutionHelperInterface $titleResolutionHelper,
private ShortUrlRelationResolverInterface $relationResolver private ShortUrlRelationResolverInterface $relationResolver,
) { ) {
} }

View File

@ -20,7 +20,7 @@ class UrlShortener implements UrlShortenerInterface
private ShortUrlTitleResolutionHelperInterface $titleResolutionHelper, private ShortUrlTitleResolutionHelperInterface $titleResolutionHelper,
private EntityManagerInterface $em, private EntityManagerInterface $em,
private ShortUrlRelationResolverInterface $relationResolver, private ShortUrlRelationResolverInterface $relationResolver,
private ShortCodeHelperInterface $shortCodeHelper private ShortCodeHelperInterface $shortCodeHelper,
) { ) {
} }

View File

@ -12,7 +12,7 @@ class VisitsCountFiltering
public function __construct( public function __construct(
private ?DateRange $dateRange = null, private ?DateRange $dateRange = null,
private bool $excludeBots = false, private bool $excludeBots = false,
private ?Specification $spec = null private ?Specification $spec = null,
) { ) {
} }

View File

@ -14,7 +14,7 @@ final class VisitsListFiltering extends VisitsCountFiltering
bool $excludeBots = false, bool $excludeBots = false,
?Specification $spec = null, ?Specification $spec = null,
private ?int $limit = null, private ?int $limit = null,
private ?int $offset = null private ?int $offset = null,
) { ) {
parent::__construct($dateRange, $excludeBots, $spec); parent::__construct($dateRange, $excludeBots, $spec);
} }

View File

@ -17,7 +17,7 @@ class VisitsTracker implements VisitsTrackerInterface
public function __construct( public function __construct(
private ORM\EntityManagerInterface $em, private ORM\EntityManagerInterface $em,
private EventDispatcherInterface $eventDispatcher, private EventDispatcherInterface $eventDispatcher,
private TrackingOptions $options private TrackingOptions $options,
) { ) {
} }

View File

@ -65,7 +65,7 @@ class ExtraPathRedirectMiddlewareTest extends TestCase
*/ */
public function handlerIsCalledWhenConfigPreventsRedirectWithExtraPath( public function handlerIsCalledWhenConfigPreventsRedirectWithExtraPath(
bool $appendExtraPath, bool $appendExtraPath,
ServerRequestInterface $request ServerRequestInterface $request,
): void { ): void {
$this->options->appendExtraPath = $appendExtraPath; $this->options->appendExtraPath = $appendExtraPath;

View File

@ -23,7 +23,7 @@ class ListShortUrlsAction extends AbstractRestAction
public function __construct( public function __construct(
private ShortUrlServiceInterface $shortUrlService, private ShortUrlServiceInterface $shortUrlService,
private DataTransformerInterface $transformer private DataTransformerInterface $transformer,
) { ) {
} }

View File

@ -22,7 +22,7 @@ class OrphanVisitsAction extends AbstractRestAction
public function __construct( public function __construct(
private VisitsStatsHelperInterface $visitsHelper, private VisitsStatsHelperInterface $visitsHelper,
private DataTransformerInterface $orphanVisitTransformer private DataTransformerInterface $orphanVisitTransformer,
) { ) {
} }

View File

@ -26,7 +26,7 @@ class AuthenticationMiddleware implements MiddlewareInterface, StatusCodeInterfa
public function __construct( public function __construct(
private ApiKeyServiceInterface $apiKeyService, private ApiKeyServiceInterface $apiKeyService,
private array $routesWithoutApiKey, private array $routesWithoutApiKey,
private array $routesWithQueryApiKey private array $routesWithQueryApiKey,
) { ) {
} }