Repository navigation
Expand file tree
/
Copy pathArenaCache.php
More file actions
101 lines (86 loc) · 2.75 KB
/
Copy pathArenaCache.php
File metadata and controls
101 lines (86 loc) · 2.75 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php declare(strict_types = 1);
namespace PHPStan\Cache;
use PHPStan\Turbo\ShadowedByTurboExtension;
/**
* Cross-process sharing seam for a single analysis run.
*
* This PHP implementation shares nothing: create() never yields an arena,
* lookups always miss and publishes are dropped — callers fall through to
* computing values locally, which is exactly PHPStan's behavior without the
* turbo extension. The native implementation is a shared-memory arena:
* the master process creates it under a per-run name before spawning
* parallel workers, every worker maps it, and whichever process computes a
* record first publishes it for the others. The arena lives exactly as long
* as the run — the master unlinks the name once all workers have attached
* (the kernel then reclaims the memory when the last process exits, even
* after SIGKILL) and destroys it when the analysis ends.
*
* Records hold data-only value trees (null, bool, int, float, string,
* array). Values that are not representable (objects, resources) are simply
* not published. A stored null is indistinguishable from an absent entry, so
* callers must only store non-null values. hasRecord() distinguishes "the
* record was never published" (compute locally, then publish) from "the
* record exists and is authoritative" (a null entry lookup means absent).
*
* @internal
*/
#[ShadowedByTurboExtension(implementation: __DIR__ . '/../../turbo-ext/src/ArenaCache.cpp')]
final class ArenaCache
{
public static function create(string $runId): ?string
{
return null;
}
public static function attach(string $name): bool
{
return false;
}
public static function unlinkName(): void
{
}
public static function destroy(): void
{
}
public static function hasRecord(string $key): bool
{
return false;
}
public static function lookup(string $key): mixed
{
return null;
}
/**
* Publishes the value unless the key already has one - the first publish wins.
*/
public static function publish(string $key, mixed $value): void
{
}
/**
* Publishes the value in place of the one the key has - for a value just
* computed because the published one was out of date.
*/
public static function replace(string $key, mixed $value): void
{
}
public static function lookupHash(string $recordKey, string $entryKey): mixed
{
return null;
}
/**
* The entire entries map of a hash record, in the insertion order it was
* published with — for the rare consumers that must enumerate, at the
* price of materializing every entry locally.
*
* @return mixed[]|null
*/
public static function lookupHashAll(string $recordKey): ?array
{
return null;
}
/**
* @param mixed[] $entries
*/
public static function publishHash(string $recordKey, array $entries): void
{
}
}