mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-10 09:13:11 +08:00
Update to PHPStan 2.0
This commit is contained in:
@@ -8,11 +8,11 @@ use Doctrine\ORM\EntityManagerInterface;
|
||||
use Shlinkio\Shlink\Core\Exception\NonUniqueSlugException;
|
||||
use Shlinkio\Shlink\Core\ShortUrl\Entity\ShortUrl;
|
||||
use Shlinkio\Shlink\Core\ShortUrl\Helper\ShortCodeUniquenessHelperInterface;
|
||||
use Shlinkio\Shlink\Core\ShortUrl\Repository\ShortUrlRepositoryInterface;
|
||||
use Shlinkio\Shlink\Core\ShortUrl\Repository\ShortUrlRepository;
|
||||
use Shlinkio\Shlink\Core\ShortUrl\Resolver\ShortUrlRelationResolverInterface;
|
||||
use Shlinkio\Shlink\Core\Util\DoctrineBatchHelperInterface;
|
||||
use Shlinkio\Shlink\Core\Visit\Entity\Visit;
|
||||
use Shlinkio\Shlink\Core\Visit\Repository\VisitRepositoryInterface;
|
||||
use Shlinkio\Shlink\Core\Visit\Repository\VisitRepository;
|
||||
use Shlinkio\Shlink\Importer\ImportedLinksProcessorInterface;
|
||||
use Shlinkio\Shlink\Importer\Model\ImportedShlinkOrphanVisit;
|
||||
use Shlinkio\Shlink\Importer\Model\ImportedShlinkUrl;
|
||||
@@ -93,7 +93,7 @@ readonly class ImportedLinksProcessor implements ImportedLinksProcessorInterface
|
||||
bool $importShortCodes,
|
||||
callable $skipOnShortCodeConflict,
|
||||
): ShortUrlImporting {
|
||||
/** @var ShortUrlRepositoryInterface $shortUrlRepo */
|
||||
/** @var ShortUrlRepository $shortUrlRepo */
|
||||
$shortUrlRepo = $this->em->getRepository(ShortUrl::class);
|
||||
$alreadyImportedShortUrl = $shortUrlRepo->findOneByImportedUrl($importedUrl);
|
||||
if ($alreadyImportedShortUrl !== null) {
|
||||
@@ -132,7 +132,7 @@ readonly class ImportedLinksProcessor implements ImportedLinksProcessorInterface
|
||||
{
|
||||
$iterable = $this->batchHelper->wrapIterable($orphanVisits, 100);
|
||||
|
||||
/** @var VisitRepositoryInterface $visitRepo */
|
||||
/** @var VisitRepository $visitRepo */
|
||||
$visitRepo = $this->em->getRepository(Visit::class);
|
||||
$mostRecentOrphanVisit = $visitRepo->findMostRecentOrphanVisit();
|
||||
|
||||
|
||||
@@ -11,8 +11,8 @@ use Doctrine\ORM\Events;
|
||||
use Shlinkio\Shlink\Core\Config\Options\UrlShortenerOptions;
|
||||
use Shlinkio\Shlink\Core\Domain\Entity\Domain;
|
||||
use Shlinkio\Shlink\Core\Tag\Entity\Tag;
|
||||
use Symfony\Component\Lock\Lock;
|
||||
use Symfony\Component\Lock\LockFactory;
|
||||
use Symfony\Component\Lock\SharedLockInterface;
|
||||
use Symfony\Component\Lock\Store\InMemoryStore;
|
||||
|
||||
use function array_map;
|
||||
@@ -24,9 +24,9 @@ class PersistenceShortUrlRelationResolver implements ShortUrlRelationResolverInt
|
||||
private array $memoizedNewDomains = [];
|
||||
/** @var array<string, Tag> */
|
||||
private array $memoizedNewTags = [];
|
||||
/** @var array<string, Lock> */
|
||||
/** @var array<string, SharedLockInterface> */
|
||||
private array $tagLocks = [];
|
||||
/** @var array<string, Lock> */
|
||||
/** @var array<string, SharedLockInterface> */
|
||||
private array $domainLocks = [];
|
||||
|
||||
public function __construct(
|
||||
@@ -100,7 +100,7 @@ class PersistenceShortUrlRelationResolver implements ShortUrlRelationResolverInt
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, Lock> $locks
|
||||
* @param array<string, SharedLockInterface> $locks
|
||||
*/
|
||||
private function lock(array &$locks, string $name): void
|
||||
{
|
||||
@@ -112,7 +112,7 @@ class PersistenceShortUrlRelationResolver implements ShortUrlRelationResolverInt
|
||||
|
||||
/**
|
||||
/**
|
||||
* @param array<string, Lock> $locks
|
||||
* @param array<string, SharedLockInterface> $locks
|
||||
*/
|
||||
private function releaseLock(array &$locks, string $name): void
|
||||
{
|
||||
|
||||
@@ -45,7 +45,7 @@ class TagRepository extends EntitySpecificationRepository implements TagReposito
|
||||
public function findTagsWithInfo(TagsListFiltering|null $filtering = null): array
|
||||
{
|
||||
$orderField = OrderableField::toValidField($filtering?->orderBy?->field);
|
||||
$orderDir = $filtering?->orderBy?->direction ?? 'ASC';
|
||||
$orderDir = $filtering->orderBy->direction ?? 'ASC';
|
||||
$apiKey = $filtering?->apiKey;
|
||||
$conn = $this->getEntityManager()->getConnection();
|
||||
|
||||
@@ -113,8 +113,8 @@ class TagRepository extends EntitySpecificationRepository implements TagReposito
|
||||
->from('(' . $tagsSubQb->getSQL() . ')', 't')
|
||||
->leftJoin('t', '(' . $allVisitsSubQb->getSQL() . ')', 'v', $mainQb->expr()->eq('t.tag_id', 'v.tag_id'))
|
||||
->leftJoin('t', '(' . $nonBotVisitsSubQb->getSQL() . ')', 'b', $mainQb->expr()->eq('t.tag_id', 'b.tag_id'))
|
||||
->setMaxResults($filtering?->limit ?? PHP_INT_MAX)
|
||||
->setFirstResult($filtering?->offset ?? 0);
|
||||
->setMaxResults($filtering->limit ?? PHP_INT_MAX)
|
||||
->setFirstResult($filtering->offset ?? 0);
|
||||
|
||||
$mainQb->orderBy(camelCaseToSnakeCase($orderField->value), $orderDir);
|
||||
if ($orderField !== OrderableField::TAG) {
|
||||
|
||||
@@ -47,9 +47,11 @@ readonly class TagService implements TagServiceInterface
|
||||
*/
|
||||
private function createPaginator(AdapterInterface $adapter, TagsParams $params): Paginator
|
||||
{
|
||||
return (new Paginator($adapter))
|
||||
->setMaxPerPage($params->itemsPerPage)
|
||||
->setCurrentPage($params->page);
|
||||
$paginator = new Paginator($adapter);
|
||||
$paginator->setMaxPerPage($params->itemsPerPage)
|
||||
->setCurrentPage($params->page);
|
||||
|
||||
return $paginator;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -11,7 +11,7 @@ use Shlinkio\Shlink\Common\Util\DateRange;
|
||||
use Shlinkio\Shlink\Core\Domain\Entity\Domain;
|
||||
use Shlinkio\Shlink\Core\ShortUrl\Entity\ShortUrl;
|
||||
use Shlinkio\Shlink\Core\ShortUrl\Model\ShortUrlIdentifier;
|
||||
use Shlinkio\Shlink\Core\ShortUrl\Repository\ShortUrlRepositoryInterface;
|
||||
use Shlinkio\Shlink\Core\ShortUrl\Repository\ShortUrlRepository;
|
||||
use Shlinkio\Shlink\Core\Visit\Entity\Visit;
|
||||
use Shlinkio\Shlink\Core\Visit\Entity\VisitLocation;
|
||||
use Shlinkio\Shlink\Core\Visit\Persistence\OrphanVisitsCountFiltering;
|
||||
@@ -48,7 +48,7 @@ class VisitRepository extends EntitySpecificationRepository implements VisitRepo
|
||||
ShortUrlIdentifier $identifier,
|
||||
VisitsCountFiltering $filtering,
|
||||
): QueryBuilder {
|
||||
/** @var ShortUrlRepositoryInterface $shortUrlRepo */
|
||||
/** @var ShortUrlRepository $shortUrlRepo */
|
||||
$shortUrlRepo = $this->getEntityManager()->getRepository(ShortUrl::class);
|
||||
$shortUrlId = $shortUrlRepo->findOne($identifier, $filtering->apiKey?->spec())?->getId() ?? '-1';
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ use Shlinkio\Shlink\Core\Exception\ShortUrlNotFoundException;
|
||||
use Shlinkio\Shlink\Core\Exception\TagNotFoundException;
|
||||
use Shlinkio\Shlink\Core\ShortUrl\Entity\ShortUrl;
|
||||
use Shlinkio\Shlink\Core\ShortUrl\Model\ShortUrlIdentifier;
|
||||
use Shlinkio\Shlink\Core\ShortUrl\Repository\ShortUrlRepositoryInterface;
|
||||
use Shlinkio\Shlink\Core\ShortUrl\Repository\ShortUrlRepository;
|
||||
use Shlinkio\Shlink\Core\Tag\Entity\Tag;
|
||||
use Shlinkio\Shlink\Core\Tag\Repository\TagRepository;
|
||||
use Shlinkio\Shlink\Core\Visit\Entity\OrphanVisitsCount;
|
||||
@@ -32,7 +32,7 @@ use Shlinkio\Shlink\Core\Visit\Persistence\OrphanVisitsCountFiltering;
|
||||
use Shlinkio\Shlink\Core\Visit\Persistence\VisitsCountFiltering;
|
||||
use Shlinkio\Shlink\Core\Visit\Repository\OrphanVisitsCountRepository;
|
||||
use Shlinkio\Shlink\Core\Visit\Repository\ShortUrlVisitsCountRepository;
|
||||
use Shlinkio\Shlink\Core\Visit\Repository\VisitRepositoryInterface;
|
||||
use Shlinkio\Shlink\Core\Visit\Repository\VisitRepository;
|
||||
use Shlinkio\Shlink\Rest\Entity\ApiKey;
|
||||
|
||||
readonly class VisitsStatsHelper implements VisitsStatsHelperInterface
|
||||
@@ -70,13 +70,13 @@ readonly class VisitsStatsHelper implements VisitsStatsHelperInterface
|
||||
VisitsParams $params,
|
||||
ApiKey|null $apiKey = null,
|
||||
): Paginator {
|
||||
/** @var ShortUrlRepositoryInterface $repo */
|
||||
/** @var ShortUrlRepository $repo */
|
||||
$repo = $this->em->getRepository(ShortUrl::class);
|
||||
if (! $repo->shortCodeIsInUse($identifier, $apiKey?->spec())) {
|
||||
throw ShortUrlNotFoundException::fromNotFound($identifier);
|
||||
}
|
||||
|
||||
/** @var VisitRepositoryInterface $repo */
|
||||
/** @var VisitRepository $repo */
|
||||
$repo = $this->em->getRepository(Visit::class);
|
||||
|
||||
return $this->createPaginator(
|
||||
@@ -96,7 +96,7 @@ readonly class VisitsStatsHelper implements VisitsStatsHelperInterface
|
||||
throw TagNotFoundException::fromTag($tag);
|
||||
}
|
||||
|
||||
/** @var VisitRepositoryInterface $repo */
|
||||
/** @var VisitRepository $repo */
|
||||
$repo = $this->em->getRepository(Visit::class);
|
||||
|
||||
return $this->createPaginator(new TagVisitsPaginatorAdapter($repo, $tag, $params, $apiKey), $params);
|
||||
@@ -113,7 +113,7 @@ readonly class VisitsStatsHelper implements VisitsStatsHelperInterface
|
||||
throw DomainNotFoundException::fromAuthority($domain);
|
||||
}
|
||||
|
||||
/** @var VisitRepositoryInterface $repo */
|
||||
/** @var VisitRepository $repo */
|
||||
$repo = $this->em->getRepository(Visit::class);
|
||||
|
||||
return $this->createPaginator(new DomainVisitsPaginatorAdapter($repo, $domain, $params, $apiKey), $params);
|
||||
@@ -124,7 +124,7 @@ readonly class VisitsStatsHelper implements VisitsStatsHelperInterface
|
||||
*/
|
||||
public function orphanVisits(OrphanVisitsParams $params, ApiKey|null $apiKey = null): Paginator
|
||||
{
|
||||
/** @var VisitRepositoryInterface $repo */
|
||||
/** @var VisitRepository $repo */
|
||||
$repo = $this->em->getRepository(Visit::class);
|
||||
|
||||
return $this->createPaginator(new OrphanVisitsPaginatorAdapter($repo, $params, $apiKey), $params);
|
||||
@@ -132,7 +132,7 @@ readonly class VisitsStatsHelper implements VisitsStatsHelperInterface
|
||||
|
||||
public function nonOrphanVisits(VisitsParams $params, ApiKey|null $apiKey = null): Paginator
|
||||
{
|
||||
/** @var VisitRepositoryInterface $repo */
|
||||
/** @var VisitRepository $repo */
|
||||
$repo = $this->em->getRepository(Visit::class);
|
||||
|
||||
return $this->createPaginator(new NonOrphanVisitsPaginatorAdapter($repo, $params, $apiKey), $params);
|
||||
|
||||
Reference in New Issue
Block a user