Skip to content

Apply PHP 8.2 syntax #228

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

Merged
merged 2 commits into from
Dec 21, 2022
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 src/Changelog/CommitReleaseChangelogViaKeepAChangelog.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
11 changes: 4 additions & 7 deletions src/Git/Value/BranchName.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
) {
}

/**
Expand Down
6 changes: 2 additions & 4 deletions src/Git/Value/MergeTargetCandidateBranches.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(...));

Expand Down
2 changes: 1 addition & 1 deletion src/Git/Value/SemVerVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Psl\Regex;

/** @psalm-immutable */
final class SemVerVersion
final readonly class SemVerVersion
{
private function __construct(
private readonly int $major,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Psr\Http\Message\UriInterface;

/** @psalm-immutable */
final class IssueOrPullRequest
final readonly class IssueOrPullRequest
{
/**
* @param array<int, Label> $labels
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use Psr\Http\Message\UriInterface;

/** @psalm-immutable */
final class Label
final readonly class Label
{
/**
* @psalm-param non-empty-string $colour
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use Psr\Http\Message\UriInterface;

/** @psalm-immutable */
final class Milestone
final readonly class Milestone
{
/**
* @param array<int, IssueOrPullRequest> $entries
Expand Down Expand Up @@ -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.');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion src/Github/Api/GraphQL/RunGraphQLQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
2 changes: 1 addition & 1 deletion src/Github/Api/V3/CreateMilestoneThroughApiCall.php
Original file line number Diff line number Diff line change
Expand Up @@ -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/';

Expand Down
2 changes: 1 addition & 1 deletion src/Github/Api/V3/CreatePullRequestThroughApiCall.php
Original file line number Diff line number Diff line change
Expand Up @@ -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/';

Expand Down
2 changes: 1 addition & 1 deletion src/Github/Api/V3/CreateReleaseThroughApiCall.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
2 changes: 1 addition & 1 deletion src/Github/Api/V3/SetDefaultBranchThroughApiCall.php
Original file line number Diff line number Diff line change
Expand Up @@ -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/';

Expand Down
2 changes: 1 addition & 1 deletion src/Github/CreateReleaseTextThroughChangelog.php
Original file line number Diff line number Diff line change
Expand Up @@ -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%
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Github/Event/MilestoneClosedEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Psl\Type;

/** @psalm-immutable */
final class MilestoneClosedEvent
final readonly class MilestoneClosedEvent
{
private function __construct(
private readonly SemVerVersion $version,
Expand Down
2 changes: 1 addition & 1 deletion src/Github/JwageGenerateChangelog.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
11 changes: 4 additions & 7 deletions src/Github/MergeMultipleReleaseNotes.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<CreateReleaseText> */
private array $releaseTextGenerators;

/** @psalm-param non-empty-list<CreateReleaseText> $releaseTextGenerators */
public function __construct(array $releaseTextGenerators)
{
$this->releaseTextGenerators = $releaseTextGenerators;
public function __construct(
private readonly array $releaseTextGenerators,
) {
}

public function __invoke(
Expand Down
16 changes: 5 additions & 11 deletions src/Github/Value/RepositoryName.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
) {
}

/**
Expand Down
11 changes: 4 additions & 7 deletions src/Gpg/SecretKeyId.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion src/HttpClient/LoggingHttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion test/unit/Environment/EnvironmentVariablesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
));
}

Expand Down