Skip to content

Commit f4877ec

Browse files
authored
Update types for Psalm (#1036)
1 parent d0157a9 commit f4877ec

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

.dev-tools/psalm.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@
2222
<InternalMethod errorLevel='suppress' />
2323
<MissingConstructor errorLevel='suppress' />
2424
<MissingOverrideAttribute errorLevel='suppress' />
25-
<MixedArgument errorLevel='suppress' />
26-
<MixedArrayAccess errorLevel='suppress' />
27-
<MixedAssignment errorLevel='suppress' />
28-
<MixedOperand errorLevel='suppress' />
29-
<MixedReturnStatement errorLevel='suppress' />
3025
<PossiblyFalseOperand errorLevel='suppress' />
3126
<PossiblyNullArgument errorLevel='suppress' />
3227
<PossiblyNullArrayAccess errorLevel='suppress' />

.php-cs-fixer.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
$rules[PhpdocTagNoNamedArgumentsFixer::name()] = ['directory' => __DIR__ . '/src/'];
6262

6363
$rules[PhpdocOnlyAllowedAnnotationsFixer::name()]['elements'][] = 'phpstan-type';
64+
$rules[PhpdocOnlyAllowedAnnotationsFixer::name()]['elements'][] = 'psalm-var';
6465

6566
foreach (new PhpCsFixerCustomFixersDev\Fixers() as $fixer) {
6667
$rules[$fixer->getName()] = true;

src/Fixer/MultilineCommentOpeningClosingAloneFixer.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,26 @@ private function fixOpening(Tokens $tokens, int $index): void
7474

7575
Preg::match('#\\R(\\h*)#', $tokens[$index]->getContent(), $matches);
7676

77+
// @phpstan-ignore function.alreadyNarrowedType
78+
\assert(\is_string($matches[1]));
79+
7780
$indent = $matches[1] . '*';
7881

7982
Preg::match('#^(?<opening>/\\*+)(?<before_newline>.*?)(?<newline>\\R)(?<after_newline>.*)$#s', $tokens[$index]->getContent(), $matches);
8083
if ($matches === []) {
8184
return;
8285
}
8386

87+
/** @psalm-var string $opening */
8488
$opening = $matches['opening'];
89+
90+
/** @psalm-var string $beforeNewline */
8591
$beforeNewline = $matches['before_newline'];
92+
93+
/** @psalm-var string $newline */
8694
$newline = $matches['newline'];
95+
96+
/** @psalm-var string $afterNewline */
8797
$afterNewline = $matches['after_newline'];
8898

8999
if ($beforeNewline[0] !== ' ') {
@@ -111,6 +121,7 @@ private function fixClosing(Tokens $tokens, int $index): void
111121

112122
Preg::match('#\\R(\\h*)#', $tokens[$index]->getContent(), $matches);
113123

124+
/** @psalm-var string $indent */
114125
$indent = $matches[1];
115126

116127
$newContent = Preg::replace('#(\\R)(.+?)\\h*(\\*+/)$#', \sprintf('$1$2$1%s$3', $indent), $tokens[$index]->getContent());

src/Fixer/PhpdocNoSuperfluousParamFixer.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@ private function getParamName(string $annotation): ?string
143143
return null;
144144
}
145145

146+
// @phpstan-ignore function.alreadyNarrowedType
147+
\assert(\is_string($matches[1]));
148+
146149
return $matches[1];
147150
}
148151
}

0 commit comments

Comments
 (0)