LockFile
API reference › Foxy › Native › LockFile
Reads and writes foxy.lock: the requirements fingerprint and the packages installed by the native manager.
The fingerprint maps each source ('' for the root manifest, the local package name otherwise) to its mandatory
dependencies and its optionalDependencies, plus the version of a local package, so moving a requirement
between the two kinds or changing a local version makes the lock stale.
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
__construct() | Creates a native dependency lock-file store. | LockFile |
exists() | Returns whether the lock file exists. | LockFile |
read() | Returns the requirements fingerprint and the locked packages. | LockFile |
write() | Writes the lock file with its maps sorted by key as strings. | LockFile |
Method details
Section titled “Method details”__construct()
Section titled “__construct() ”public function __construct(string $path)Creates a native dependency lock-file store.
Parameters
| Parameter | Type | Description |
|---|---|---|
$path | string | Lock file path. |
exists()
Section titled “exists() ”public function exists(): boolReturns whether the lock file exists.
Returns
bool
read()
Section titled “read() ”public function read(): array{requirements: Foxy\Native\Fingerprint, packages: array<array-key, Foxy\Native\ResolvedPackage>}Returns the requirements fingerprint and the locked packages.
Keys are package names; PHP stores a numeric name such as 123 as an int key.
Returns
array{requirements: Foxy\Native\Fingerprint, packages: array<array-key, ResolvedPackage>}
Throws
Foxy\Exception\RuntimeException: if the file is not valid JSON, does not have the lock file shape, or keys a requirement or a package by an invalid package name.
write()
Section titled “write() ”public function write(Foxy\Native\Fingerprint $requirements, array<array-key, Foxy\Native\ResolvedPackage> $packages): voidWrites the lock file with its maps sorted by key as strings.
Parameters
| Parameter | Type | Description |
|---|---|---|
$requirements | Foxy\ | Specifications keyed by source ('' for the root manifest, the local package name otherwise), then by kind, then by package name; a local source also carries its version, written first. |
$packages | array<array-key, ResolvedPackage> | Packages keyed by name. |