Skip to content

Commit 254d9a5

Browse files
committed
Fix BC break
1 parent 8e9a34c commit 254d9a5

File tree

4 files changed

+18
-15
lines changed

4 files changed

+18
-15
lines changed

src/Type/Generic/GenericObjectType.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,11 @@ private function isSuperTypeOfInternal(Type $type, bool $acceptsContext): IsSupe
198198
$thisVariance = $this->variances[$i] ?? TemplateTypeVariance::createInvariant();
199199
$ancestorVariance = $ancestor->variances[$i] ?? TemplateTypeVariance::createInvariant();
200200
if (!$thisVariance->invariant()) {
201-
$results[] = $thisVariance->isValidVarianceWithReason($templateType, $this->types[$i], $ancestor->types[$i]);
201+
$result = $thisVariance->isValidVarianceWithReason($templateType, $this->types[$i], $ancestor->types[$i]);
202+
$results[] = new IsSuperTypeOfResult($result->result, $result->reasons);
202203
} else {
203-
$results[] = $templateType->isValidVarianceWithReason($this->types[$i], $ancestor->types[$i]);
204+
$result = $templateType->isValidVarianceWithReason($this->types[$i], $ancestor->types[$i]);
205+
$results[] = new IsSuperTypeOfResult($result->result, $result->reasons);
204206
}
205207

206208
$results[] = IsSuperTypeOfResult::createFromBoolean($thisVariance->validPosition($ancestorVariance));

src/Type/Generic/TemplateType.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
namespace PHPStan\Type\Generic;
44

55
use PHPStan\TrinaryLogic;
6+
use PHPStan\Type\AcceptsResult;
67
use PHPStan\Type\CompoundType;
7-
use PHPStan\Type\IsSuperTypeOfResult;
88
use PHPStan\Type\Type;
99

1010
/** @api */
@@ -24,7 +24,7 @@ public function isArgument(): bool;
2424

2525
public function isValidVariance(Type $a, Type $b): TrinaryLogic;
2626

27-
public function isValidVarianceWithReason(Type $a, Type $b): IsSuperTypeOfResult;
27+
public function isValidVarianceWithReason(Type $a, Type $b): AcceptsResult;
2828

2929
public function getVariance(): TemplateTypeVariance;
3030

src/Type/Generic/TemplateTypeTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public function isValidVariance(Type $a, Type $b): TrinaryLogic
9999
return $this->isValidVarianceWithReason($a, $b)->result;
100100
}
101101

102-
public function isValidVarianceWithReason(Type $a, Type $b): IsSuperTypeOfResult
102+
public function isValidVarianceWithReason(Type $a, Type $b): AcceptsResult
103103
{
104104
return $this->variance->isValidVarianceWithReason($this, $a, $b);
105105
}

src/Type/Generic/TemplateTypeVariance.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use PHPStan\PhpDocParser\Ast\Type\GenericTypeNode;
66
use PHPStan\ShouldNotHappenException;
77
use PHPStan\TrinaryLogic;
8+
use PHPStan\Type\AcceptsResult;
89
use PHPStan\Type\BenevolentUnionType;
910
use PHPStan\Type\IsSuperTypeOfResult;
1011
use PHPStan\Type\MixedType;
@@ -134,30 +135,30 @@ public function isValidVariance(Type $a, Type $b): TrinaryLogic
134135
return $this->isValidVarianceWithReason(null, $a, $b)->result;
135136
}
136137

137-
public function isValidVarianceWithReason(?TemplateType $templateType, Type $a, Type $b): IsSuperTypeOfResult
138+
public function isValidVarianceWithReason(?TemplateType $templateType, Type $a, Type $b): AcceptsResult
138139
{
139140
if ($b instanceof NeverType) {
140-
return IsSuperTypeOfResult::createYes();
141+
return AcceptsResult::createYes();
141142
}
142143

143144
if ($a instanceof MixedType && !$a instanceof TemplateType) {
144-
return IsSuperTypeOfResult::createYes();
145+
return AcceptsResult::createYes();
145146
}
146147

147148
if ($a instanceof BenevolentUnionType) {
148149
if (!$a->isSuperTypeOf($b)->no()) {
149-
return IsSuperTypeOfResult::createYes();
150+
return AcceptsResult::createYes();
150151
}
151152
}
152153

153154
if ($b instanceof BenevolentUnionType) {
154155
if (!$b->isSuperTypeOf($a)->no()) {
155-
return IsSuperTypeOfResult::createYes();
156+
return AcceptsResult::createYes();
156157
}
157158
}
158159

159160
if ($b instanceof MixedType && !$b instanceof TemplateType) {
160-
return IsSuperTypeOfResult::createYes();
161+
return AcceptsResult::createYes();
161162
}
162163

163164
if ($this->invariant()) {
@@ -177,19 +178,19 @@ public function isValidVarianceWithReason(?TemplateType $templateType, Type $a,
177178
}
178179
}
179180

180-
return new IsSuperTypeOfResult(TrinaryLogic::createFromBoolean($result), $reasons);
181+
return new AcceptsResult(TrinaryLogic::createFromBoolean($result), $reasons);
181182
}
182183

183184
if ($this->covariant()) {
184-
return $a->isSuperTypeOfWithReason($b);
185+
return $a->isSuperTypeOfWithReason($b)->toAcceptsResult();
185186
}
186187

187188
if ($this->contravariant()) {
188-
return $b->isSuperTypeOfWithReason($a);
189+
return $b->isSuperTypeOfWithReason($a)->toAcceptsResult();
189190
}
190191

191192
if ($this->bivariant()) {
192-
return IsSuperTypeOfResult::createYes();
193+
return AcceptsResult::createYes();
193194
}
194195

195196
throw new ShouldNotHappenException();

0 commit comments

Comments
 (0)