diff --git a/src/Changelog/CommitReleaseChangelogViaKeepAChangelog.php b/src/Changelog/CommitReleaseChangelogViaKeepAChangelog.php index a5beb2ae..f25fb044 100644 --- a/src/Changelog/CommitReleaseChangelogViaKeepAChangelog.php +++ b/src/Changelog/CommitReleaseChangelogViaKeepAChangelog.php @@ -14,7 +14,7 @@ use Psl\Type; use Psr\Log\LoggerInterface; -final class CommitReleaseChangelogViaKeepAChangelog implements CommitReleaseChangelog +final readonly class CommitReleaseChangelogViaKeepAChangelog implements CommitReleaseChangelog { private const CHANGELOG_FILE = 'CHANGELOG.md'; diff --git a/src/Git/FetchAndSetCurrentUserByReplacingCurrentOriginRemote.php b/src/Git/FetchAndSetCurrentUserByReplacingCurrentOriginRemote.php index 23c51514..417d5b31 100644 --- a/src/Git/FetchAndSetCurrentUserByReplacingCurrentOriginRemote.php +++ b/src/Git/FetchAndSetCurrentUserByReplacingCurrentOriginRemote.php @@ -10,7 +10,7 @@ use Psl\Shell; use Psr\Http\Message\UriInterface; -final class FetchAndSetCurrentUserByReplacingCurrentOriginRemote implements Fetch +final readonly class FetchAndSetCurrentUserByReplacingCurrentOriginRemote implements Fetch { public function __construct(private readonly EnvironmentVariables $variables) { diff --git a/src/Git/Value/BranchName.php b/src/Git/Value/BranchName.php index 5eec5c37..31f21ad2 100644 --- a/src/Git/Value/BranchName.php +++ b/src/Git/Value/BranchName.php @@ -9,15 +9,12 @@ use Psl\Type; /** @psalm-immutable */ -final class BranchName +final readonly class BranchName { - /** @psalm-var non-empty-string */ - private string $name; - /** @psalm-param non-empty-string $name */ - private function __construct(string $name) - { - $this->name = $name; + private function __construct( + private readonly string $name, + ) { } /** diff --git a/src/Git/Value/MergeTargetCandidateBranches.php b/src/Git/Value/MergeTargetCandidateBranches.php index bc976a29..192d9ea4 100644 --- a/src/Git/Value/MergeTargetCandidateBranches.php +++ b/src/Git/Value/MergeTargetCandidateBranches.php @@ -13,7 +13,7 @@ use function Psl\Vec\filter; use function Psl\Vec\reverse; -final class MergeTargetCandidateBranches +final readonly class MergeTargetCandidateBranches { /** * @param BranchName[] $sortedBranches branches that can be used for releases, sorted in ascending version number @@ -25,9 +25,7 @@ private function __construct(private readonly array $sortedBranches) public static function fromAllBranches(BranchName ...$branches): self { - $mergeTargetBranches = filter($branches, static function (BranchName $branch): bool { - return $branch->isReleaseBranch(); - }); + $mergeTargetBranches = filter($branches, static fn (BranchName $branch): bool => $branch->isReleaseBranch()); $mergeTargetBranches = Vec\sort($mergeTargetBranches, self::branchOrder(...)); diff --git a/src/Git/Value/SemVerVersion.php b/src/Git/Value/SemVerVersion.php index d1032e69..0423aa44 100644 --- a/src/Git/Value/SemVerVersion.php +++ b/src/Git/Value/SemVerVersion.php @@ -8,7 +8,7 @@ use Psl\Regex; /** @psalm-immutable */ -final class SemVerVersion +final readonly class SemVerVersion { private function __construct( private readonly int $major, diff --git a/src/Github/Api/GraphQL/Query/GetMilestoneChangelog/Response/Author.php b/src/Github/Api/GraphQL/Query/GetMilestoneChangelog/Response/Author.php index 6fa0a932..550a2ef5 100644 --- a/src/Github/Api/GraphQL/Query/GetMilestoneChangelog/Response/Author.php +++ b/src/Github/Api/GraphQL/Query/GetMilestoneChangelog/Response/Author.php @@ -8,7 +8,7 @@ use Psl\Type; use Psr\Http\Message\UriInterface; -final class Author +final readonly class Author { /** @psalm-param non-empty-string $name */ private function __construct( diff --git a/src/Github/Api/GraphQL/Query/GetMilestoneChangelog/Response/IssueOrPullRequest.php b/src/Github/Api/GraphQL/Query/GetMilestoneChangelog/Response/IssueOrPullRequest.php index f1f05dc1..4e303202 100644 --- a/src/Github/Api/GraphQL/Query/GetMilestoneChangelog/Response/IssueOrPullRequest.php +++ b/src/Github/Api/GraphQL/Query/GetMilestoneChangelog/Response/IssueOrPullRequest.php @@ -10,7 +10,7 @@ use Psr\Http\Message\UriInterface; /** @psalm-immutable */ -final class IssueOrPullRequest +final readonly class IssueOrPullRequest { /** * @param array $labels diff --git a/src/Github/Api/GraphQL/Query/GetMilestoneChangelog/Response/Label.php b/src/Github/Api/GraphQL/Query/GetMilestoneChangelog/Response/Label.php index 4d416ca2..2fea1b11 100644 --- a/src/Github/Api/GraphQL/Query/GetMilestoneChangelog/Response/Label.php +++ b/src/Github/Api/GraphQL/Query/GetMilestoneChangelog/Response/Label.php @@ -11,7 +11,7 @@ use Psr\Http\Message\UriInterface; /** @psalm-immutable */ -final class Label +final readonly class Label { /** * @psalm-param non-empty-string $colour diff --git a/src/Github/Api/GraphQL/Query/GetMilestoneChangelog/Response/Milestone.php b/src/Github/Api/GraphQL/Query/GetMilestoneChangelog/Response/Milestone.php index 12ee574e..ec46bc43 100644 --- a/src/Github/Api/GraphQL/Query/GetMilestoneChangelog/Response/Milestone.php +++ b/src/Github/Api/GraphQL/Query/GetMilestoneChangelog/Response/Milestone.php @@ -12,7 +12,7 @@ use Psr\Http\Message\UriInterface; /** @psalm-immutable */ -final class Milestone +final readonly class Milestone { /** * @param array $entries @@ -101,8 +101,6 @@ public function url(): UriInterface /** @psalm-suppress ImpureFunctionCall the {@see \Psl\Iter\all()} API is conditionally pure */ public function assertAllIssuesAreClosed(): void { - Psl\invariant(Iter\all($this->entries, static function (IssueOrPullRequest $entry): bool { - return $entry->closed(); - }), 'Failed asserting that all milestone issues are closed.'); + Psl\invariant(Iter\all($this->entries, static fn (IssueOrPullRequest $entry): bool => $entry->closed()), 'Failed asserting that all milestone issues are closed.'); } } diff --git a/src/Github/Api/GraphQL/Query/GetMilestoneFirst100IssuesAndPullRequests.php b/src/Github/Api/GraphQL/Query/GetMilestoneFirst100IssuesAndPullRequests.php index 625db2cd..de6ec76a 100644 --- a/src/Github/Api/GraphQL/Query/GetMilestoneFirst100IssuesAndPullRequests.php +++ b/src/Github/Api/GraphQL/Query/GetMilestoneFirst100IssuesAndPullRequests.php @@ -9,7 +9,7 @@ use Laminas\AutomaticReleases\Github\Value\RepositoryName; use Psl\Type; -final class GetMilestoneFirst100IssuesAndPullRequests implements GetGithubMilestone +final readonly class GetMilestoneFirst100IssuesAndPullRequests implements GetGithubMilestone { // @TODO this fetches ONLY the first 100 issues!!! private const QUERY = <<<'GRAPHQL' diff --git a/src/Github/Api/GraphQL/RunGraphQLQuery.php b/src/Github/Api/GraphQL/RunGraphQLQuery.php index d0edce88..71c1897b 100644 --- a/src/Github/Api/GraphQL/RunGraphQLQuery.php +++ b/src/Github/Api/GraphQL/RunGraphQLQuery.php @@ -12,7 +12,7 @@ use function array_key_exists; -final class RunGraphQLQuery implements RunQuery +final readonly class RunGraphQLQuery implements RunQuery { private const ENDPOINT = 'https://api.github.com/graphql'; diff --git a/src/Github/Api/V3/CreateMilestoneThroughApiCall.php b/src/Github/Api/V3/CreateMilestoneThroughApiCall.php index 66ecc72d..e4de0400 100644 --- a/src/Github/Api/V3/CreateMilestoneThroughApiCall.php +++ b/src/Github/Api/V3/CreateMilestoneThroughApiCall.php @@ -13,7 +13,7 @@ use Psr\Http\Message\RequestFactoryInterface; use Psr\Log\LoggerInterface; -final class CreateMilestoneThroughApiCall implements CreateMilestone +final readonly class CreateMilestoneThroughApiCall implements CreateMilestone { private const API_ROOT = 'https://api.github.com/'; diff --git a/src/Github/Api/V3/CreatePullRequestThroughApiCall.php b/src/Github/Api/V3/CreatePullRequestThroughApiCall.php index 0433c788..e0b51a38 100644 --- a/src/Github/Api/V3/CreatePullRequestThroughApiCall.php +++ b/src/Github/Api/V3/CreatePullRequestThroughApiCall.php @@ -12,7 +12,7 @@ use Psr\Http\Client\ClientInterface; use Psr\Http\Message\RequestFactoryInterface; -final class CreatePullRequestThroughApiCall implements CreatePullRequest +final readonly class CreatePullRequestThroughApiCall implements CreatePullRequest { private const API_ROOT = 'https://api.github.com/'; diff --git a/src/Github/Api/V3/CreateReleaseThroughApiCall.php b/src/Github/Api/V3/CreateReleaseThroughApiCall.php index a15eec28..128cdf8d 100644 --- a/src/Github/Api/V3/CreateReleaseThroughApiCall.php +++ b/src/Github/Api/V3/CreateReleaseThroughApiCall.php @@ -18,7 +18,7 @@ use function Psl\Type\shape; use function sprintf; -final class CreateReleaseThroughApiCall implements CreateRelease +final readonly class CreateReleaseThroughApiCall implements CreateRelease { private const API_URI = 'https://api.github.com/repos/%s/%s/releases'; diff --git a/src/Github/Api/V3/SetDefaultBranchThroughApiCall.php b/src/Github/Api/V3/SetDefaultBranchThroughApiCall.php index 2016862c..98accd43 100644 --- a/src/Github/Api/V3/SetDefaultBranchThroughApiCall.php +++ b/src/Github/Api/V3/SetDefaultBranchThroughApiCall.php @@ -12,7 +12,7 @@ use Psr\Http\Client\ClientInterface; use Psr\Http\Message\RequestFactoryInterface; -final class SetDefaultBranchThroughApiCall implements SetDefaultBranch +final readonly class SetDefaultBranchThroughApiCall implements SetDefaultBranch { private const API_ROOT = 'https://api.github.com/'; diff --git a/src/Github/CreateReleaseTextThroughChangelog.php b/src/Github/CreateReleaseTextThroughChangelog.php index 8bddf737..6c7b3e89 100644 --- a/src/Github/CreateReleaseTextThroughChangelog.php +++ b/src/Github/CreateReleaseTextThroughChangelog.php @@ -17,7 +17,7 @@ use function preg_quote; -final class CreateReleaseTextThroughChangelog implements CreateReleaseText +final readonly class CreateReleaseTextThroughChangelog implements CreateReleaseText { private const TEMPLATE = <<<'MARKDOWN' ### Release Notes for %release% diff --git a/src/Github/Event/Factory/LoadCurrentGithubEventFromGithubActionPath.php b/src/Github/Event/Factory/LoadCurrentGithubEventFromGithubActionPath.php index e1fb6778..5217a4b8 100644 --- a/src/Github/Event/Factory/LoadCurrentGithubEventFromGithubActionPath.php +++ b/src/Github/Event/Factory/LoadCurrentGithubEventFromGithubActionPath.php @@ -9,7 +9,7 @@ use function Psl\File\read; -final class LoadCurrentGithubEventFromGithubActionPath implements LoadCurrentGithubEvent +final readonly class LoadCurrentGithubEventFromGithubActionPath implements LoadCurrentGithubEvent { public function __construct(private readonly EnvironmentVariables $variables) { diff --git a/src/Github/Event/MilestoneClosedEvent.php b/src/Github/Event/MilestoneClosedEvent.php index 2a5cd475..5f4466a2 100644 --- a/src/Github/Event/MilestoneClosedEvent.php +++ b/src/Github/Event/MilestoneClosedEvent.php @@ -10,7 +10,7 @@ use Psl\Type; /** @psalm-immutable */ -final class MilestoneClosedEvent +final readonly class MilestoneClosedEvent { private function __construct( private readonly SemVerVersion $version, diff --git a/src/Github/JwageGenerateChangelog.php b/src/Github/JwageGenerateChangelog.php index c4bffe22..d5dd9b90 100644 --- a/src/Github/JwageGenerateChangelog.php +++ b/src/Github/JwageGenerateChangelog.php @@ -18,7 +18,7 @@ use Psr\Http\Message\RequestFactoryInterface; use Symfony\Component\Console\Output\BufferedOutput; -final class JwageGenerateChangelog implements GenerateChangelog +final readonly class JwageGenerateChangelog implements GenerateChangelog { public function __construct( private readonly ChangelogGenerator $changelogGenerator, diff --git a/src/Github/MergeMultipleReleaseNotes.php b/src/Github/MergeMultipleReleaseNotes.php index 2ff895a9..da9ebecf 100644 --- a/src/Github/MergeMultipleReleaseNotes.php +++ b/src/Github/MergeMultipleReleaseNotes.php @@ -13,15 +13,12 @@ use Psl\Type; use Psl\Vec; -final class MergeMultipleReleaseNotes implements CreateReleaseText +final readonly class MergeMultipleReleaseNotes implements CreateReleaseText { - /** @psalm-var non-empty-list */ - private array $releaseTextGenerators; - /** @psalm-param non-empty-list $releaseTextGenerators */ - public function __construct(array $releaseTextGenerators) - { - $this->releaseTextGenerators = $releaseTextGenerators; + public function __construct( + private readonly array $releaseTextGenerators, + ) { } public function __invoke( diff --git a/src/Github/Value/RepositoryName.php b/src/Github/Value/RepositoryName.php index 68570397..1848d50d 100644 --- a/src/Github/Value/RepositoryName.php +++ b/src/Github/Value/RepositoryName.php @@ -14,22 +14,16 @@ use function explode; /** @psalm-immutable */ -final class RepositoryName +final readonly class RepositoryName { - /** @psalm-var non-empty-string */ - private string $owner; - - /** @psalm-var non-empty-string */ - private string $name; - /** * @psalm-param non-empty-string $owner * @psalm-param non-empty-string $name */ - private function __construct(string $owner, string $name) - { - $this->owner = $owner; - $this->name = $name; + private function __construct( + private readonly string $owner, + private readonly string $name, + ) { } /** diff --git a/src/Gpg/SecretKeyId.php b/src/Gpg/SecretKeyId.php index 3d381426..d234e2e4 100644 --- a/src/Gpg/SecretKeyId.php +++ b/src/Gpg/SecretKeyId.php @@ -9,15 +9,12 @@ use Psl\Str; /** @psalm-immutable */ -final class SecretKeyId +final readonly class SecretKeyId { - /** @psalm-var non-empty-string */ - private string $id; - /** @psalm-param non-empty-string $id */ - private function __construct(string $id) - { - $this->id = $id; + private function __construct( + private readonly string $id, + ) { } /** @psalm-pure */ diff --git a/src/HttpClient/LoggingHttpClient.php b/src/HttpClient/LoggingHttpClient.php index 017cdb1d..24e9687c 100644 --- a/src/HttpClient/LoggingHttpClient.php +++ b/src/HttpClient/LoggingHttpClient.php @@ -10,7 +10,7 @@ use Psr\Log\LoggerInterface; /** @internal */ -final class LoggingHttpClient implements ClientInterface +final readonly class LoggingHttpClient implements ClientInterface { public function __construct(private readonly ClientInterface $next, private readonly LoggerInterface $logger) { diff --git a/test/unit/Environment/EnvironmentVariablesTest.php b/test/unit/Environment/EnvironmentVariablesTest.php index 0245ed17..e4e5e4c0 100644 --- a/test/unit/Environment/EnvironmentVariablesTest.php +++ b/test/unit/Environment/EnvironmentVariablesTest.php @@ -38,7 +38,7 @@ protected function setUp(): void $this->originalValues = Dict\associate(self::RESET_ENVIRONMENT_VARIABLES, Dict\map( self::RESET_ENVIRONMENT_VARIABLES, - static fn (string $variable) => Env\get_var($variable), + static fn (string $variable): string|null => Env\get_var($variable), )); }