Skip to content

Commit 244337e

Browse files
committed
Merge remote-tracking branch 'origin/1.12.x' into 2.0.x
2 parents 4bec8b2 + 254d9a5 commit 244337e

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
@@ -190,9 +190,11 @@ private function isSuperTypeOfInternal(Type $type, bool $acceptsContext): IsSupe
190190
$thisVariance = $this->variances[$i] ?? TemplateTypeVariance::createInvariant();
191191
$ancestorVariance = $ancestor->variances[$i] ?? TemplateTypeVariance::createInvariant();
192192
if (!$thisVariance->invariant()) {
193-
$results[] = $thisVariance->isValidVariance($templateType, $this->types[$i], $ancestor->types[$i]);
193+
$result = $thisVariance->isValidVariance($templateType, $this->types[$i], $ancestor->types[$i]);
194+
$results[] = new IsSuperTypeOfResult($result->result, $result->reasons);
194195
} else {
195-
$results[] = $templateType->isValidVariance($this->types[$i], $ancestor->types[$i]);
196+
$result = $templateType->isValidVariance($this->types[$i], $ancestor->types[$i]);
197+
$results[] = new IsSuperTypeOfResult($result->result, $result->reasons);
196198
}
197199

198200
$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
@@ -2,8 +2,8 @@
22

33
namespace PHPStan\Type\Generic;
44

5+
use PHPStan\Type\AcceptsResult;
56
use PHPStan\Type\CompoundType;
6-
use PHPStan\Type\IsSuperTypeOfResult;
77
use PHPStan\Type\Type;
88

99
/** @api */
@@ -21,7 +21,7 @@ public function toArgument(): TemplateType;
2121

2222
public function isArgument(): bool;
2323

24-
public function isValidVariance(Type $a, Type $b): IsSuperTypeOfResult;
24+
public function isValidVariance(Type $a, Type $b): AcceptsResult;
2525

2626
public function getVariance(): TemplateTypeVariance;
2727

src/Type/Generic/TemplateTypeTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public function toArgument(): TemplateType
9292
);
9393
}
9494

95-
public function isValidVariance(Type $a, Type $b): IsSuperTypeOfResult
95+
public function isValidVariance(Type $a, Type $b): AcceptsResult
9696
{
9797
return $this->variance->isValidVariance($this, $a, $b);
9898
}

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;
@@ -126,30 +127,30 @@ public function compose(self $other): self
126127
return $other;
127128
}
128129

129-
public function isValidVariance(TemplateType $templateType, Type $a, Type $b): IsSuperTypeOfResult
130+
public function isValidVariance(TemplateType $templateType, Type $a, Type $b): AcceptsResult
130131
{
131132
if ($b instanceof NeverType) {
132-
return IsSuperTypeOfResult::createYes();
133+
return AcceptsResult::createYes();
133134
}
134135

135136
if ($a instanceof MixedType && !$a instanceof TemplateType) {
136-
return IsSuperTypeOfResult::createYes();
137+
return AcceptsResult::createYes();
137138
}
138139

139140
if ($a instanceof BenevolentUnionType) {
140141
if (!$a->isSuperTypeOf($b)->no()) {
141-
return IsSuperTypeOfResult::createYes();
142+
return AcceptsResult::createYes();
142143
}
143144
}
144145

145146
if ($b instanceof BenevolentUnionType) {
146147
if (!$b->isSuperTypeOf($a)->no()) {
147-
return IsSuperTypeOfResult::createYes();
148+
return AcceptsResult::createYes();
148149
}
149150
}
150151

151152
if ($b instanceof MixedType && !$b instanceof TemplateType) {
152-
return IsSuperTypeOfResult::createYes();
153+
return AcceptsResult::createYes();
153154
}
154155

155156
if ($this->invariant()) {
@@ -168,19 +169,19 @@ public function isValidVariance(TemplateType $templateType, Type $a, Type $b): I
168169
}
169170
}
170171

171-
return new IsSuperTypeOfResult(TrinaryLogic::createFromBoolean($result), $reasons);
172+
return new AcceptsResult(TrinaryLogic::createFromBoolean($result), $reasons);
172173
}
173174

174175
if ($this->covariant()) {
175-
return $a->isSuperTypeOfWithReason($b);
176+
return $a->isSuperTypeOfWithReason($b)->toAcceptsResult();
176177
}
177178

178179
if ($this->contravariant()) {
179-
return $b->isSuperTypeOfWithReason($a);
180+
return $b->isSuperTypeOfWithReason($a)->toAcceptsResult();
180181
}
181182

182183
if ($this->bivariant()) {
183-
return IsSuperTypeOfResult::createYes();
184+
return AcceptsResult::createYes();
184185
}
185186

186187
throw new ShouldNotHappenException();

0 commit comments

Comments
 (0)