Skip to content

Commit f676244

Browse files
Use union types
1 parent cc4bea0 commit f676244

File tree

2 files changed

+4
-22
lines changed

2 files changed

+4
-22
lines changed

.psalm/baseline.xml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,7 @@
203203
<PossiblyUndefinedMethod occurrences="1">
204204
<code>toString</code>
205205
</PossiblyUndefinedMethod>
206-
<RedundantConditionGivenDocblockType occurrences="13">
207-
<code>$node instanceof Function_</code>
208-
<code>$node instanceof Function_</code>
209-
<code>$type instanceof ComplexType</code>
206+
<RedundantConditionGivenDocblockType occurrences="10">
210207
<code>assert($node-&gt;namespacedName instanceof Name)</code>
211208
<code>assert($node-&gt;namespacedName instanceof Name)</code>
212209
<code>assert($node-&gt;namespacedName instanceof Name)</code>

src/StaticAnalysis/CodeUnitFindingVisitor.php

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,8 @@ public function functions(): array
106106
return $this->functions;
107107
}
108108

109-
/**
110-
* @psalm-param ClassMethod|Function_ $node
111-
*/
112-
private function cyclomaticComplexity(Node $node): int
109+
private function cyclomaticComplexity(ClassMethod|Function_ $node): int
113110
{
114-
assert($node instanceof ClassMethod || $node instanceof Function_);
115-
116111
$nodes = $node->getStmts();
117112

118113
if ($nodes === null) {
@@ -131,13 +126,8 @@ private function cyclomaticComplexity(Node $node): int
131126
return $cyclomaticComplexityCalculatingVisitor->cyclomaticComplexity();
132127
}
133128

134-
/**
135-
* @psalm-param ClassMethod|Function_ $node
136-
*/
137-
private function signature(Node $node): string
129+
private function signature(ClassMethod|Function_ $node): string
138130
{
139-
assert($node instanceof ClassMethod || $node instanceof Function_);
140-
141131
$signature = ($node->returnsByRef() ? '&' : '') . $node->name->toString() . '(';
142132
$parameters = [];
143133

@@ -168,13 +158,8 @@ private function signature(Node $node): string
168158
return $signature;
169159
}
170160

171-
/**
172-
* @psalm-param Identifier|Name|ComplexType $type
173-
*/
174-
private function type(Node $type): string
161+
private function type(Identifier|Name|ComplexType $type): string
175162
{
176-
assert($type instanceof Identifier || $type instanceof Name || $type instanceof ComplexType);
177-
178163
if ($type instanceof NullableType) {
179164
return '?' . $type->type;
180165
}

0 commit comments

Comments
 (0)