Skip to content

Commit 6e0fe17

Browse files
committed
chore: phpstan
1 parent 954a78e commit 6e0fe17

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/Console/CodemapCommand.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Exception;
88
use InvalidArgumentException;
99
use Kauffinger\Codemap\Config\CodemapConfig;
10+
use Kauffinger\Codemap\Dto\CodemapFileDto;
1011
use Kauffinger\Codemap\Enum\PhpVersion;
1112
use Kauffinger\Codemap\Formatter\TextCodemapFormatter;
1213
use Kauffinger\Codemap\Generator\CodemapGenerator;
@@ -59,12 +60,17 @@ protected function handle(): int
5960

6061
$phpVersion = $this->getPhpVersion($config);
6162

63+
/* @phpstan-ignore-next-line */
6264
$codemapResults = $this->generateCodemap($scanPaths, $phpVersion);
6365

6466
$formatter = new TextCodemapFormatter;
6567
$formattedOutput = $formatter->format($codemapResults);
6668

6769
$outputFile = $this->option('output');
70+
if (! is_string($outputFile)) {
71+
throw new RuntimeException('Invalid output file path.');
72+
}
73+
6874
$this->writeOutput($formattedOutput, $outputFile);
6975

7076
return Command::SUCCESS;
@@ -133,6 +139,10 @@ private function getPhpVersion(CodemapConfig $config): ?PhpVersion
133139
{
134140
$phpVersionString = $this->option('php-version');
135141
if ($phpVersionString) {
142+
if (! is_string($phpVersionString) && ! is_int($phpVersionString)) {
143+
throw new InvalidArgumentException('Invalid PHP version: '.$phpVersionString);
144+
}
145+
136146
$phpVersion = PhpVersion::tryFrom($phpVersionString);
137147
if (! $phpVersion instanceof PhpVersion) {
138148
throw new InvalidArgumentException('Invalid PHP version: '.$phpVersionString);
@@ -144,6 +154,10 @@ private function getPhpVersion(CodemapConfig $config): ?PhpVersion
144154
return $config->getConfiguredPhpVersion();
145155
}
146156

157+
/**
158+
* @param string[] $scanPaths
159+
* @return array<string, CodemapFileDto>
160+
*/
147161
private function generateCodemap(array $scanPaths, ?PhpVersion $phpVersion): array
148162
{
149163
$codemapGenerator = new CodemapGenerator;

0 commit comments

Comments
 (0)