mirror of
https://github.com/shlinkio/shlink.git
synced 2024-12-31 19:26:58 -06:00
Merge pull request #1146 from acelaya-forks/feature/coding-standard
Updated to coding standard v2.2.0
This commit is contained in:
commit
7e7ef64c79
@ -46,7 +46,7 @@
|
||||
"predis/predis": "^1.1",
|
||||
"pugx/shortid-php": "^0.7",
|
||||
"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-event-dispatcher": "^2.1",
|
||||
"shlinkio/shlink-importer": "^2.3.1",
|
||||
@ -71,7 +71,7 @@
|
||||
"phpunit/php-code-coverage": "^9.2",
|
||||
"phpunit/phpunit": "^9.5",
|
||||
"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",
|
||||
"symfony/var-dumper": "^5.3",
|
||||
"veewee/composer-run-parallel": "^1.0"
|
||||
|
@ -60,10 +60,7 @@ final class Version20201102113208 extends AbstractMigration
|
||||
->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|int|null
|
||||
*/
|
||||
private function resolveOneApiKeyId(Result $result)
|
||||
private function resolveOneApiKeyId(Result $result): string|int|null
|
||||
{
|
||||
$results = [];
|
||||
while ($row = $result->fetchAssociative()) {
|
||||
|
@ -25,7 +25,7 @@ class GenerateKeyCommand extends BaseCommand
|
||||
|
||||
public function __construct(
|
||||
private ApiKeyServiceInterface $apiKeyService,
|
||||
private RoleResolverInterface $roleResolver
|
||||
private RoleResolverInterface $roleResolver,
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ abstract class AbstractDatabaseCommand extends AbstractLockedCommand
|
||||
public function __construct(
|
||||
LockFactory $locker,
|
||||
private ProcessRunnerInterface $processRunner,
|
||||
PhpExecutableFinder $phpFinder
|
||||
PhpExecutableFinder $phpFinder,
|
||||
) {
|
||||
parent::__construct($locker);
|
||||
$this->phpBinary = $phpFinder->find(false) ?: 'php';
|
||||
|
@ -26,7 +26,7 @@ class CreateDatabaseCommand extends AbstractDatabaseCommand
|
||||
ProcessRunnerInterface $processRunner,
|
||||
PhpExecutableFinder $phpFinder,
|
||||
private Connection $regularConn,
|
||||
private Connection $noDbNameConn
|
||||
private Connection $noDbNameConn,
|
||||
) {
|
||||
parent::__construct($locker, $processRunner, $phpFinder);
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ class GenerateShortUrlCommand extends BaseCommand
|
||||
public function __construct(
|
||||
private UrlShortenerInterface $urlShortener,
|
||||
private ShortUrlStringifierInterface $stringifier,
|
||||
private int $defaultShortCodeLength
|
||||
private int $defaultShortCodeLength,
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ class ListShortUrlsCommand extends AbstractWithDateRangeCommand
|
||||
|
||||
public function __construct(
|
||||
private ShortUrlServiceInterface $shortUrlService,
|
||||
private DataTransformerInterface $transformer
|
||||
private DataTransformerInterface $transformer,
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ final class LockedCommandConfig
|
||||
private function __construct(
|
||||
private string $lockName,
|
||||
private bool $isBlocking,
|
||||
private float $ttl = self::DEFAULT_TTL
|
||||
private float $ttl = self::DEFAULT_TTL,
|
||||
) {
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ class LocateVisitsCommand extends AbstractLockedCommand implements VisitGeolocat
|
||||
public function __construct(
|
||||
private VisitLocatorInterface $visitLocator,
|
||||
private IpLocationResolverInterface $ipLocationResolver,
|
||||
LockFactory $locker
|
||||
LockFactory $locker,
|
||||
) {
|
||||
parent::__construct($locker);
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ class GeolocationDbUpdater implements GeolocationDbUpdaterInterface
|
||||
private DbUpdaterInterface $dbUpdater,
|
||||
private Reader $geoLiteDbReader,
|
||||
private LockFactory $locker,
|
||||
private TrackingOptions $trackingOptions
|
||||
private TrackingOptions $trackingOptions,
|
||||
) {
|
||||
}
|
||||
|
||||
|
@ -238,11 +238,10 @@ class ListShortUrlsCommandTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|array|null $expectedOrderBy
|
||||
* @test
|
||||
* @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([
|
||||
'orderBy' => $expectedOrderBy,
|
||||
|
@ -116,9 +116,8 @@ class GeolocationDbUpdaterTest extends TestCase
|
||||
/**
|
||||
* @test
|
||||
* @dataProvider provideSmallDays
|
||||
* @param string|int $buildEpoch
|
||||
*/
|
||||
public function databaseIsNotUpdatedIfItIsYoungerThanOneWeek($buildEpoch): void
|
||||
public function databaseIsNotUpdatedIfItIsYoungerThanOneWeek(string|int $buildEpoch): void
|
||||
{
|
||||
$fileExists = $this->dbUpdater->databaseFileExists()->willReturn(true);
|
||||
$getMeta = $this->geoLiteDbReader->metadata()->willReturn($this->buildMetaWithBuildEpoch($buildEpoch));
|
||||
@ -161,10 +160,7 @@ class GeolocationDbUpdaterTest extends TestCase
|
||||
$this->geolocationDbUpdater->checkDbUpdate();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|int $buildEpoch
|
||||
*/
|
||||
private function buildMetaWithBuildEpoch($buildEpoch): Metadata
|
||||
private function buildMetaWithBuildEpoch(string|int $buildEpoch): Metadata
|
||||
{
|
||||
return new Metadata([
|
||||
'binary_format_major_version' => '',
|
||||
|
@ -55,10 +55,7 @@ function parseDateRangeFromQuery(array $query, string $startDateName, string $en
|
||||
return buildDateRange($startDate, $endDate);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|DateTimeInterface|Chronos|null $date
|
||||
*/
|
||||
function parseDateField($date): ?Chronos
|
||||
function parseDateField(string|DateTimeInterface|Chronos|null $date): ?Chronos
|
||||
{
|
||||
if ($date === null || $date instanceof Chronos) {
|
||||
return $date;
|
||||
|
@ -28,7 +28,7 @@ final class QrCodeParams
|
||||
private int $size,
|
||||
private int $margin,
|
||||
private WriterInterface $writer,
|
||||
private ErrorCorrectionLevelInterface $errorCorrectionLevel
|
||||
private ErrorCorrectionLevelInterface $errorCorrectionLevel,
|
||||
) {
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ class QrCodeAction implements MiddlewareInterface
|
||||
public function __construct(
|
||||
private ShortUrlResolverInterface $urlResolver,
|
||||
private ShortUrlStringifierInterface $stringifier,
|
||||
private LoggerInterface $logger
|
||||
private LoggerInterface $logger,
|
||||
) {
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@ class NotFoundRedirectResolver implements NotFoundRedirectResolverInterface
|
||||
|
||||
public function resolveRedirectResponse(
|
||||
NotFoundType $notFoundType,
|
||||
NotFoundRedirectConfigInterface $config
|
||||
NotFoundRedirectConfigInterface $config,
|
||||
): ?ResponseInterface {
|
||||
return match (true) {
|
||||
$notFoundType->isBaseUrl() && $config->hasBaseUrlRedirect() =>
|
||||
|
@ -11,6 +11,6 @@ interface NotFoundRedirectResolverInterface
|
||||
{
|
||||
public function resolveRedirectResponse(
|
||||
NotFoundType $notFoundType,
|
||||
NotFoundRedirectConfigInterface $config
|
||||
NotFoundRedirectConfigInterface $config,
|
||||
): ?ResponseInterface;
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ class DomainService implements DomainServiceInterface
|
||||
public function configureNotFoundRedirects(
|
||||
string $authority,
|
||||
NotFoundRedirects $notFoundRedirects,
|
||||
?ApiKey $apiKey = null
|
||||
?ApiKey $apiKey = null,
|
||||
): Domain {
|
||||
if ($authority === $this->defaultDomain) {
|
||||
throw InvalidDomainException::forDefaultDomainRedirects();
|
||||
|
@ -14,7 +14,7 @@ final class DomainItem implements JsonSerializable
|
||||
private function __construct(
|
||||
private string $authority,
|
||||
private NotFoundRedirectConfigInterface $notFoundRedirectConfig,
|
||||
private bool $isDefault
|
||||
private bool $isDefault,
|
||||
) {
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ class LocateVisit
|
||||
private EntityManagerInterface $em,
|
||||
private LoggerInterface $logger,
|
||||
private DbUpdaterInterface $dbUpdater,
|
||||
private EventDispatcherInterface $eventDispatcher
|
||||
private EventDispatcherInterface $eventDispatcher,
|
||||
) {
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ class NotifyVisitToMercure
|
||||
private HubInterface $hub,
|
||||
private MercureUpdatesGeneratorInterface $updatesGenerator,
|
||||
private EntityManagerInterface $em,
|
||||
private LoggerInterface $logger
|
||||
private LoggerInterface $logger,
|
||||
) {
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ class NotifyVisitToWebHooks
|
||||
/** @var string[] */
|
||||
private array $webhooks,
|
||||
private DataTransformerInterface $transformer,
|
||||
private AppOptions $appOptions
|
||||
private AppOptions $appOptions,
|
||||
) {
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ class ImportedLinksProcessor implements ImportedLinksProcessorInterface
|
||||
private EntityManagerInterface $em,
|
||||
private ShortUrlRelationResolverInterface $relationResolver,
|
||||
private ShortCodeHelperInterface $shortCodeHelper,
|
||||
private DoctrineBatchHelperInterface $batchHelper
|
||||
private DoctrineBatchHelperInterface $batchHelper,
|
||||
) {
|
||||
$this->shortUrlRepo = $this->em->getRepository(ShortUrl::class);
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ final class MercureUpdatesGenerator implements MercureUpdatesGeneratorInterface
|
||||
|
||||
public function __construct(
|
||||
private DataTransformerInterface $shortUrlTransformer,
|
||||
private DataTransformerInterface $orphanVisitTransformer
|
||||
private DataTransformerInterface $orphanVisitTransformer,
|
||||
) {
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ final class VisitsParams
|
||||
?DateRange $dateRange = null,
|
||||
int $page = self::FIRST_PAGE,
|
||||
?int $itemsPerPage = null,
|
||||
private bool $excludeBots = false
|
||||
private bool $excludeBots = false,
|
||||
) {
|
||||
$this->dateRange = $dateRange ?? DateRange::emptyInstance();
|
||||
$this->page = $this->determinePage($page);
|
||||
|
@ -14,7 +14,7 @@ class ShortUrlRepositoryAdapter implements AdapterInterface
|
||||
public function __construct(
|
||||
private ShortUrlRepositoryInterface $repository,
|
||||
private ShortUrlsParams $params,
|
||||
private ?ApiKey $apiKey
|
||||
private ?ApiKey $apiKey,
|
||||
) {
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@ class VisitsForTagPaginatorAdapter extends AbstractCacheableCountPaginatorAdapte
|
||||
private VisitRepositoryInterface $visitRepository,
|
||||
private string $tag,
|
||||
private VisitsParams $params,
|
||||
private ?ApiKey $apiKey
|
||||
private ?ApiKey $apiKey,
|
||||
) {
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ class VisitsPaginatorAdapter extends AbstractCacheableCountPaginatorAdapter
|
||||
private VisitRepositoryInterface $visitRepository,
|
||||
private ShortUrlIdentifier $identifier,
|
||||
private VisitsParams $params,
|
||||
private ?Specification $spec
|
||||
private ?Specification $spec,
|
||||
) {
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@ class DeleteShortUrlService implements DeleteShortUrlServiceInterface
|
||||
public function __construct(
|
||||
private EntityManagerInterface $em,
|
||||
private DeleteShortUrlsOptions $deleteShortUrlsOptions,
|
||||
private ShortUrlResolverInterface $urlResolver
|
||||
private ShortUrlResolverInterface $urlResolver,
|
||||
) {
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ class ShortUrlService implements ShortUrlServiceInterface
|
||||
private ORM\EntityManagerInterface $em,
|
||||
private ShortUrlResolverInterface $urlResolver,
|
||||
private ShortUrlTitleResolutionHelperInterface $titleResolutionHelper,
|
||||
private ShortUrlRelationResolverInterface $relationResolver
|
||||
private ShortUrlRelationResolverInterface $relationResolver,
|
||||
) {
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ class UrlShortener implements UrlShortenerInterface
|
||||
private ShortUrlTitleResolutionHelperInterface $titleResolutionHelper,
|
||||
private EntityManagerInterface $em,
|
||||
private ShortUrlRelationResolverInterface $relationResolver,
|
||||
private ShortCodeHelperInterface $shortCodeHelper
|
||||
private ShortCodeHelperInterface $shortCodeHelper,
|
||||
) {
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ class VisitsCountFiltering
|
||||
public function __construct(
|
||||
private ?DateRange $dateRange = null,
|
||||
private bool $excludeBots = false,
|
||||
private ?Specification $spec = null
|
||||
private ?Specification $spec = null,
|
||||
) {
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ final class VisitsListFiltering extends VisitsCountFiltering
|
||||
bool $excludeBots = false,
|
||||
?Specification $spec = null,
|
||||
private ?int $limit = null,
|
||||
private ?int $offset = null
|
||||
private ?int $offset = null,
|
||||
) {
|
||||
parent::__construct($dateRange, $excludeBots, $spec);
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ class VisitsTracker implements VisitsTrackerInterface
|
||||
public function __construct(
|
||||
private ORM\EntityManagerInterface $em,
|
||||
private EventDispatcherInterface $eventDispatcher,
|
||||
private TrackingOptions $options
|
||||
private TrackingOptions $options,
|
||||
) {
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ class ExtraPathRedirectMiddlewareTest extends TestCase
|
||||
*/
|
||||
public function handlerIsCalledWhenConfigPreventsRedirectWithExtraPath(
|
||||
bool $appendExtraPath,
|
||||
ServerRequestInterface $request
|
||||
ServerRequestInterface $request,
|
||||
): void {
|
||||
$this->options->appendExtraPath = $appendExtraPath;
|
||||
|
||||
|
@ -23,7 +23,7 @@ class ListShortUrlsAction extends AbstractRestAction
|
||||
|
||||
public function __construct(
|
||||
private ShortUrlServiceInterface $shortUrlService,
|
||||
private DataTransformerInterface $transformer
|
||||
private DataTransformerInterface $transformer,
|
||||
) {
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ class OrphanVisitsAction extends AbstractRestAction
|
||||
|
||||
public function __construct(
|
||||
private VisitsStatsHelperInterface $visitsHelper,
|
||||
private DataTransformerInterface $orphanVisitTransformer
|
||||
private DataTransformerInterface $orphanVisitTransformer,
|
||||
) {
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ class AuthenticationMiddleware implements MiddlewareInterface, StatusCodeInterfa
|
||||
public function __construct(
|
||||
private ApiKeyServiceInterface $apiKeyService,
|
||||
private array $routesWithoutApiKey,
|
||||
private array $routesWithQueryApiKey
|
||||
private array $routesWithQueryApiKey,
|
||||
) {
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user