Skip to content

Commit 82e5689

Browse files
committed
phpstan fixes
1 parent 6999204 commit 82e5689

File tree

3 files changed

+17
-23
lines changed

3 files changed

+17
-23
lines changed

src/voku/PhpDocFixer/CliCommand/PhpDocFixerCommand.php

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,32 +29,25 @@ public function configure(): void
2929
->setDefinition(
3030
new InputDefinition(
3131
[
32-
new InputArgument('path', InputArgument::REQUIRED | InputArgument::IS_ARRAY, 'The path to analyse'),
32+
new InputArgument('path', InputArgument::REQUIRED, 'The path to analyse'),
3333
]
3434
)
3535
);
3636
}
3737

3838
public function execute(InputInterface $input, OutputInterface $output): int
3939
{
40-
$pathArray = $input->getArgument('path');
41-
if (!$pathArray) {
42-
// fallback
43-
$pathArray = ['.'];
44-
}
45-
$realPath = null;
46-
\assert(\is_array($pathArray));
47-
foreach ($pathArray as $pathItem) {
48-
$realPath = \realpath($pathItem);
49-
\assert(\is_string($realPath));
50-
51-
if (!$realPath || !\file_exists($realPath)) {
52-
$output->writeln('-------------------------------');
53-
$output->writeln('The path "' . $pathItem . '" does not exists.');
54-
$output->writeln('-------------------------------');
55-
56-
return 2;
57-
}
40+
$path = $input->getArgument('path');
41+
\assert(\is_string($path));
42+
$realPath = \realpath($path);
43+
\assert(\is_string($realPath));
44+
45+
if (!$realPath || !\file_exists($realPath)) {
46+
$output->writeln('-------------------------------');
47+
$output->writeln('The path "' . $path . '" does not exists.');
48+
$output->writeln('-------------------------------');
49+
50+
return 2;
5851
}
5952

6053
$xmlReader = new \voku\PhpDocFixer\ReadXmlDocs\XmlReader($realPath);
@@ -80,7 +73,7 @@ public function execute(InputInterface $input, OutputInterface $output): int
8073
}
8174
}
8275

83-
$output->writeln($realPath);
76+
$output->writeln(\count($errors) . ' ' . 'errors found');
8477

8578
foreach ($errors as $name => $typesArray) {
8679
$output->writeln('----------------');

src/voku/PhpDocFixer/ReadPhpStormStubs/PhpStormStubsReader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public function __construct(string $path)
1616
/**
1717
* @return array
1818
*
19-
* @phpstan-return array<string, array{return: string, params: array<string, string>}>
19+
* @phpstan-return array<string, array{return: string, params?: array<string, string>}>
2020
*/
2121
public function parse(): array
2222
{

src/voku/PhpDocFixer/ReadXmlDocs/XmlReader.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public function __construct(string $xml_path)
1616
/**
1717
* @return array
1818
*
19-
* @phpstan-return array<string, array{return: array<string, string>, params: array<string, array<string, string>}>
19+
* @phpstan-return array<string, array{return: string, params?: array<string, string>}>
2020
*/
2121
public function parse(): array
2222
{
@@ -58,7 +58,7 @@ public function parse(): array
5858
/**
5959
* @param \voku\helper\XmlDomParser $xmlParser
6060
*
61-
* @phpstan-return array<string, array{return: string, params: array<string, string>>
61+
* @phpstan-return array<string, array{return: string, params?: array<string, string>}>
6262
*/
6363
private function findTypes(\voku\helper\XmlDomParser $xmlParser): array
6464
{
@@ -94,6 +94,7 @@ private function findTypes(\voku\helper\XmlDomParser $xmlParser): array
9494
$data[$name]['params'][$paramName][$paramTypeText] = \ltrim($paramTypeText, '\\');
9595
}
9696

97+
/** @phpstan-ignore-next-line TODO? */
9798
$data[$name]['params'][$paramName] = \implode('|', $data[$name]['params'][$paramName] ?? []);
9899
}
99100
}

0 commit comments

Comments
 (0)