Skip to content

Commit 3e03e9d

Browse files
committed
Use NonAcceptingNeverType in more places
1 parent d44ae55 commit 3e03e9d

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

src/Analyser/MutatingScope.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
use PHPStan\Type\IntersectionType;
9797
use PHPStan\Type\MixedType;
9898
use PHPStan\Type\NeverType;
99+
use PHPStan\Type\NonAcceptingNeverType;
99100
use PHPStan\Type\NonexistentParentClassType;
100101
use PHPStan\Type\NullType;
101102
use PHPStan\Type\ObjectShapeType;
@@ -676,7 +677,7 @@ private function getNodeKey(Expr $node): string
676677
private function resolveType(string $exprString, Expr $node): Type
677678
{
678679
if ($node instanceof Expr\Exit_ || $node instanceof Expr\Throw_) {
679-
return new NeverType(true);
680+
return new NonAcceptingNeverType();
680681
}
681682

682683
if (!$node instanceof Variable && $this->hasExpressionType($node)->yes()) {
@@ -1281,13 +1282,13 @@ private function resolveType(string $exprString, Expr $node): Type
12811282

12821283
if (count($returnTypes) === 0) {
12831284
if (count($closureExecutionEnds) > 0 && !$hasNull) {
1284-
$returnType = new NeverType(true);
1285+
$returnType = new NonAcceptingNeverType();
12851286
} else {
12861287
$returnType = new VoidType();
12871288
}
12881289
} else {
12891290
if (count($closureExecutionEnds) > 0) {
1290-
$returnTypes[] = new NeverType(true);
1291+
$returnTypes[] = new NonAcceptingNeverType();
12911292
}
12921293
if ($hasNull) {
12931294
$returnTypes[] = new NullType();

tests/PHPStan/Analyser/data/closure-return-type.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,12 @@ public function doBaz(): void
111111
$f = function() {
112112
$this->returnNever();
113113
};
114-
assertType('*NEVER*', $f());
114+
assertType('never', $f());
115115

116116
$f = function(): void {
117117
$this->returnNever();
118118
};
119-
assertType('*NEVER*', $f());
119+
assertType('never', $f());
120120

121121
$f = function() {
122122
if (rand(0, 1)) {
@@ -134,7 +134,7 @@ public function doBaz(): void
134134

135135
$this->returnNever();
136136
};
137-
assertType('*NEVER*', $f([]));
137+
assertType('never', $f([]));
138138

139139
$f = function(array $a) {
140140
foreach ($a as $v) {
@@ -148,12 +148,12 @@ public function doBaz(): void
148148
$this->returnNever();
149149
}
150150
};
151-
assertType('*NEVER*', $f());
151+
assertType('never', $f());
152152

153153
$f = function (): \stdClass {
154154
throw new \Exception();
155155
};
156-
assertType('*NEVER*', $f());
156+
assertType('never', $f());
157157
}
158158

159159
}

tests/PHPStan/Analyser/data/throw-expr.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public function doFoo(bool $b): void
1515

1616
public function doBar(): void
1717
{
18-
assertType('*NEVER*', throw new \Exception());
18+
assertType('never', throw new \Exception());
1919
}
2020

2121
}

0 commit comments

Comments
 (0)