Skip to content

Commit f8560a4

Browse files
Try ?
1 parent 3afa0ac commit f8560a4

2 files changed

Lines changed: 11 additions & 11 deletions

File tree

src/Type/AcceptsResult.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,4 +195,9 @@ public static function lazyMaxMin(
195195
);
196196
}
197197

198+
public function negate(): self
199+
{
200+
return new self($this->result->negate(), $this->reasons);
201+
}
202+
198203
}

src/Type/IntersectionType.php

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -281,10 +281,11 @@ public function isSubTypeOf(Type $otherType): IsSuperTypeOfResult
281281
return $otherType->isSuperTypeOf($this);
282282
}
283283

284+
// TODO: implement a lazyMinMax
284285
$result = IsSuperTypeOfResult::lazyMaxMin(
285286
$this->types,
286-
static fn (Type $innerType) => $otherType->isSuperTypeOf($innerType),
287-
);
287+
static fn (Type $innerType) => $otherType->isSuperTypeOf($innerType)->negate(),
288+
)->negate();
288289

289290
if (
290291
!$result->no()
@@ -299,17 +300,11 @@ public function isSubTypeOf(Type $otherType): IsSuperTypeOfResult
299300

300301
public function isAcceptedBy(Type $acceptingType, bool $strictTypes): AcceptsResult
301302
{
303+
// TODO: implement a lazyMinMax
302304
$result = AcceptsResult::lazyMaxMin(
303305
$this->types,
304-
static fn (Type $innerType) => $acceptingType->accepts($innerType, $strictTypes),
305-
);
306-
307-
if ($result->yes()) {
308-
$isSuperType = $acceptingType->isSuperTypeOf($this);
309-
if ($isSuperType->no()) {
310-
return $isSuperType->toAcceptsResult();
311-
}
312-
}
306+
static fn (Type $innerType) => $acceptingType->accepts($innerType, $strictTypes)->negate(),
307+
)->negate();
313308

314309
if ($this->isOversizedArray()->yes()) {
315310
if (!$result->no()) {

0 commit comments

Comments
 (0)