function Locker::lockPackages
@phpstan-return list<array<string, mixed>>
Parameters
PackageInterface[] $packages:
Return value
mixed[][]
1 call to Locker::lockPackages()
- Locker::setLockData in vendor/
composer/ composer/ src/ Composer/ Package/ Locker.php - Locks provided data into lockfile.
File
-
vendor/
composer/ composer/ src/ Composer/ Package/ Locker.php, line 479
Class
- Locker
- Reads/writes project lockfile (composer.lock).
Namespace
Composer\PackageCode
private function lockPackages(array $packages) : array {
$locked = [];
foreach ($packages as $package) {
if ($package instanceof AliasPackage) {
continue;
}
$name = $package->getPrettyName();
$version = $package->getPrettyVersion();
if (!$name || !$version) {
throw new \LogicException(sprintf('Package "%s" has no version or name and can not be locked', $package));
}
$spec = $this->dumper
->dump($package);
unset($spec['version_normalized']);
// always move time to the end of the package definition
$time = $spec['time'] ?? null;
unset($spec['time']);
if ($package->isDev() && $package->getInstallationSource() === 'source') {
// use the exact commit time of the current reference if it's a dev package
$time = $this->getPackageTime($package) ?: $time;
}
if (null !== $time) {
$spec['time'] = $time;
}
unset($spec['installation-source']);
$locked[] = $spec;
}
usort($locked, static function ($a, $b) {
$comparison = strcmp($a['name'], $b['name']);
if (0 !== $comparison) {
return $comparison;
}
// If it is the same package, compare the versions to make the order deterministic
return strcmp($a['version'], $b['version']);
});
return $locked;
}