Skip to content

Commit 8d1d0bb

Browse files
committed
Enable psalm for phpcs.php
1 parent 816976f commit 8d1d0bb

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

psalm.xml

+3
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,7 @@
77
xmlns="https://getpsalm.org/schema/config"
88
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
99
>
10+
<projectFiles>
11+
<file name="src/phpcs.php"/>
12+
</projectFiles>
1013
</psalm>

src/phpcs.php

+7-5
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ private function createHelpParser(): OutputInterface
205205
/** @var array<string,string> */
206206
private $descriptions = [];
207207

208-
/** @var array<string,array{description:string, short?: bool, paramName?: string|null}> */
208+
/** @var array<string,array{description:string, short?: bool, paramName?: string|null, keyValue?: bool}> */
209209
private $options = [];
210210

211211
/** @var array<string,string> */
@@ -279,7 +279,8 @@ private function describe(ConsoleApplicationBuilderInterface $application): void
279279
$definition->withShortcutOnly();
280280
}
281281

282-
if ($config['paramName'] ?? null) {
282+
if (($config['paramName'] ?? null) !== null) {
283+
/** @psalm-suppress PossiblyUndefinedArrayOffset */
283284
$definition->withRequiredValue($config['paramName']);
284285
}
285286

@@ -352,7 +353,6 @@ private function parseShortOptionDescriptions(string $help): void
352353
}
353354

354355
if (null !== $currentName) {
355-
assert(is_string($currentName));
356356
$this->options[$currentName]['short'] = true;
357357
$this->options[$currentName]['description'] = $currentDescription;
358358
}
@@ -362,7 +362,6 @@ private function parseShortOptionDescriptions(string $help): void
362362
}
363363

364364
if ($currentName !== null) {
365-
assert(is_string($currentName));
366365
$this->options[$currentName]['short'] = true;
367366
$this->options[$currentName]['description'] = $currentDescription;
368367
}
@@ -376,8 +375,11 @@ private function parseOptionDescriptions(string $help): void
376375

377376
foreach ($lines as $line) {
378377
preg_match('#^\s+(--[a-z-]*)?\s+(.*)$#', $line, $matches);
378+
if ($matches === []) {
379+
continue;
380+
}
379381

380-
if ($matches[1] === '' || $matches[1] === null) {
382+
if ($matches[1] === '') {
381383
$currentDescription .= ' ' . trim($matches[2]);
382384
continue;
383385
}

0 commit comments

Comments
 (0)