Skip to content

Commit 507d88a

Browse files
phpstan-botclaude
andcommitted
Add comment explaining isSuperTypeOf guard in IntersectionType::isAcceptedBy()
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 9759075 commit 507d88a

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

src/Type/IntersectionType.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,10 @@ public function isAcceptedBy(Type $acceptingType, bool $strictTypes): AcceptsRes
304304
static fn (Type $innerType) => $acceptingType->accepts($innerType, $strictTypes),
305305
);
306306

307+
// lazyMaxMin can short-circuit to Yes when array<mixed> (inside e.g. array&callable
308+
// or array&hasOffsetValue) is accepted by a specific array type like array<int>,
309+
// because MixedType::isAcceptedBy() always returns Yes. The isSuperTypeOf check
310+
// considers the intersection holistically and catches these false positives.
307311
if ($result->yes()) {
308312
$isSuperType = $acceptingType->isSuperTypeOf($this);
309313
if ($isSuperType->no()) {

0 commit comments

Comments
 (0)