forked from phpstan/phpstan-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTypeCombinatorCache.php
More file actions
44 lines (36 loc) · 1.25 KB
/
Copy pathTypeCombinatorCache.php
File metadata and controls
44 lines (36 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php declare(strict_types = 1);
namespace PHPStan\Type;
use PHPStan\Turbo\ShadowedByTurboExtension;
/**
* Memoization seam for TypeCombinator's binary operations.
*
* This PHP implementation performs no caching at all — it delegates straight to
* TypeCombinator. The native implementation memoizes each operation on a
* structural key of its arguments; roughly 91% of the calls in a
* self-analysis run repeat an argument tuple that was already computed.
*
* The cache is scoped to a single container: memoization hands back shared Type
* instances, and Type objects carry a lazily resolved ClassReflection tied to the
* container that created them.
*
* @internal
*/
#[ShadowedByTurboExtension(turboClass: 'PHPStanTurbo\TypeCombinatorCache', implementation: __DIR__ . '/../../turbo-ext/src/TypeCombinatorCache.cpp')]
final class TypeCombinatorCache
{
public static function union(Type ...$types): Type
{
return TypeCombinator::doUnion(...$types);
}
public static function intersect(Type ...$types): Type
{
return TypeCombinator::doIntersect(...$types);
}
public static function remove(Type $fromType, Type $typeToRemove): Type
{
return TypeCombinator::doRemove($fromType, $typeToRemove);
}
public static function clearCache(): void
{
}
}