Skip to content

Commit 0d109aa

Browse files
authored
Faster UnionType->isCallable() (#6233)
1 parent 752f83f commit 0d109aa

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
@@ -85,6 +85,8 @@ class UnionType implements CompoundType
8585

8686
private ?TrinaryLogic $isNull = null;
8787

88+
private ?TrinaryLogic $isCallable = null;
89+
8890
/**
8991
* @api
9092
* @param list<Type> $types
@@ -1126,7 +1128,7 @@ public function getEnumCaseObject(): ?EnumCaseObjectType
11261128

11271129
public function isCallable(): TrinaryLogic
11281130
{
1129-
return $this->unionResults(static fn (Type $type): TrinaryLogic => $type->isCallable());
1131+
return $this->isCallable ??= $this->unionResults(static fn (Type $type): TrinaryLogic => $type->isCallable());
11301132
}
11311133

11321134
public function getCallableParametersAcceptors(ClassMemberAccessAnswerer $scope): array

0 commit comments

Comments
 (0)