From 4b47beff9acdd59011d5f6a3a4c3820d1abccb80 Mon Sep 17 00:00:00 2001 From: core23 Date: Sat, 8 Feb 2025 22:38:06 +0100 Subject: [PATCH] Fix phpstan findings --- src/Application.php | 2 +- src/Changelog/Formatter/PrefixGroupFormatter.php | 2 +- src/VersionControl/Git.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Application.php b/src/Application.php index 80b0b23..54f7c5d 100644 --- a/src/Application.php +++ b/src/Application.php @@ -30,7 +30,7 @@ public function __construct() $this->add(new ChangesCommand()); } - public function add(Command $command): ?Command + public function add(Command $command): Command { $command = parent::add($command); diff --git a/src/Changelog/Formatter/PrefixGroupFormatter.php b/src/Changelog/Formatter/PrefixGroupFormatter.php index 992c2b5..771fd3a 100644 --- a/src/Changelog/Formatter/PrefixGroupFormatter.php +++ b/src/Changelog/Formatter/PrefixGroupFormatter.php @@ -161,7 +161,7 @@ private function parseLines(array $lines, array $groupedLines): array preg_match('/^([0-9A-f]+) (?:\[(.*)\] )?(.*)/', $line, $matches, PREG_UNMATCHED_AS_NULL); $type = strtoupper($matches[2] ?? $this->defaultGroup); - $line = \sprintf('- [%s] %s', $matches[1], $matches[3]); + $line = \sprintf('- [%s] %s', $matches[1] ?? '', $matches[3] ?? ''); $groupedLines[$type][] = $line; } diff --git a/src/VersionControl/Git.php b/src/VersionControl/Git.php index 6756d37..08e9cb4 100644 --- a/src/VersionControl/Git.php +++ b/src/VersionControl/Git.php @@ -43,7 +43,7 @@ public function getModifiedFilesSince(string $tag): array { $files = []; - $lines = array_filter($this->executeGitCommand(\sprintf('diff --name-status %s..HEAD', $tag))); + $lines = array_filter($this->executeGitCommand(\sprintf('diff --name-status %s..HEAD', $tag)), static function (string $line) { return '' !== $line; }); foreach ($lines as $line) { [$state, $file] = explode("\t", (string) $line);