Skip to content

Commit 752f83f

Browse files
authored
Faster UnionType->isNull() (#6232)
1 parent 380b5ba commit 752f83f

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎src/Type/UnionType.php‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ class UnionType implements CompoundType
8383
/** @var list<Type>|null */
8484
private ?array $finiteTypes = null;
8585

86+
private ?TrinaryLogic $isNull = null;
87+
8688
/**
8789
* @api
8890
* @param list<Type> $types
@@ -1163,7 +1165,7 @@ public function isSmallerThanOrEqual(Type $otherType, PhpVersion $phpVersion): T
11631165

11641166
public function isNull(): TrinaryLogic
11651167
{
1166-
return $this->notBenevolentUnionResults(static fn (Type $type): TrinaryLogic => $type->isNull());
1168+
return $this->isNull ??= $this->notBenevolentUnionResults(static fn (Type $type): TrinaryLogic => $type->isNull());
11671169
}
11681170

11691171
public function isConstantValue(): TrinaryLogic

0 commit comments

Comments
 (0)