Skip to content
PHP Ecosystem
Explore

LockFile

API reference › Foxy › Native › LockFile

final readonly classFoxy\Native\LockFile
Sourcesrc/Native/LockFile.php

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.

MethodDescriptionDefined 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
public function __construct(string $path)

Creates a native dependency lock-file store.

Parameters

ParameterTypeDescription
$pathstringLock file path.
public function exists(): bool

Returns whether the lock file exists.

Returns

bool

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.
public function write(Foxy\Native\Fingerprint $requirements, array<array-key, Foxy\Native\ResolvedPackage> $packages): void

Writes the lock file with its maps sorted by key as strings.

Parameters

ParameterTypeDescription
$requirementsFoxy\Native\FingerprintSpecifications 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.
$packagesarray<array-key, ResolvedPackage>Packages keyed by name.