Make classes readonly when possible

This commit is contained in:
Alejandro Celaya
2024-11-09 09:55:51 +01:00
parent d6b103de83
commit 72f1e243b5
16 changed files with 40 additions and 40 deletions

View File

@@ -25,14 +25,14 @@ use function implode;
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,
) {
}

View File

@@ -7,11 +7,11 @@ namespace Shlinkio\Shlink\Core\ShortUrl\Model;
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,
) {
}

View File

@@ -10,11 +10,11 @@ use Shlinkio\Shlink\Core\ShortUrl\Model\ShortUrlIdentifier;
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,
) {
}