Skip to content

Commit

Permalink
Mark classes as readonly (#261)
Browse files Browse the repository at this point in the history
Some found by PhpStorm, some manually because PhpStorm didn't flag them for some reason. Seems that whenever there's something, even like a constant, the class won't be marked as `readonly`-able.
  • Loading branch information
spaze authored Dec 31, 2023
2 parents b816100 + e627d92 commit decba12
Show file tree
Hide file tree
Showing 134 changed files with 713 additions and 713 deletions.
4 changes: 2 additions & 2 deletions site/app/Api/Presenters/ErrorGenericPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
use Nette\Application\Response;
use Override;

class ErrorGenericPresenter implements IPresenter
readonly class ErrorGenericPresenter implements IPresenter
{

public function __construct(
private readonly Error $error,
private Error $error,
) {
}

Expand Down
6 changes: 3 additions & 3 deletions site/app/Application/Cli/CliArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@

namespace MichalSpacekCz\Application\Cli;

class CliArgs
readonly class CliArgs
{

/**
* @param array<string, mixed> $args
*/
public function __construct(
private readonly array $args,
private readonly ?string $error,
private array $args,
private ?string $error,
) {
}

Expand Down
6 changes: 3 additions & 3 deletions site/app/Application/Error.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
use Nette\Application\Responses\ForwardResponse;
use Tracy\ILogger;

class Error
readonly class Error
{

public function __construct(
private readonly ILogger $logger,
private readonly AppRequest $appRequest,
private ILogger $logger,
private AppRequest $appRequest,
) {
}

Expand Down
10 changes: 5 additions & 5 deletions site/app/Application/Locale/LocaleLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

namespace MichalSpacekCz\Application\Locale;

class LocaleLink
readonly class LocaleLink
{

public function __construct(
private readonly string $locale,
private readonly string $languageCode,
private readonly string $languageName,
private readonly string $url,
private string $locale,
private string $languageCode,
private string $languageName,
private string $url,
) {
}

Expand Down
12 changes: 6 additions & 6 deletions site/app/Application/Routing/RouterFactoryRoute.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@

namespace MichalSpacekCz\Application\Routing;

class RouterFactoryRoute
readonly class RouterFactoryRoute
{

/**
* @param array<string, array<string, string>>|null $initialMetadata
*/
public function __construct(
public readonly string $mask,
public readonly string $defaultPresenter,
public readonly string $defaultAction,
public readonly ?array $initialMetadata = null,
public readonly RouterRoutes $class = RouterRoutes::Route,
public string $mask,
public string $defaultPresenter,
public string $defaultAction,
public ?array $initialMetadata = null,
public RouterRoutes $class = RouterRoutes::Route,
) {
}

Expand Down
4 changes: 2 additions & 2 deletions site/app/Application/Theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use MichalSpacekCz\Http\Cookies\CookieName;
use MichalSpacekCz\Http\Cookies\Cookies;

class Theme
readonly class Theme
{

private const DARK = 'dark';
Expand All @@ -15,7 +15,7 @@ class Theme


public function __construct(
private readonly Cookies $cookies,
private Cookies $cookies,
) {
}

Expand Down
12 changes: 6 additions & 6 deletions site/app/Application/WebApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
use Nette\Http\IRequest;
use Nette\Http\IResponse;

class WebApplication
readonly class WebApplication
{

public function __construct(
private readonly IRequest $httpRequest,
private readonly IResponse $httpResponse,
private readonly SecurityHeaders $securityHeaders,
private readonly Application $application,
private readonly string $fqdn,
private IRequest $httpRequest,
private IResponse $httpResponse,
private SecurityHeaders $securityHeaders,
private Application $application,
private string $fqdn,
) {
}

Expand Down
8 changes: 4 additions & 4 deletions site/app/Articles/ArticleEdit.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
use DateTime;
use Nette\Utils\Html;

class ArticleEdit
readonly class ArticleEdit
{

public function __construct(
private readonly DateTime $editedAt,
private readonly Html $summary,
private readonly string $summaryTexy,
private DateTime $editedAt,
private Html $summary,
private string $summaryTexy,
) {
}

Expand Down
20 changes: 10 additions & 10 deletions site/app/Articles/ArticlePublishedElsewhere.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@
use Nette\Utils\Html;
use Override;

class ArticlePublishedElsewhere implements ArticleWithId, ArticleWithSummary, ArticleWithPublishTime
readonly class ArticlePublishedElsewhere implements ArticleWithId, ArticleWithSummary, ArticleWithPublishTime
{

public function __construct(
private readonly int $articleId,
private readonly Html $title,
private readonly string $titleTexy,
private readonly string $href,
private readonly DateTime $published,
private readonly Html $excerpt,
private readonly string $excerptTexy,
private readonly string $sourceName,
private readonly string $sourceHref,
private int $articleId,
private Html $title,
private string $titleTexy,
private string $href,
private DateTime $published,
private Html $excerpt,
private string $excerptTexy,
private string $sourceName,
private string $sourceHref,
) {
}

Expand Down
54 changes: 27 additions & 27 deletions site/app/Articles/Blog/BlogPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use Nette\Utils\Html;
use Override;

class BlogPost implements ExportsOmittable, ArticleWithId, ArticleWithSlug, ArticleWithSummary, ArticleWithText, ArticleWithTags, ArticleWithUpdateTime, ArticleWithPublishTime, ArticleWithEdits
readonly class BlogPost implements ExportsOmittable, ArticleWithId, ArticleWithSlug, ArticleWithSummary, ArticleWithText, ArticleWithTags, ArticleWithUpdateTime, ArticleWithPublishTime, ArticleWithEdits
{

/**
Expand All @@ -30,32 +30,32 @@ class BlogPost implements ExportsOmittable, ArticleWithId, ArticleWithSlug, Arti
* @param list<string> $allowedTagsGroups
*/
public function __construct(
private readonly ?int $id,
private readonly string $slug,
private readonly int $localeId,
private readonly ?string $locale,
private readonly ?int $translationGroupId,
private readonly Html $title,
private readonly string $titleTexy,
private readonly ?Html $lead,
private readonly ?string $leadTexy,
private readonly Html $text,
private readonly string $textTexy,
private readonly ?DateTime $published,
private readonly bool $needsPreviewKey,
private readonly ?string $previewKey,
private readonly ?Html $originally,
private readonly ?string $originallyTexy,
private readonly ?string $ogImage,
private readonly array $tags,
private readonly array $slugTags,
private readonly array $recommended,
private readonly ?TwitterCard $twitterCard,
private readonly string $href,
private readonly array $edits,
private readonly array $cspSnippets,
private readonly array $allowedTagsGroups,
private readonly bool $omitExports,
private ?int $id,
private string $slug,
private int $localeId,
private ?string $locale,
private ?int $translationGroupId,
private Html $title,
private string $titleTexy,
private ?Html $lead,
private ?string $leadTexy,
private Html $text,
private string $textTexy,
private ?DateTime $published,
private bool $needsPreviewKey,
private ?string $previewKey,
private ?Html $originally,
private ?string $originallyTexy,
private ?string $ogImage,
private array $tags,
private array $slugTags,
private array $recommended,
private ?TwitterCard $twitterCard,
private string $href,
private array $edits,
private array $cspSnippets,
private array $allowedTagsGroups,
private bool $omitExports,
) {
}

Expand Down
8 changes: 4 additions & 4 deletions site/app/Articles/Blog/BlogPostEdits.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
use MichalSpacekCz\Formatter\TexyFormatter;
use Nette\Database\Explorer;

class BlogPostEdits
readonly class BlogPostEdits
{

public function __construct(
private readonly Explorer $database,
private readonly DateTimeZoneFactory $dateTimeZoneFactory,
private readonly TexyFormatter $texyFormatter,
private Explorer $database,
private DateTimeZoneFactory $dateTimeZoneFactory,
private TexyFormatter $texyFormatter,
) {
}

Expand Down
22 changes: 11 additions & 11 deletions site/app/Articles/Blog/BlogPostFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,23 @@
use Nette\Database\Row;
use Nette\Utils\JsonException;

class BlogPostFactory
readonly class BlogPostFactory
{

/**
* @param array<string, array<string, list<string>>> $allowedTags
*/
public function __construct(
private readonly TexyFormatter $texyFormatter,
private readonly Tags $tags,
private readonly TwitterCards $twitterCards,
private readonly BlogPostRecommendedLinks $recommendedLinks,
private readonly BlogPostEdits $edits,
private readonly JsonUtils $jsonUtils,
private readonly LinkGenerator $linkGenerator,
private readonly LocaleLinkGenerator $localeLinkGenerator,
private readonly Translator $translator,
private readonly array $allowedTags,
private TexyFormatter $texyFormatter,
private Tags $tags,
private TwitterCards $twitterCards,
private BlogPostRecommendedLinks $recommendedLinks,
private BlogPostEdits $edits,
private JsonUtils $jsonUtils,
private LinkGenerator $linkGenerator,
private LocaleLinkGenerator $localeLinkGenerator,
private Translator $translator,
private array $allowedTags,
) {
}

Expand Down
12 changes: 6 additions & 6 deletions site/app/Articles/Blog/BlogPostLocaleUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@

use DateTime;

class BlogPostLocaleUrl
readonly class BlogPostLocaleUrl
{

/**
* @param list<string> $slugTags
*/
public function __construct(
private readonly string $locale,
private readonly string $slug,
private readonly ?DateTime $published,
private readonly ?string $previewKey,
private readonly array $slugTags,
private string $locale,
private string $slug,
private ?DateTime $published,
private ?string $previewKey,
private array $slugTags,
) {
}

Expand Down
6 changes: 3 additions & 3 deletions site/app/Articles/Blog/BlogPostLocaleUrls.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
use Nette\Database\Explorer;
use Nette\Utils\JsonException;

class BlogPostLocaleUrls
readonly class BlogPostLocaleUrls
{

public function __construct(
private readonly Explorer $database,
private readonly Tags $tags,
private Explorer $database,
private Tags $tags,
) {
}

Expand Down
10 changes: 5 additions & 5 deletions site/app/Articles/Blog/BlogPostPreview.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
use Nette\Bridges\ApplicationLatte\DefaultTemplate;
use Spaze\ContentSecurityPolicy\CspConfig;

class BlogPostPreview
readonly class BlogPostPreview
{

public function __construct(
private readonly TexyFormatter $texyFormatter,
private readonly BlogPosts $blogPosts,
private readonly UpcomingTrainingDates $upcomingTrainingDates,
private readonly CspConfig $contentSecurityPolicy,
private TexyFormatter $texyFormatter,
private BlogPosts $blogPosts,
private UpcomingTrainingDates $upcomingTrainingDates,
private CspConfig $contentSecurityPolicy,
) {
}

Expand Down
6 changes: 3 additions & 3 deletions site/app/Articles/Blog/BlogPostRecommendedLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
use JsonSerializable;
use Override;

class BlogPostRecommendedLink implements JsonSerializable
readonly class BlogPostRecommendedLink implements JsonSerializable
{

public function __construct(
private readonly string $url,
private readonly string $text,
private string $url,
private string $text,
) {
}

Expand Down
Loading

0 comments on commit decba12

Please sign in to comment.