diff --git a/bin/console.php b/bin/console.php index 50b2ddac..f1e2e6ba 100755 --- a/bin/console.php +++ b/bin/console.php @@ -57,7 +57,7 @@ static function (int $errorCode, string $message = '', string $file = '', int $line = 0): bool { throw new ErrorException($message, 0, $errorCode, $file, $line); }, - E_STRICT | E_NOTICE | E_WARNING + E_STRICT | E_NOTICE | E_WARNING, ); $variables = EnvironmentVariables::fromEnvironment(new ImportGpgKeyFromStringViaTemporaryFile()); @@ -72,7 +72,7 @@ static function (int $errorCode, string $message = '', string $file = '', int $l $getMilestone = new GetMilestoneFirst100IssuesAndPullRequests(new RunGraphQLQuery( $makeRequests, $httpClient, - $githubToken + $githubToken, )); $changelogExists = new ChangelogExistsViaConsole(); $checkoutBranch = new CheckoutBranchViaConsole(); @@ -83,12 +83,12 @@ static function (int $errorCode, string $message = '', string $file = '', int $l $checkoutBranch, $commit, $push, - $logger + $logger, ); $createCommitText = new CreateReleaseTextThroughChangelog(JwageGenerateChangelog::create( $makeRequests, $httpClient, - new GitHubOAuthToken($githubToken) + new GitHubOAuthToken($githubToken), )); $createReleaseText = new MergeMultipleReleaseNotes([ new CreateReleaseTextViaKeepAChangelog($changelogExists, new SystemClock(new DateTimeZone('UTC'))), @@ -97,14 +97,14 @@ static function (int $errorCode, string $message = '', string $file = '', int $l $createRelease = new CreateReleaseThroughApiCall( $makeRequests, $httpClient, - $githubToken + $githubToken, ); $bumpChangelogVersion = new BumpAndCommitChangelogVersionViaKeepAChangelog( $changelogExists, $checkoutBranch, $commit, $push, - $logger + $logger, ); $application = new Application(Versions::rootPackageName(), Versions::getVersion('laminas/automatic-releases')); @@ -120,7 +120,7 @@ static function (int $errorCode, string $message = '', string $file = '', int $l $createReleaseText, new CreateTagViaConsole(), $push, - $createRelease + $createRelease, ), new CreateMergeUpPullRequest( $variables, @@ -133,8 +133,8 @@ static function (int $errorCode, string $message = '', string $file = '', int $l new CreatePullRequestThroughApiCall( $makeRequests, $httpClient, - $githubToken - ) + $githubToken, + ), ), new SwitchDefaultBranchToNextMinor( $variables, @@ -145,16 +145,16 @@ static function (int $errorCode, string $message = '', string $file = '', int $l new SetDefaultBranchThroughApiCall( $makeRequests, $httpClient, - $githubToken + $githubToken, ), - $bumpChangelogVersion + $bumpChangelogVersion, ), new BumpChangelogForReleaseBranch( $variables, $loadEvent, $fetch, $getCandidateBranches, - $bumpChangelogVersion + $bumpChangelogVersion, ), new CreateMilestones( $loadEvent, @@ -162,8 +162,8 @@ static function (int $errorCode, string $message = '', string $file = '', int $l $makeRequests, $httpClient, $githubToken, - $logger - ) + $logger, + ), ), ]); diff --git a/composer.json b/composer.json index d8d93409..747ab81c 100644 --- a/composer.json +++ b/composer.json @@ -21,13 +21,13 @@ "symfony/console": "^5.4.12" }, "require-dev": { - "doctrine/coding-standard": "^9.0.0", + "doctrine/coding-standard": "^10.0.0", "php-standard-library/psalm-plugin": "^2.0.2", - "phpunit/phpunit": "^9.5.0", + "phpunit/phpunit": "^9.5.23", "psalm/plugin-phpunit": "^0.17.0", - "roave/infection-static-analysis-plugin": "^1.7", - "squizlabs/php_codesniffer": "^3.5.8", - "vimeo/psalm": "^4.7.2" + "roave/infection-static-analysis-plugin": "^1.22.0", + "squizlabs/php_codesniffer": "^3.7.1", + "vimeo/psalm": "^4.26.0" }, "config": { "sort-packages": true, diff --git a/composer.lock b/composer.lock index 33a8a90e..f0a30bb0 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "a7a1861c9ee388450344a33174ba8ad4", + "content-hash": "a7b2a5eeb09216929b5544228650def9", "packages": [ { "name": "azjezz/psl", @@ -148,16 +148,16 @@ }, { "name": "guzzlehttp/guzzle", - "version": "7.4.5", + "version": "7.5.0", "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", - "reference": "1dd98b0564cb3f6bd16ce683cb755f94c10fbd82" + "reference": "b50a2a1251152e43f6a37f0fa053e730a67d25ba" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/1dd98b0564cb3f6bd16ce683cb755f94c10fbd82", - "reference": "1dd98b0564cb3f6bd16ce683cb755f94c10fbd82", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/b50a2a1251152e43f6a37f0fa053e730a67d25ba", + "reference": "b50a2a1251152e43f6a37f0fa053e730a67d25ba", "shasum": "" }, "require": { @@ -172,10 +172,10 @@ "psr/http-client-implementation": "1.0" }, "require-dev": { - "bamarni/composer-bin-plugin": "^1.4.1", + "bamarni/composer-bin-plugin": "^1.8.1", "ext-curl": "*", "php-http/client-integration-tests": "^3.0", - "phpunit/phpunit": "^8.5.5 || ^9.3.5", + "phpunit/phpunit": "^8.5.29 || ^9.5.23", "psr/log": "^1.1 || ^2.0 || ^3.0" }, "suggest": { @@ -185,8 +185,12 @@ }, "type": "library", "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + }, "branch-alias": { - "dev-master": "7.4-dev" + "dev-master": "7.5-dev" } }, "autoload": { @@ -252,7 +256,7 @@ ], "support": { "issues": "https://github.com/guzzle/guzzle/issues", - "source": "https://github.com/guzzle/guzzle/tree/7.4.5" + "source": "https://github.com/guzzle/guzzle/tree/7.5.0" }, "funding": [ { @@ -268,20 +272,20 @@ "type": "tidelift" } ], - "time": "2022-06-20T22:16:13+00:00" + "time": "2022-08-28T15:39:27+00:00" }, { "name": "guzzlehttp/promises", - "version": "1.5.1", + "version": "1.5.2", "source": { "type": "git", "url": "https://github.com/guzzle/promises.git", - "reference": "fe752aedc9fd8fcca3fe7ad05d419d32998a06da" + "reference": "b94b2807d85443f9719887892882d0329d1e2598" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/promises/zipball/fe752aedc9fd8fcca3fe7ad05d419d32998a06da", - "reference": "fe752aedc9fd8fcca3fe7ad05d419d32998a06da", + "url": "https://api.github.com/repos/guzzle/promises/zipball/b94b2807d85443f9719887892882d0329d1e2598", + "reference": "b94b2807d85443f9719887892882d0329d1e2598", "shasum": "" }, "require": { @@ -336,7 +340,7 @@ ], "support": { "issues": "https://github.com/guzzle/promises/issues", - "source": "https://github.com/guzzle/promises/tree/1.5.1" + "source": "https://github.com/guzzle/promises/tree/1.5.2" }, "funding": [ { @@ -352,20 +356,20 @@ "type": "tidelift" } ], - "time": "2021-10-22T20:56:57+00:00" + "time": "2022-08-28T14:55:35+00:00" }, { "name": "guzzlehttp/psr7", - "version": "2.4.0", + "version": "2.4.1", "source": { "type": "git", "url": "https://github.com/guzzle/psr7.git", - "reference": "13388f00956b1503577598873fffb5ae994b5737" + "reference": "69568e4293f4fa993f3b0e51c9723e1e17c41379" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/13388f00956b1503577598873fffb5ae994b5737", - "reference": "13388f00956b1503577598873fffb5ae994b5737", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/69568e4293f4fa993f3b0e51c9723e1e17c41379", + "reference": "69568e4293f4fa993f3b0e51c9723e1e17c41379", "shasum": "" }, "require": { @@ -379,15 +383,19 @@ "psr/http-message-implementation": "1.0" }, "require-dev": { - "bamarni/composer-bin-plugin": "^1.4.1", + "bamarni/composer-bin-plugin": "^1.8.1", "http-interop/http-factory-tests": "^0.9", - "phpunit/phpunit": "^8.5.8 || ^9.3.10" + "phpunit/phpunit": "^8.5.29 || ^9.5.23" }, "suggest": { "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" }, "type": "library", "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + }, "branch-alias": { "dev-master": "2.4-dev" } @@ -451,7 +459,7 @@ ], "support": { "issues": "https://github.com/guzzle/psr7/issues", - "source": "https://github.com/guzzle/psr7/tree/2.4.0" + "source": "https://github.com/guzzle/psr7/tree/2.4.1" }, "funding": [ { @@ -467,7 +475,7 @@ "type": "tidelift" } ], - "time": "2022-06-20T21:43:11+00:00" + "time": "2022-08-28T14:45:39+00:00" }, { "name": "jwage/changelog-generator", @@ -3649,23 +3657,23 @@ }, { "name": "doctrine/coding-standard", - "version": "9.0.2", + "version": "10.0.0", "source": { "type": "git", "url": "https://github.com/doctrine/coding-standard.git", - "reference": "35a2452c6025cb739c3244b3348bcd1604df07d1" + "reference": "7903671d7d33c231c8921058b7c14b8f57cbacb7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/coding-standard/zipball/35a2452c6025cb739c3244b3348bcd1604df07d1", - "reference": "35a2452c6025cb739c3244b3348bcd1604df07d1", + "url": "https://api.github.com/repos/doctrine/coding-standard/zipball/7903671d7d33c231c8921058b7c14b8f57cbacb7", + "reference": "7903671d7d33c231c8921058b7c14b8f57cbacb7", "shasum": "" }, "require": { "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7", - "php": "^7.1 || ^8.0", - "slevomat/coding-standard": "^7.0.0", - "squizlabs/php_codesniffer": "^3.6.0" + "php": "^7.2 || ^8.0", + "slevomat/coding-standard": "^8.2", + "squizlabs/php_codesniffer": "^3.7" }, "type": "phpcodesniffer-standard", "notification-url": "https://packagist.org/downloads/", @@ -3698,9 +3706,9 @@ ], "support": { "issues": "https://github.com/doctrine/coding-standard/issues", - "source": "https://github.com/doctrine/coding-standard/tree/9.0.2" + "source": "https://github.com/doctrine/coding-standard/tree/10.0.0" }, - "time": "2021-04-12T15:11:14+00:00" + "time": "2022-08-26T10:53:05+00:00" }, { "name": "doctrine/instantiator", @@ -5390,16 +5398,16 @@ }, { "name": "roave/infection-static-analysis-plugin", - "version": "1.21.0", + "version": "1.22.0", "source": { "type": "git", "url": "https://github.com/Roave/infection-static-analysis-plugin.git", - "reference": "7d7587684cc5e2425d9ae52e8ab7358936373c0e" + "reference": "34a06cfacf64542b94bd9a406bbb6b4f1cc2767c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Roave/infection-static-analysis-plugin/zipball/7d7587684cc5e2425d9ae52e8ab7358936373c0e", - "reference": "7d7587684cc5e2425d9ae52e8ab7358936373c0e", + "url": "https://api.github.com/repos/Roave/infection-static-analysis-plugin/zipball/34a06cfacf64542b94bd9a406bbb6b4f1cc2767c", + "reference": "34a06cfacf64542b94bd9a406bbb6b4f1cc2767c", "shasum": "" }, "require": { @@ -5407,11 +5415,11 @@ "ocramius/package-versions": "^1.9.0 || ^2.0.0", "php": "~8.0.0|~8.1.0", "sanmai/later": "^0.1.2", - "vimeo/psalm": "^4.24.0" + "vimeo/psalm": "^4.26.0" }, "require-dev": { - "doctrine/coding-standard": "^9.0.0", - "phpunit/phpunit": "^9.5.21" + "doctrine/coding-standard": "^10.0.0", + "phpunit/phpunit": "^9.5.23" }, "bin": [ "bin/roave-infection-static-analysis-plugin" @@ -5435,9 +5443,9 @@ "description": "Static analysis on top of mutation testing - prevents escaped mutants from being invalid according to static analysis", "support": { "issues": "https://github.com/Roave/infection-static-analysis-plugin/issues", - "source": "https://github.com/Roave/infection-static-analysis-plugin/tree/1.21.0" + "source": "https://github.com/Roave/infection-static-analysis-plugin/tree/1.22.0" }, - "time": "2022-06-29T08:30:25+00:00" + "time": "2022-08-29T08:57:35+00:00" }, { "name": "sanmai/later", @@ -6419,16 +6427,16 @@ }, { "name": "sebastian/type", - "version": "3.0.0", + "version": "3.1.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/type.git", - "reference": "b233b84bc4465aff7b57cf1c4bc75c86d00d6dad" + "reference": "fb44e1cc6e557418387ad815780360057e40753e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/b233b84bc4465aff7b57cf1c4bc75c86d00d6dad", - "reference": "b233b84bc4465aff7b57cf1c4bc75c86d00d6dad", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/fb44e1cc6e557418387ad815780360057e40753e", + "reference": "fb44e1cc6e557418387ad815780360057e40753e", "shasum": "" }, "require": { @@ -6440,7 +6448,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "3.1-dev" } }, "autoload": { @@ -6463,7 +6471,7 @@ "homepage": "https://github.com/sebastianbergmann/type", "support": { "issues": "https://github.com/sebastianbergmann/type/issues", - "source": "https://github.com/sebastianbergmann/type/tree/3.0.0" + "source": "https://github.com/sebastianbergmann/type/tree/3.1.0" }, "funding": [ { @@ -6471,7 +6479,7 @@ "type": "github" } ], - "time": "2022-03-15T09:54:48+00:00" + "time": "2022-08-29T06:55:37+00:00" }, { "name": "sebastian/version", @@ -6592,37 +6600,37 @@ }, { "name": "slevomat/coding-standard", - "version": "7.2.1", + "version": "8.4.0", "source": { "type": "git", "url": "https://github.com/slevomat/coding-standard.git", - "reference": "aff06ae7a84e4534bf6f821dc982a93a5d477c90" + "reference": "02f27326be19633a1b6ba76745390bbf9a4be0b6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/aff06ae7a84e4534bf6f821dc982a93a5d477c90", - "reference": "aff06ae7a84e4534bf6f821dc982a93a5d477c90", + "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/02f27326be19633a1b6ba76745390bbf9a4be0b6", + "reference": "02f27326be19633a1b6ba76745390bbf9a4be0b6", "shasum": "" }, "require": { "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7", "php": "^7.2 || ^8.0", - "phpstan/phpdoc-parser": "^1.5.1", - "squizlabs/php_codesniffer": "^3.6.2" + "phpstan/phpdoc-parser": ">=1.7.0 <1.8.0", + "squizlabs/php_codesniffer": "^3.7.1" }, "require-dev": { - "phing/phing": "2.17.3", + "phing/phing": "2.17.4", "php-parallel-lint/php-parallel-lint": "1.3.2", - "phpstan/phpstan": "1.4.10|1.7.1", + "phpstan/phpstan": "1.4.10|1.8.2", "phpstan/phpstan-deprecation-rules": "1.0.0", "phpstan/phpstan-phpunit": "1.0.0|1.1.1", - "phpstan/phpstan-strict-rules": "1.2.3", - "phpunit/phpunit": "7.5.20|8.5.21|9.5.20" + "phpstan/phpstan-strict-rules": "1.3.0", + "phpunit/phpunit": "7.5.20|8.5.21|9.5.21" }, "type": "phpcodesniffer-standard", "extra": { "branch-alias": { - "dev-master": "7.x-dev" + "dev-master": "8.x-dev" } }, "autoload": { @@ -6637,7 +6645,7 @@ "description": "Slevomat Coding Standard for PHP_CodeSniffer complements Consistence Coding Standard by providing sniffs with additional checks.", "support": { "issues": "https://github.com/slevomat/coding-standard/issues", - "source": "https://github.com/slevomat/coding-standard/tree/7.2.1" + "source": "https://github.com/slevomat/coding-standard/tree/8.4.0" }, "funding": [ { @@ -6649,7 +6657,7 @@ "type": "tidelift" } ], - "time": "2022-05-25T10:58:12+00:00" + "time": "2022-08-09T19:03:45+00:00" }, { "name": "squizlabs/php_codesniffer", diff --git a/src/Application/Command/BumpChangelogForReleaseBranch.php b/src/Application/Command/BumpChangelogForReleaseBranch.php index c3cfaf38..7ab6f29b 100644 --- a/src/Application/Command/BumpChangelogForReleaseBranch.php +++ b/src/Application/Command/BumpChangelogForReleaseBranch.php @@ -18,26 +18,14 @@ final class BumpChangelogForReleaseBranch extends Command { - private Variables $environment; - private LoadCurrentGithubEvent $loadEvent; - private Fetch $fetch; - private GetMergeTargetCandidateBranches $getMergeTargets; - private BumpAndCommitChangelogVersion $bumpChangelogVersion; - public function __construct( - Variables $environment, - LoadCurrentGithubEvent $loadEvent, - Fetch $fetch, - GetMergeTargetCandidateBranches $getMergeTargets, - BumpAndCommitChangelogVersion $bumpChangelogVersion + private readonly Variables $environment, + private readonly LoadCurrentGithubEvent $loadEvent, + private readonly Fetch $fetch, + private readonly GetMergeTargetCandidateBranches $getMergeTargets, + private readonly BumpAndCommitChangelogVersion $bumpChangelogVersion, ) { parent::__construct('laminas:automatic-releases:bump-changelog'); - - $this->environment = $environment; - $this->loadEvent = $loadEvent; - $this->fetch = $fetch; - $this->getMergeTargets = $getMergeTargets; - $this->bumpChangelogVersion = $bumpChangelogVersion; } public function execute(InputInterface $input, OutputInterface $output): int @@ -51,7 +39,7 @@ public function execute(InputInterface $input, OutputInterface $output): int ($this->fetch)( $repositoryName->uri(), $repositoryName->uriWithTokenAuthentication($this->environment->githubToken()), - $repositoryPath + $repositoryPath, ); $mergeCandidates = ($this->getMergeTargets)($repositoryPath); @@ -65,7 +53,7 @@ public function execute(InputInterface $input, OutputInterface $output): int $repositoryPath, $releaseVersion, $releaseBranch, - $this->environment->signingSecretKey() + $this->environment->signingSecretKey(), ); return 0; diff --git a/src/Application/Command/CreateMergeUpPullRequest.php b/src/Application/Command/CreateMergeUpPullRequest.php index 358dccdb..6c34d334 100644 --- a/src/Application/Command/CreateMergeUpPullRequest.php +++ b/src/Application/Command/CreateMergeUpPullRequest.php @@ -23,35 +23,17 @@ final class CreateMergeUpPullRequest extends Command { - private Variables $variables; - private LoadCurrentGithubEvent $loadGithubEvent; - private Fetch $fetch; - private GetMergeTargetCandidateBranches $getMergeCandidates; - private GetGithubMilestone $getMilestone; - private CreateReleaseText $createReleaseText; - private Push $push; - private CreatePullRequest $createPullRequest; - public function __construct( - Variables $variables, - LoadCurrentGithubEvent $loadGithubEvent, - Fetch $fetch, - GetMergeTargetCandidateBranches $getMergeCandidates, - GetGithubMilestone $getMilestone, - CreateReleaseText $createReleaseText, - Push $push, - CreatePullRequest $createPullRequest + private readonly Variables $variables, + private readonly LoadCurrentGithubEvent $loadGithubEvent, + private readonly Fetch $fetch, + private readonly GetMergeTargetCandidateBranches $getMergeCandidates, + private readonly GetGithubMilestone $getMilestone, + private readonly CreateReleaseText $createReleaseText, + private readonly Push $push, + private readonly CreatePullRequest $createPullRequest, ) { parent::__construct('laminas:automatic-releases:create-merge-up-pull-request'); - - $this->variables = $variables; - $this->loadGithubEvent = $loadGithubEvent; - $this->fetch = $fetch; - $this->getMergeCandidates = $getMergeCandidates; - $this->getMilestone = $getMilestone; - $this->createReleaseText = $createReleaseText; - $this->push = $push; - $this->createPullRequest = $createPullRequest; } public function execute(InputInterface $input, OutputInterface $output): int @@ -65,7 +47,7 @@ public function execute(InputInterface $input, OutputInterface $output): int $this->fetch->__invoke( $repositoryName->uri(), $repositoryName->uriWithTokenAuthentication($this->variables->githubToken()), - $repositoryPath + $repositoryPath, ); $mergeCandidates = $this->getMergeCandidates->__invoke($repositoryPath); @@ -77,7 +59,7 @@ public function execute(InputInterface $input, OutputInterface $output): int if ($mergeUpTarget === null) { $output->writeln(Str\format( 'No merge-up candidate for release %s - skipping pull request creation', - $releaseVersion->fullReleaseName() + $releaseVersion->fullReleaseName(), )); return 0; @@ -90,7 +72,7 @@ public function execute(InputInterface $input, OutputInterface $output): int . '-merge-up-into-' . $mergeUpTarget->name() . '_' - . SecureRandom\string(8) // This is to ensure that a new merge-up pull request is created even if one already exists + . SecureRandom\string(8), // This is to ensure that a new merge-up pull request is created even if one already exists ); $releaseNotes = $this->createReleaseText->__invoke( @@ -98,7 +80,7 @@ public function execute(InputInterface $input, OutputInterface $output): int $event->repository(), $event->version(), $releaseBranch, - $repositoryPath + $repositoryPath, ); $this->push->__invoke($repositoryPath, $releaseBranch->name(), $mergeUpBranch->name()); @@ -107,7 +89,7 @@ public function execute(InputInterface $input, OutputInterface $output): int $mergeUpBranch, $mergeUpTarget, 'Merge release ' . $releaseVersion->fullReleaseName() . ' into ' . $mergeUpTarget->name(), - $releaseNotes->contents() + $releaseNotes->contents(), ); return 0; diff --git a/src/Application/Command/CreateMilestones.php b/src/Application/Command/CreateMilestones.php index 2e41544c..d864dcef 100644 --- a/src/Application/Command/CreateMilestones.php +++ b/src/Application/Command/CreateMilestones.php @@ -15,17 +15,11 @@ final class CreateMilestones extends Command { - private LoadCurrentGithubEvent $loadEvent; - private CreateMilestone $createMilestone; - public function __construct( - LoadCurrentGithubEvent $loadEvent, - CreateMilestone $createMilestone + private readonly LoadCurrentGithubEvent $loadEvent, + private readonly CreateMilestone $createMilestone, ) { parent::__construct('laminas:automatic-releases:create-milestones'); - - $this->loadEvent = $loadEvent; - $this->createMilestone = $createMilestone; } public function execute(InputInterface $input, OutputInterface $output): int diff --git a/src/Application/Command/ReleaseCommand.php b/src/Application/Command/ReleaseCommand.php index d66326d0..af346f5a 100644 --- a/src/Application/Command/ReleaseCommand.php +++ b/src/Application/Command/ReleaseCommand.php @@ -23,41 +23,19 @@ final class ReleaseCommand extends Command { - private Variables $environment; - private LoadCurrentGithubEvent $loadEvent; - private Fetch $fetch; - private GetMergeTargetCandidateBranches $getMergeTargets; - private GetGithubMilestone $getMilestone; - private CommitReleaseChangelog $commitChangelog; - private CreateReleaseText $createChangelogText; - private CreateTag $createTag; - private Push $push; - private CreateRelease $createRelease; - public function __construct( - Variables $environment, - LoadCurrentGithubEvent $loadEvent, - Fetch $fetch, - GetMergeTargetCandidateBranches $getMergeTargets, - GetGithubMilestone $getMilestone, - CommitReleaseChangelog $commitChangelog, - CreateReleaseText $createChangelogText, - CreateTag $createTag, - Push $push, - CreateRelease $createRelease + private readonly Variables $environment, + private readonly LoadCurrentGithubEvent $loadEvent, + private readonly Fetch $fetch, + private readonly GetMergeTargetCandidateBranches $getMergeTargets, + private readonly GetGithubMilestone $getMilestone, + private readonly CommitReleaseChangelog $commitChangelog, + private readonly CreateReleaseText $createChangelogText, + private readonly CreateTag $createTag, + private readonly Push $push, + private readonly CreateRelease $createRelease, ) { parent::__construct('laminas:automatic-releases:release'); - - $this->environment = $environment; - $this->loadEvent = $loadEvent; - $this->fetch = $fetch; - $this->getMergeTargets = $getMergeTargets; - $this->getMilestone = $getMilestone; - $this->commitChangelog = $commitChangelog; - $this->createChangelogText = $createChangelogText; - $this->createTag = $createTag; - $this->push = $push; - $this->createRelease = $createRelease; } public function execute(InputInterface $input, OutputInterface $output): int @@ -71,7 +49,7 @@ public function execute(InputInterface $input, OutputInterface $output): int ($this->fetch)( $repositoryName->uri(), $repositoryName->uriWithTokenAuthentication($this->environment->githubToken()), - $repositoryPath + $repositoryPath, ); $mergeCandidates = ($this->getMergeTargets)($repositoryPath); @@ -90,7 +68,7 @@ public function execute(InputInterface $input, OutputInterface $output): int $repositoryName, $releaseVersion, $releaseBranch, - $repositoryPath + $repositoryPath, ); ($this->commitChangelog)( @@ -98,7 +76,7 @@ public function execute(InputInterface $input, OutputInterface $output): int $repositoryPath, $releaseVersion, $releaseBranch, - $this->environment->signingSecretKey() + $this->environment->signingSecretKey(), ); $tagName = $releaseVersion->fullReleaseName(); @@ -108,7 +86,7 @@ public function execute(InputInterface $input, OutputInterface $output): int $releaseBranch, $tagName, $changelogReleaseNotes->contents(), - $this->environment->signingSecretKey() + $this->environment->signingSecretKey(), ); ($this->push)($repositoryPath, $tagName); ($this->push)($repositoryPath, $tagName, $releaseVersion->targetReleaseBranchName()->name()); diff --git a/src/Application/Command/SwitchDefaultBranchToNextMinor.php b/src/Application/Command/SwitchDefaultBranchToNextMinor.php index 13997545..8db1ce59 100644 --- a/src/Application/Command/SwitchDefaultBranchToNextMinor.php +++ b/src/Application/Command/SwitchDefaultBranchToNextMinor.php @@ -19,32 +19,16 @@ final class SwitchDefaultBranchToNextMinor extends Command { - private Variables $variables; - private LoadCurrentGithubEvent $loadGithubEvent; - private Fetch $fetch; - private GetMergeTargetCandidateBranches $getMergeCandidates; - private Push $push; - private SetDefaultBranch $switchDefaultBranch; - private BumpAndCommitChangelogVersion $bumpChangelogVersion; - public function __construct( - Variables $variables, - LoadCurrentGithubEvent $loadGithubEvent, - Fetch $fetch, - GetMergeTargetCandidateBranches $getMergeCandidates, - Push $push, - SetDefaultBranch $switchDefaultBranch, - BumpAndCommitChangelogVersion $bumpChangelogVersion + private readonly Variables $variables, + private readonly LoadCurrentGithubEvent $loadGithubEvent, + private readonly Fetch $fetch, + private readonly GetMergeTargetCandidateBranches $getMergeCandidates, + private readonly Push $push, + private readonly SetDefaultBranch $switchDefaultBranch, + private readonly BumpAndCommitChangelogVersion $bumpChangelogVersion, ) { parent::__construct('laminas:automatic-releases:switch-default-branch-to-next-minor'); - - $this->variables = $variables; - $this->loadGithubEvent = $loadGithubEvent; - $this->fetch = $fetch; - $this->getMergeCandidates = $getMergeCandidates; - $this->push = $push; - $this->switchDefaultBranch = $switchDefaultBranch; - $this->bumpChangelogVersion = $bumpChangelogVersion; } public function execute(InputInterface $input, OutputInterface $output): int @@ -58,7 +42,7 @@ public function execute(InputInterface $input, OutputInterface $output): int $this->fetch->__invoke( $repositoryName->uri(), $repositoryName->uriWithTokenAuthentication($this->variables->githubToken()), - $repositoryPath + $repositoryPath, ); $mergeCandidates = $this->getMergeCandidates->__invoke($repositoryPath); @@ -77,14 +61,14 @@ public function execute(InputInterface $input, OutputInterface $output): int $this->push->__invoke( $repositoryPath, $newestBranch->name(), - $nextDefaultBranch->name() + $nextDefaultBranch->name(), ); ($this->bumpChangelogVersion)( BumpAndCommitChangelogVersion::BUMP_MINOR, $repositoryPath, $releaseVersion, $nextDefaultBranch, - $this->variables->signingSecretKey() + $this->variables->signingSecretKey(), ); } diff --git a/src/Changelog/BumpAndCommitChangelogVersion.php b/src/Changelog/BumpAndCommitChangelogVersion.php index 02e2c291..25ada334 100644 --- a/src/Changelog/BumpAndCommitChangelogVersion.php +++ b/src/Changelog/BumpAndCommitChangelogVersion.php @@ -22,6 +22,6 @@ public function __invoke( string $repositoryDirectory, SemVerVersion $version, BranchName $sourceBranch, - SecretKeyId $keyId + SecretKeyId $keyId, ): void; } diff --git a/src/Changelog/BumpAndCommitChangelogVersionViaKeepAChangelog.php b/src/Changelog/BumpAndCommitChangelogVersionViaKeepAChangelog.php index a18a065d..338fbd9b 100644 --- a/src/Changelog/BumpAndCommitChangelogVersionViaKeepAChangelog.php +++ b/src/Changelog/BumpAndCommitChangelogVersionViaKeepAChangelog.php @@ -25,24 +25,13 @@ class BumpAndCommitChangelogVersionViaKeepAChangelog implements BumpAndCommitCha Updates the %s file to add a changelog entry for a new %s version. COMMIT; - private ChangelogExists $changelogExists; - private CheckoutBranch $checkoutBranch; - private CommitFile $commitFile; - private Push $push; - private LoggerInterface $logger; - public function __construct( - ChangelogExists $changelogExists, - CheckoutBranch $checkoutBranch, - CommitFile $commitFile, - Push $push, - LoggerInterface $logger + private readonly ChangelogExists $changelogExists, + private readonly CheckoutBranch $checkoutBranch, + private readonly CommitFile $commitFile, + private readonly Push $push, + private readonly LoggerInterface $logger, ) { - $this->changelogExists = $changelogExists; - $this->checkoutBranch = $checkoutBranch; - $this->commitFile = $commitFile; - $this->push = $push; - $this->logger = $logger; } public function __invoke( @@ -50,7 +39,7 @@ public function __invoke( string $repositoryDirectory, SemVerVersion $version, BranchName $sourceBranch, - SecretKeyId $keyId + SecretKeyId $keyId, ): void { if (! ($this->changelogExists)($sourceBranch, $repositoryDirectory)) { // No changelog @@ -76,7 +65,7 @@ public function __invoke( $sourceBranch, self::CHANGELOG_FILE, $message, - $keyId + $keyId, ); ($this->push)($repositoryDirectory, $sourceBranch->name()); @@ -85,7 +74,7 @@ public function __invoke( 'BumpAndCommitChangelogVersion: bumped %s to version %s in branch %s', self::CHANGELOG_FILE, $newVersion, - $sourceBranch->name() + $sourceBranch->name(), )); } } diff --git a/src/Changelog/ChangelogExists.php b/src/Changelog/ChangelogExists.php index b511675b..f4dd9b55 100644 --- a/src/Changelog/ChangelogExists.php +++ b/src/Changelog/ChangelogExists.php @@ -8,11 +8,9 @@ interface ChangelogExists { - /** - * @param non-empty-string $repositoryDirectory - */ + /** @param non-empty-string $repositoryDirectory */ public function __invoke( BranchName $sourceBranch, - string $repositoryDirectory + string $repositoryDirectory, ): bool; } diff --git a/src/Changelog/ChangelogExistsViaConsole.php b/src/Changelog/ChangelogExistsViaConsole.php index d3946bfe..ab8ecedc 100644 --- a/src/Changelog/ChangelogExistsViaConsole.php +++ b/src/Changelog/ChangelogExistsViaConsole.php @@ -9,12 +9,10 @@ class ChangelogExistsViaConsole implements ChangelogExists { - /** - * @param non-empty-string $repositoryDirectory - */ + /** @param non-empty-string $repositoryDirectory */ public function __invoke( BranchName $sourceBranch, - string $repositoryDirectory + string $repositoryDirectory, ): bool { try { Shell\execute('git', ['show', 'origin/' . $sourceBranch->name() . ':CHANGELOG.md'], $repositoryDirectory); diff --git a/src/Changelog/ChangelogReleaseNotes.php b/src/Changelog/ChangelogReleaseNotes.php index a216cd9d..711df2c1 100644 --- a/src/Changelog/ChangelogReleaseNotes.php +++ b/src/Changelog/ChangelogReleaseNotes.php @@ -10,21 +10,12 @@ use Psl\Str; use RuntimeException; -/** - * @psalm-immutable - */ +/** @psalm-immutable */ class ChangelogReleaseNotes { private const CONCATENATION_STRING = "\n\n-----\n\n"; - private ?ChangelogEntry $changelogEntry; - - /** @psalm-var non-empty-string */ - private string $contents; - - /** - * @psalm-param non-empty-string $changelogFile - */ + /** @psalm-param non-empty-string $changelogFile */ public static function writeChangelogFile(string $changelogFile, self $releaseNotes): void { // Nothing to do @@ -40,28 +31,23 @@ public static function writeChangelogFile(string $changelogFile, self $releaseNo $editor->update( $changelogFile, $changelogEntry, - $releaseNotes->changelogEntry + $releaseNotes->changelogEntry, ); } - /** - * @psalm-param non-empty-string $contents - */ + /** @psalm-param non-empty-string $contents */ public function __construct( - string $contents, - ?ChangelogEntry $changelogEntry = null + private string $contents, + private ChangelogEntry|null $changelogEntry = null, ) { if ($changelogEntry) { $changelogEntry = clone $changelogEntry; } - $this->contents = $contents; $this->changelogEntry = $changelogEntry; } - /** - * @psalm-return non-empty-string - */ + /** @psalm-return non-empty-string */ public function contents(): string { return $this->contents; @@ -73,7 +59,7 @@ public function merge(self $next): self if ($this->changelogEntry && $next->changelogEntry) { throw new RuntimeException( 'Aborting: Both current release notes and next contain a ChangelogEntry;' - . ' only one CreateReleaseText implementation should resolve one.' + . ' only one CreateReleaseText implementation should resolve one.', ); } diff --git a/src/Changelog/CommitReleaseChangelog.php b/src/Changelog/CommitReleaseChangelog.php index 5ad8c14b..3f12989b 100644 --- a/src/Changelog/CommitReleaseChangelog.php +++ b/src/Changelog/CommitReleaseChangelog.php @@ -10,14 +10,12 @@ interface CommitReleaseChangelog { - /** - * @psalm-param non-empty-string $repositoryDirectory - */ + /** @psalm-param non-empty-string $repositoryDirectory */ public function __invoke( ChangelogReleaseNotes $releaseNotes, string $repositoryDirectory, SemVerVersion $version, BranchName $sourceBranch, - SecretKeyId $keyId + SecretKeyId $keyId, ): void; } diff --git a/src/Changelog/CommitReleaseChangelogViaKeepAChangelog.php b/src/Changelog/CommitReleaseChangelogViaKeepAChangelog.php index 88c0c6ae..a5beb2ae 100644 --- a/src/Changelog/CommitReleaseChangelogViaKeepAChangelog.php +++ b/src/Changelog/CommitReleaseChangelogViaKeepAChangelog.php @@ -24,35 +24,22 @@ final class CommitReleaseChangelogViaKeepAChangelog implements CommitReleaseChan Updates the %s to set the release date. COMMIT; - private ChangelogExists $changelogExists; - private CheckoutBranch $checkoutBranch; - private CommitFile $commitFile; - private Push $push; - private LoggerInterface $logger; - public function __construct( - ChangelogExists $changelogExists, - CheckoutBranch $checkoutBranch, - CommitFile $commitFile, - Push $push, - LoggerInterface $logger + private readonly ChangelogExists $changelogExists, + private readonly CheckoutBranch $checkoutBranch, + private readonly CommitFile $commitFile, + private readonly Push $push, + private readonly LoggerInterface $logger, ) { - $this->changelogExists = $changelogExists; - $this->checkoutBranch = $checkoutBranch; - $this->commitFile = $commitFile; - $this->push = $push; - $this->logger = $logger; } - /** - * @psalm-param non-empty-string $repositoryDirectory - */ + /** @psalm-param non-empty-string $repositoryDirectory */ public function __invoke( ChangelogReleaseNotes $releaseNotes, string $repositoryDirectory, SemVerVersion $version, BranchName $sourceBranch, - SecretKeyId $keyId + SecretKeyId $keyId, ): void { if (! $releaseNotes->requiresUpdatingChangelogFile()) { // Nothing to commit @@ -83,7 +70,7 @@ public function __invoke( $sourceBranch, self::CHANGELOG_FILE, $message, - $keyId + $keyId, ); ($this->push)($repositoryDirectory, $sourceBranch->name()); diff --git a/src/Environment/EnvironmentVariables.php b/src/Environment/EnvironmentVariables.php index 66973280..3906a998 100644 --- a/src/Environment/EnvironmentVariables.php +++ b/src/Environment/EnvironmentVariables.php @@ -33,20 +33,6 @@ class EnvironmentVariables implements Variables 'EMERGENCY', ]; - /** @psalm-var non-empty-string */ - private string $githubToken; - private SecretKeyId $signingSecretKey; - /** @psalm-var non-empty-string */ - private string $gitAuthorName; - /** @psalm-var non-empty-string */ - private string $gitAuthorEmail; - /** @psalm-var non-empty-string */ - private string $githubEventPath; - /** @psalm-var non-empty-string */ - private string $workspacePath; - /** @psalm-var non-empty-string */ - private string $logLevel; - /** * @psalm-param non-empty-string $githubToken * @psalm-param non-empty-string $gitAuthorName @@ -56,29 +42,20 @@ class EnvironmentVariables implements Variables * @psalm-param non-empty-string $logLevel */ private function __construct( - string $githubToken, - SecretKeyId $signingSecretKey, - string $gitAuthorName, - string $gitAuthorEmail, - string $githubEventPath, - string $workspacePath, - string $logLevel + private readonly string $githubToken, + private readonly SecretKeyId $signingSecretKey, + private readonly string $gitAuthorName, + private readonly string $gitAuthorEmail, + private readonly string $githubEventPath, + private readonly string $workspacePath, + private readonly string $logLevel, ) { - $this->githubToken = $githubToken; - $this->signingSecretKey = $signingSecretKey; - $this->gitAuthorName = $gitAuthorName; - $this->gitAuthorEmail = $gitAuthorEmail; - $this->githubEventPath = $githubEventPath; - $this->workspacePath = $workspacePath; - /** @psalm-suppress ImpureFunctionCall the {@see \Psl\Iter\contains()} API is conditionally pure */ Psl\invariant( Iter\contains(self::LOG_LEVELS, $logLevel), 'LOG_LEVEL env MUST be a valid monolog/monolog log level constant name or value;' - . ' see https://github.com/Seldaek/monolog/blob/master/doc/01-usage.md#log-levels' + . ' see https://github.com/Seldaek/monolog/blob/master/doc/01-usage.md#log-levels', ); - - $this->logLevel = $logLevel; } public static function fromEnvironment(ImportGpgKeyFromString $importKey): self diff --git a/src/Git/CheckoutBranch.php b/src/Git/CheckoutBranch.php index 0aa87054..4cd6e186 100644 --- a/src/Git/CheckoutBranch.php +++ b/src/Git/CheckoutBranch.php @@ -8,11 +8,9 @@ interface CheckoutBranch { - /** - * @psalm-param non-empty-string $repositoryDirectory - */ + /** @psalm-param non-empty-string $repositoryDirectory */ public function __invoke( string $repositoryDirectory, - BranchName $branchName + BranchName $branchName, ): void; } diff --git a/src/Git/CheckoutBranchViaConsole.php b/src/Git/CheckoutBranchViaConsole.php index 178bad16..39e7a8c4 100644 --- a/src/Git/CheckoutBranchViaConsole.php +++ b/src/Git/CheckoutBranchViaConsole.php @@ -11,7 +11,7 @@ class CheckoutBranchViaConsole implements CheckoutBranch { public function __invoke( string $repositoryDirectory, - BranchName $branchName + BranchName $branchName, ): void { Shell\execute('git', ['switch', $branchName->name()], $repositoryDirectory); } diff --git a/src/Git/CommitFile.php b/src/Git/CommitFile.php index efd7232c..a9cfcb7e 100644 --- a/src/Git/CommitFile.php +++ b/src/Git/CommitFile.php @@ -19,6 +19,6 @@ public function __invoke( BranchName $sourceBranch, string $filename, string $commitMessage, - SecretKeyId $keyId + SecretKeyId $keyId, ): void; } diff --git a/src/Git/CommitFileViaConsole.php b/src/Git/CommitFileViaConsole.php index a78c1a82..708ee381 100644 --- a/src/Git/CommitFileViaConsole.php +++ b/src/Git/CommitFileViaConsole.php @@ -17,7 +17,7 @@ public function __invoke( BranchName $sourceBranch, string $filename, string $commitMessage, - SecretKeyId $keyId + SecretKeyId $keyId, ): void { $this->assertWeAreOnBranch($sourceBranch, $repositoryDirectory, $filename); @@ -32,7 +32,7 @@ public function __invoke( private function assertWeAreOnBranch( BranchName $expectedBranch, string $repositoryDirectory, - string $filename + string $filename, ): void { $output = Str\trim(Shell\execute('git', ['branch', '--show-current'], $repositoryDirectory)); @@ -40,7 +40,7 @@ private function assertWeAreOnBranch( 'CommitFile: Cannot commit file %s to branch %s, as a different branch is currently checked out (%s).', $filename, $expectedBranch->name(), - $output + $output, )); } } diff --git a/src/Git/CreateTag.php b/src/Git/CreateTag.php index 95d88453..fb6b3cc3 100644 --- a/src/Git/CreateTag.php +++ b/src/Git/CreateTag.php @@ -15,6 +15,6 @@ public function __invoke( BranchName $sourceBranch, string $tagName, string $changelog, - SecretKeyId $keyId + SecretKeyId $keyId, ): void; } diff --git a/src/Git/CreateTagViaConsole.php b/src/Git/CreateTagViaConsole.php index 73d0cf1b..33a71f1d 100644 --- a/src/Git/CreateTagViaConsole.php +++ b/src/Git/CreateTagViaConsole.php @@ -18,7 +18,7 @@ public function __invoke( BranchName $sourceBranch, string $tagName, string $changelog, - SecretKeyId $keyId + SecretKeyId $keyId, ): void { $tagFileName = Filesystem\create_temporary_file(Env\temp_dir(), 'created_tag'); diff --git a/src/Git/Fetch.php b/src/Git/Fetch.php index 404b2ffb..bfdd0467 100644 --- a/src/Git/Fetch.php +++ b/src/Git/Fetch.php @@ -12,6 +12,6 @@ interface Fetch public function __invoke( UriInterface $repositoryUri, UriInterface $uriWithCredentials, - string $repositoryRootDirectory + string $repositoryRootDirectory, ): void; } diff --git a/src/Git/FetchAndSetCurrentUserByReplacingCurrentOriginRemote.php b/src/Git/FetchAndSetCurrentUserByReplacingCurrentOriginRemote.php index 4d71cbf0..23c51514 100644 --- a/src/Git/FetchAndSetCurrentUserByReplacingCurrentOriginRemote.php +++ b/src/Git/FetchAndSetCurrentUserByReplacingCurrentOriginRemote.php @@ -12,17 +12,14 @@ final class FetchAndSetCurrentUserByReplacingCurrentOriginRemote implements Fetch { - private EnvironmentVariables $variables; - - public function __construct(EnvironmentVariables $variables) + public function __construct(private readonly EnvironmentVariables $variables) { - $this->variables = $variables; } public function __invoke( UriInterface $repositoryUri, UriInterface $uriWithCredentials, - string $repositoryRootDirectory + string $repositoryRootDirectory, ): void { Shell\execute('git', ['config', '--global', '--add', 'safe.directory', '*'], $repositoryRootDirectory); diff --git a/src/Git/GetMergeTargetCandidateBranchesFromRemoteBranches.php b/src/Git/GetMergeTargetCandidateBranchesFromRemoteBranches.php index c17e78b5..c4c10198 100644 --- a/src/Git/GetMergeTargetCandidateBranchesFromRemoteBranches.php +++ b/src/Git/GetMergeTargetCandidateBranchesFromRemoteBranches.php @@ -24,7 +24,7 @@ public function __invoke(string $repositoryRootDirectory): MergeTargetCandidateB $sanitizedBranch = Regex\replace( Str\trim($branch, "* \t\n\r\0\x0B"), '~^(?:remotes/)?origin/~', - '' + '', ); return BranchName::fromName($sanitizedBranch); diff --git a/src/Git/Push.php b/src/Git/Push.php index 569258a9..db0c7db9 100644 --- a/src/Git/Push.php +++ b/src/Git/Push.php @@ -14,6 +14,6 @@ interface Push public function __invoke( string $repositoryDirectory, string $symbol, - ?string $alias = null + string|null $alias = null, ): void; } diff --git a/src/Git/PushViaConsole.php b/src/Git/PushViaConsole.php index f25bdad7..7627275e 100644 --- a/src/Git/PushViaConsole.php +++ b/src/Git/PushViaConsole.php @@ -12,7 +12,7 @@ final class PushViaConsole implements Push public function __invoke( string $repositoryDirectory, string $symbol, - ?string $alias = null + string|null $alias = null, ): void { if ($alias === null) { Shell\execute('git', ['push', 'origin', $symbol], $repositoryDirectory); diff --git a/src/Git/Value/MergeTargetCandidateBranches.php b/src/Git/Value/MergeTargetCandidateBranches.php index 1239abdb..c8c2f610 100644 --- a/src/Git/Value/MergeTargetCandidateBranches.php +++ b/src/Git/Value/MergeTargetCandidateBranches.php @@ -13,18 +13,11 @@ final class MergeTargetCandidateBranches { /** - * @var BranchName[] branches that can be used for releases, sorted in ascending version number - * @psalm-var list - */ - private array $sortedBranches; - - /** - * @param BranchName[] $sortedBranches + * @param BranchName[] $sortedBranches branches that can be used for releases, sorted in ascending version number * @psalm-param list $sortedBranches */ - private function __construct(array $sortedBranches) + private function __construct(private readonly array $sortedBranches) { - $this->sortedBranches = $sortedBranches; } public static function fromAllBranches(BranchName ...$branches): self @@ -40,7 +33,7 @@ public static function fromAllBranches(BranchName ...$branches): self return new self($mergeTargetBranches); } - public function targetBranchFor(SemVerVersion $version): ?BranchName + public function targetBranchFor(SemVerVersion $version): BranchName|null { foreach ($this->sortedBranches as $branch) { if ($branch->isForNewerVersionThan($version)) { @@ -55,7 +48,7 @@ public function targetBranchFor(SemVerVersion $version): ?BranchName return null; } - public function branchToMergeUp(SemVerVersion $version): ?BranchName + public function branchToMergeUp(SemVerVersion $version): BranchName|null { $targetBranch = $this->targetBranchFor($version); @@ -77,7 +70,7 @@ public function branchToMergeUp(SemVerVersion $version): ?BranchName : $branch; } - public function newestReleaseBranch(): ?BranchName + public function newestReleaseBranch(): BranchName|null { return Iter\first(Vec\reverse($this->sortedBranches)); } @@ -90,7 +83,7 @@ public function newestFutureReleaseBranchAfter(SemVerVersion $version): BranchNa Vec\reverse($this->sortedBranches), static function (BranchName $branch) use ($nextMinor): bool { return $nextMinor->lessThanEqual($branch->targetMinorReleaseVersion()); - } + }, ); return Iter\first($futureReleaseBranch) ?? $nextMinor->targetReleaseBranchName(); diff --git a/src/Git/Value/SemVerVersion.php b/src/Git/Value/SemVerVersion.php index ec758905..d1032e69 100644 --- a/src/Git/Value/SemVerVersion.php +++ b/src/Git/Value/SemVerVersion.php @@ -10,15 +10,11 @@ /** @psalm-immutable */ final class SemVerVersion { - private int $major; - private int $minor; - private int $patch; - - private function __construct(int $major, int $minor, int $patch) - { - $this->major = $major; - $this->minor = $minor; - $this->patch = $patch; + private function __construct( + private readonly int $major, + private readonly int $minor, + private readonly int $patch, + ) { } /** diff --git a/src/Github/Api/GraphQL/Query/GetGithubMilestone.php b/src/Github/Api/GraphQL/Query/GetGithubMilestone.php index 2f78fb59..a61ce7d7 100644 --- a/src/Github/Api/GraphQL/Query/GetGithubMilestone.php +++ b/src/Github/Api/GraphQL/Query/GetGithubMilestone.php @@ -11,6 +11,6 @@ interface GetGithubMilestone { public function __invoke( RepositoryName $repositoryName, - int $milestoneNumber + int $milestoneNumber, ): Milestone; } diff --git a/src/Github/Api/GraphQL/Query/GetMilestoneChangelog/Response/Author.php b/src/Github/Api/GraphQL/Query/GetMilestoneChangelog/Response/Author.php index e1e96f9b..6fa0a932 100644 --- a/src/Github/Api/GraphQL/Query/GetMilestoneChangelog/Response/Author.php +++ b/src/Github/Api/GraphQL/Query/GetMilestoneChangelog/Response/Author.php @@ -10,15 +10,11 @@ final class Author { - /** @psalm-var non-empty-string */ - private string $name; - private UriInterface $url; - /** @psalm-param non-empty-string $name */ - private function __construct(string $name, UriInterface $url) - { - $this->name = $name; - $this->url = $url; + private function __construct( + private readonly string $name, + private readonly UriInterface $url, + ) { } /** @param array $payload */ diff --git a/src/Github/Api/GraphQL/Query/GetMilestoneChangelog/Response/IssueOrPullRequest.php b/src/Github/Api/GraphQL/Query/GetMilestoneChangelog/Response/IssueOrPullRequest.php index 23810f1e..f1f05dc1 100644 --- a/src/Github/Api/GraphQL/Query/GetMilestoneChangelog/Response/IssueOrPullRequest.php +++ b/src/Github/Api/GraphQL/Query/GetMilestoneChangelog/Response/IssueOrPullRequest.php @@ -12,36 +12,19 @@ /** @psalm-immutable */ final class IssueOrPullRequest { - private int $number; - /** @psalm-var non-empty-string */ - private string $title; - private Author $author; - /** - * @var array - * @psalm-var list