function Transaction::getRootPackages
Determine which packages in the result are not required by any other packages in it.
These serve as a starting point to enumerate packages in a topological order despite potential cycles. If there are packages with a cycle on the top level the package with the lowest name gets picked
Return value
array<string, PackageInterface>
1 call to Transaction::getRootPackages()
- Transaction::calculateOperations in vendor/
composer/ composer/ src/ Composer/ DependencyResolver/ Transaction.php
File
-
vendor/
composer/ composer/ src/ Composer/ DependencyResolver/ Transaction.php, line 220
Class
- Transaction
- @author Nils Adermann <naderman@naderman.de> @internal
Namespace
Composer\DependencyResolverCode
protected function getRootPackages() : array {
$roots = $this->resultPackageMap;
foreach ($this->resultPackageMap as $packageHash => $package) {
if (!isset($roots[$packageHash])) {
continue;
}
foreach ($package->getRequires() as $link) {
$possibleRequires = $this->getProvidersInResult($link);
foreach ($possibleRequires as $require) {
if ($require !== $package) {
unset($roots[spl_object_hash($require)]);
}
}
}
}
return $roots;
}