Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make classes readonly when possible #2252

Merged
merged 1 commit into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion module/CLI/src/Input/EndDateOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

use function sprintf;

readonly final class EndDateOption
final readonly class EndDateOption
{
private DateOption $dateOption;

Expand Down
2 changes: 1 addition & 1 deletion module/CLI/src/Input/ShortUrlDataInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use function Shlinkio\Shlink\Core\ArrayUtils\flatten;
use function Shlinkio\Shlink\Core\splitByComma;

readonly final class ShortUrlDataInput
final readonly class ShortUrlDataInput
{
public function __construct(Command $command, private bool $longUrlAsOption = false)
{
Expand Down
2 changes: 1 addition & 1 deletion module/CLI/src/Input/ShortUrlIdentifierInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;

readonly final class ShortUrlIdentifierInput
final readonly class ShortUrlIdentifierInput
{
public function __construct(Command $command, string $shortCodeDesc, string $domainDesc)
{
Expand Down
2 changes: 1 addition & 1 deletion module/CLI/src/Input/StartDateOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

use function sprintf;

readonly final class StartDateOption
final readonly class StartDateOption
{
private DateOption $dateOption;

Expand Down
4 changes: 2 additions & 2 deletions module/Core/src/Crawling/CrawlingHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

use Shlinkio\Shlink\Core\ShortUrl\Repository\CrawlableShortCodesQueryInterface;

class CrawlingHelper implements CrawlingHelperInterface
readonly class CrawlingHelper implements CrawlingHelperInterface
{
public function __construct(private readonly CrawlableShortCodesQueryInterface $query)
public function __construct(private CrawlableShortCodesQueryInterface $query)
{
}

Expand Down
8 changes: 4 additions & 4 deletions module/Core/src/Domain/Model/DomainItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
use Shlinkio\Shlink\Core\Config\NotFoundRedirects;
use Shlinkio\Shlink\Core\Domain\Entity\Domain;

final class DomainItem implements JsonSerializable
final readonly class DomainItem implements JsonSerializable
{
private function __construct(
private readonly string $authority,
public readonly NotFoundRedirectConfigInterface $notFoundRedirectConfig,
public readonly bool $isDefault,
private string $authority,
public NotFoundRedirectConfigInterface $notFoundRedirectConfig,
public bool $isDefault,
) {
}

Expand Down
4 changes: 2 additions & 2 deletions module/Core/src/ErrorHandler/Model/NotFoundType.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

use function rtrim;

class NotFoundType
readonly class NotFoundType
{
private function __construct(private readonly VisitType|null $type)
private function __construct(private VisitType|null $type)
{
}

Expand Down
6 changes: 3 additions & 3 deletions module/Core/src/EventDispatcher/LocateUnlocatedVisits.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
use Shlinkio\Shlink\Core\Visit\Geolocation\VisitToLocationHelperInterface;
use Shlinkio\Shlink\IpGeolocation\Model\Location;

class LocateUnlocatedVisits implements VisitGeolocationHelperInterface
readonly class LocateUnlocatedVisits implements VisitGeolocationHelperInterface
{
public function __construct(
private readonly VisitLocatorInterface $locator,
private readonly VisitToLocationHelperInterface $visitToLocation,
private VisitLocatorInterface $locator,
private VisitToLocationHelperInterface $visitToLocation,
) {
}

Expand Down
8 changes: 4 additions & 4 deletions module/Core/src/EventDispatcher/UpdateGeoLiteDb.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@

use function sprintf;

class UpdateGeoLiteDb
readonly class UpdateGeoLiteDb
{
public function __construct(
private readonly GeolocationDbUpdaterInterface $dbUpdater,
private readonly LoggerInterface $logger,
private readonly EventDispatcherInterface $eventDispatcher,
private GeolocationDbUpdaterInterface $dbUpdater,
private LoggerInterface $logger,
private EventDispatcherInterface $eventDispatcher,
) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
use function sprintf;
use function trim;

class ExtraPathRedirectMiddleware implements MiddlewareInterface
readonly class ExtraPathRedirectMiddleware implements MiddlewareInterface
{
public function __construct(
private readonly ShortUrlResolverInterface $resolver,
private readonly RequestTrackerInterface $requestTracker,
private readonly ShortUrlRedirectionBuilderInterface $redirectionBuilder,
private readonly RedirectResponseHelperInterface $redirectResponseHelper,
private readonly UrlShortenerOptions $urlShortenerOptions,
private ShortUrlResolverInterface $resolver,
private RequestTrackerInterface $requestTracker,
private ShortUrlRedirectionBuilderInterface $redirectionBuilder,
private RedirectResponseHelperInterface $redirectResponseHelper,
private UrlShortenerOptions $urlShortenerOptions,
) {
}

Expand Down
6 changes: 3 additions & 3 deletions module/Core/src/ShortUrl/Model/UrlShorteningResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
use Shlinkio\Shlink\Core\ShortUrl\Entity\ShortUrl;
use Throwable;

final class UrlShorteningResult
final readonly class UrlShorteningResult
{
private function __construct(
public readonly ShortUrl $shortUrl,
private readonly Throwable|null $errorOnEventDispatching,
public ShortUrl $shortUrl,
private Throwable|null $errorOnEventDispatching,
) {
}

Expand Down
6 changes: 3 additions & 3 deletions module/Core/src/ShortUrl/ShortUrlVisitsDeleter.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
use Shlinkio\Shlink\Core\Visit\Repository\VisitDeleterRepositoryInterface;
use Shlinkio\Shlink\Rest\Entity\ApiKey;

class ShortUrlVisitsDeleter implements ShortUrlVisitsDeleterInterface
readonly class ShortUrlVisitsDeleter implements ShortUrlVisitsDeleterInterface
{
public function __construct(
private readonly VisitDeleterRepositoryInterface $repository,
private readonly ShortUrlResolverInterface $resolver,
private VisitDeleterRepositoryInterface $repository,
private ShortUrlResolverInterface $resolver,
) {
}

Expand Down
4 changes: 2 additions & 2 deletions module/Core/src/Util/RedirectResponseHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

use function sprintf;

class RedirectResponseHelper implements RedirectResponseHelperInterface
readonly class RedirectResponseHelper implements RedirectResponseHelperInterface
{
public function __construct(private readonly RedirectOptions $options)
public function __construct(private RedirectOptions $options)
{
}

Expand Down
6 changes: 3 additions & 3 deletions module/Core/src/Visit/Geolocation/VisitLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
use Shlinkio\Shlink\Core\Visit\Repository\VisitIterationRepositoryInterface;
use Shlinkio\Shlink\IpGeolocation\Model\Location;

class VisitLocator implements VisitLocatorInterface
readonly class VisitLocator implements VisitLocatorInterface
{
public function __construct(
private readonly EntityManagerInterface $em,
private readonly VisitIterationRepositoryInterface $repo,
private EntityManagerInterface $em,
private VisitIterationRepositoryInterface $repo,
) {
}

Expand Down
4 changes: 2 additions & 2 deletions module/Core/src/Visit/Geolocation/VisitToLocationHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
use Shlinkio\Shlink\IpGeolocation\Model\Location;
use Shlinkio\Shlink\IpGeolocation\Resolver\IpLocationResolverInterface;

class VisitToLocationHelper implements VisitToLocationHelperInterface
readonly class VisitToLocationHelper implements VisitToLocationHelperInterface
{
public function __construct(private readonly IpLocationResolverInterface $ipLocationResolver)
public function __construct(private IpLocationResolverInterface $ipLocationResolver)
{
}

Expand Down
4 changes: 2 additions & 2 deletions module/Core/src/Visit/VisitsDeleter.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
use Shlinkio\Shlink\Rest\ApiKey\Role;
use Shlinkio\Shlink\Rest\Entity\ApiKey;

class VisitsDeleter implements VisitsDeleterInterface
readonly class VisitsDeleter implements VisitsDeleterInterface
{
public function __construct(private readonly VisitDeleterRepositoryInterface $repository)
public function __construct(private VisitDeleterRepositoryInterface $repository)
{
}

Expand Down
Loading