InstalledState
API reference › Foxy › Native › InstalledState
Reads and writes the hidden state file of an install directory: the lock entry of every package the last successful
native installation left in place, the counterpart of npm’s node_modules/.package-lock.json.
The state is a cache: a missing or malformed file reads as empty, so the installer extracts every registry package again.
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
__construct() | Creates an installed-state store for one native install directory. | InstalledState |
read() | Returns the recorded lock entries keyed by package name, in the shape of ResolvedPackage::toLock(). | InstalledState |
write() | Writes the state file as {"packages": {...}}, with the names sorted byte-wise. | InstalledState |
Method details
Section titled “Method details”__construct()
Section titled “__construct() ”public function __construct(string $path, Composer\IO\IOInterface $io)Creates an installed-state store for one native install directory.
Parameters
| Parameter | Type | Description |
|---|---|---|
$path | string | State file path. |
$io | Composer\ | Output for the verbose notice of a malformed file. |
read()
Section titled “read() ”public function read(): array<array-key, array<string, string>>Returns the recorded lock entries keyed by package name, in the shape of ResolvedPackage::toLock().
A missing file reads as empty. A file that is not valid JSON, has no packages map, or holds an entry of
another shape also reads as empty, with a verbose warning.
Keys are package names; PHP stores a numeric name such as 123 as an int key.
Returns
array<array-key, array<string, string>>
write()
Section titled “write() ”public function write(array<array-key, array<string, string>> $entries): voidWrites the state file as {"packages": {...}}, with the names sorted byte-wise.
Parameters
| Parameter | Type | Description |
|---|---|---|
$entries | array<array-key, | Lock entries keyed by package name. |