Skip to content

Commit f504554

Browse files
iluuu1994ondrejmirtes
authored andcommitted
Fix symfony input types
1 parent 3c28887 commit f504554

File tree

1 file changed

+32
-6
lines changed

1 file changed

+32
-6
lines changed

Diff for: src/Command/AnalyseCommand.php

+32-6
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,31 @@ protected function initialize(InputInterface $input, OutputInterface $output): v
5252

5353
protected function execute(InputInterface $input, OutputInterface $output): int
5454
{
55+
$paths = $input->getArgument('paths');
56+
$memoryLimit = $input->getOption('memory-limit');
57+
$autoloadFile = $input->getOption('autoload-file');
58+
$configuration = $input->getOption('configuration');
59+
$level = $input->getOption(self::OPTION_LEVEL);
60+
61+
if (
62+
!is_array($paths)
63+
|| (!is_string($memoryLimit) && $memoryLimit !== null)
64+
|| (!is_string($autoloadFile) && $autoloadFile !== null)
65+
|| (!is_string($configuration) && $configuration !== null)
66+
|| (!is_string($level) && $level !== null)
67+
) {
68+
throw new \PHPStan\ShouldNotHappenException();
69+
}
70+
5571
try {
5672
$inceptionResult = CommandHelper::begin(
5773
$input,
5874
$output,
59-
$input->getArgument('paths'),
60-
$input->getOption('memory-limit'),
61-
$input->getOption('autoload-file'),
62-
$input->getOption('configuration'),
63-
$input->getOption(self::OPTION_LEVEL)
75+
$paths,
76+
$memoryLimit,
77+
$autoloadFile,
78+
$configuration,
79+
$level
6480
);
6581
} catch (\PHPStan\Command\InceptionNotSuccessfulException $e) {
6682
return 1;
@@ -75,6 +91,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int
7591
$errorFormat = $oldErrorFormat;
7692
}
7793

94+
if (!is_string($errorFormat) && $errorFormat !== null) {
95+
throw new \PHPStan\ShouldNotHappenException();
96+
}
97+
7898
$container = $inceptionResult->getContainer();
7999
$errorFormatterServiceName = sprintf('errorFormatter.%s', $errorFormat);
80100
if (!$container->hasService($errorFormatterServiceName)) {
@@ -93,14 +113,20 @@ protected function execute(InputInterface $input, OutputInterface $output): int
93113

94114
/** @var AnalyseApplication $application */
95115
$application = $container->getByType(AnalyseApplication::class);
116+
117+
$debug = $input->getOption('debug');
118+
if (!is_bool($debug)) {
119+
throw new \PHPStan\ShouldNotHappenException();
120+
}
121+
96122
return $inceptionResult->handleReturn(
97123
$application->analyse(
98124
$inceptionResult->getFiles(),
99125
$inceptionResult->isOnlyFiles(),
100126
$inceptionResult->getConsoleStyle(),
101127
$errorFormatter,
102128
$inceptionResult->isDefaultLevelUsed(),
103-
$input->getOption('debug')
129+
$debug
104130
)
105131
);
106132
}

0 commit comments

Comments
 (0)