diff --git a/infection.json.dist b/infection.json.dist index 80d45787..3bafc36e 100644 --- a/infection.json.dist +++ b/infection.json.dist @@ -12,6 +12,6 @@ "mutators": { "@default": true }, - "minMsi": 95.4, + "minMsi": 98, "minCoveredMsi": 100 } diff --git a/src/Changelog/ChangelogReleaseNotes.php b/src/Changelog/ChangelogReleaseNotes.php index 711df2c1..9c188d03 100644 --- a/src/Changelog/ChangelogReleaseNotes.php +++ b/src/Changelog/ChangelogReleaseNotes.php @@ -58,8 +58,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.', + 'Aborting: Both current release notes and next contain a ChangelogEntry; only one CreateReleaseText implementation should resolve one.', ); } diff --git a/src/Git/Value/MergeTargetCandidateBranches.php b/src/Git/Value/MergeTargetCandidateBranches.php index 1df65e22..cec01cd0 100644 --- a/src/Git/Value/MergeTargetCandidateBranches.php +++ b/src/Git/Value/MergeTargetCandidateBranches.php @@ -26,9 +26,7 @@ public static function fromAllBranches(BranchName ...$branches): self return $branch->isReleaseBranch(); }); - $mergeTargetBranches = Vec\sort($mergeTargetBranches, static function (BranchName $a, BranchName $b): int { - return $a->majorAndMinor() <=> $b->majorAndMinor(); - }); + $mergeTargetBranches = Vec\sort($mergeTargetBranches, self::branchOrder(...)); return new self($mergeTargetBranches); } @@ -98,4 +96,10 @@ public function contains(BranchName $needle): bool static fn (BranchName $branch): bool => $needle->equals($branch) ); } + + /** @return -1|0|1 */ + private static function branchOrder(BranchName $a, BranchName $b): int + { + return $a->majorAndMinor() <=> $b->majorAndMinor(); + } } diff --git a/src/Github/CreateReleaseTextViaKeepAChangelog.php b/src/Github/CreateReleaseTextViaKeepAChangelog.php index d19ce5e9..a34380f8 100644 --- a/src/Github/CreateReleaseTextViaKeepAChangelog.php +++ b/src/Github/CreateReleaseTextViaKeepAChangelog.php @@ -130,17 +130,20 @@ private function updateReleaseDate(string $changelog, string $version): string */ private function removeDefaultContents(string $changelog): string { - $contents = Iter\reduce( + return Type\non_empty_string()->assert(Iter\reduce( self::DEFAULT_SECTIONS, - static fn (string $changelog, string $section): string => Regex\replace( - $changelog, - "/\n\#{3} " . $section . "\n\n- Nothing.\n/s", - '', - ), + self::removeEmptyDefaultChangelogSection(...), $changelog, - ); + )); + } - return Type\non_empty_string()->assert($contents); + private static function removeEmptyDefaultChangelogSection(string $changelog, string $section): string + { + return Regex\replace( + $changelog, + "/\n\#{3} " . $section . "\n\n- Nothing.\n/s", + '', + ); } /** diff --git a/src/Monolog/ConvertLogContextHttpRequestsIntoStrings.php b/src/Monolog/ConvertLogContextHttpRequestsIntoStrings.php index 2848504d..329d307f 100644 --- a/src/Monolog/ConvertLogContextHttpRequestsIntoStrings.php +++ b/src/Monolog/ConvertLogContextHttpRequestsIntoStrings.php @@ -20,20 +20,23 @@ public function __invoke(LogRecord $record): LogRecord $record->channel, $record->level, $record->message, - array_map(static function ($item): mixed { - if (! $item instanceof RequestInterface) { - return $item; - } - - return $item->getMethod() - . ' ' - . $item - ->getUri() - ->withUserInfo('') - ->__toString(); - }, $record->context), + array_map(self::contextItemToMessage(...), $record->context), $record->extra, $record->formatted, ); } + + private static function contextItemToMessage(mixed $item): mixed + { + if (! $item instanceof RequestInterface) { + return $item; + } + + return $item->getMethod() + . ' ' + . $item + ->getUri() + ->withUserInfo('') + ->__toString(); + } } diff --git a/src/Monolog/ConvertLogContextHttpResponsesIntoStrings.php b/src/Monolog/ConvertLogContextHttpResponsesIntoStrings.php index 77168be9..9987a16e 100644 --- a/src/Monolog/ConvertLogContextHttpResponsesIntoStrings.php +++ b/src/Monolog/ConvertLogContextHttpResponsesIntoStrings.php @@ -20,20 +20,23 @@ public function __invoke(LogRecord $record): LogRecord $record->channel, $record->level, $record->message, - array_map(static function ($item): mixed { - if (! $item instanceof ResponseInterface) { - return $item; - } - - return $item->getStatusCode() - . ' "' - . $item - ->getBody() - ->__toString() - . '"'; - }, $record->context), + array_map(self::contextItemToMessage(...), $record->context), $record->extra, $record->formatted, ); } + + private static function contextItemToMessage(mixed $item): mixed + { + if (! $item instanceof ResponseInterface) { + return $item; + } + + return $item->getStatusCode() + . ' "' + . $item + ->getBody() + ->__toString() + . '"'; + } }