$packages
$packages : array<mixed,\Composer\Package\PackageInterface>
Writable array repository.
$packages : array<mixed,\Composer\Package\PackageInterface>
hasPackage(\Composer\Package\PackageInterface $package)
{@inheritDoc}
\Composer\Package\PackageInterface | $package |
addPackage(\Composer\Package\PackageInterface $package)
Adds a new package to the repository
\Composer\Package\PackageInterface | $package |
removePackage(\Composer\Package\PackageInterface $package)
Removes package from repository.
\Composer\Package\PackageInterface | $package | package instance |
getDependents(string|array<mixed,string> $needle, \Composer\Semver\Constraint\ConstraintInterface|null $constraint = null, boolean $invert = false, boolean $recurse = true, array<mixed,string> $packagesFound = null) : array
Returns a list of links causing the requested needle packages to be installed, as an associative array with the dependent's name as key, and an array containing in order the PackageInterface and Link describing the relationship as values. If recursive lookup was requested a third value is returned containing an identically formed array up to the root package. That third value will be false in case a circular recursion was detected.
string|array<mixed,string> | $needle | The package name(s) to inspect. |
\Composer\Semver\Constraint\ConstraintInterface|null | $constraint | Optional constraint to filter by. |
boolean | $invert | Whether to invert matches to discover reasons for the package NOT to be installed. |
boolean | $recurse | Whether to recursively expand the requirement tree up to the root package. |
array<mixed,string> | $packagesFound | Used internally when recurring |
An associative array of arrays as described above.
getCanonicalPackages() : array<mixed,\Composer\Package\PackageInterface>
Get unique packages (at most one package of each name), with aliases resolved and removed.
createAliasPackage(\Composer\Package\PackageInterface $package, $alias, $prettyAlias)
\Composer\Package\PackageInterface | $package | |
$alias | ||
$prettyAlias |
<?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer\Repository;
use Composer\Package\AliasPackage;
/**
* Writable array repository.
*
* @author Jordi Boggiano <j.boggiano@seld.be>
*/
class WritableArrayRepository extends ArrayRepository implements WritableRepositoryInterface
{
/**
* {@inheritDoc}
*/
public function write()
{
}
/**
* {@inheritDoc}
*/
public function reload()
{
}
/**
* {@inheritDoc}
*/
public function getCanonicalPackages()
{
$packages = $this->getPackages();
// get at most one package of each name, preferring non-aliased ones
$packagesByName = array();
foreach ($packages as $package) {
if (!isset($packagesByName[$package->getName()]) || $packagesByName[$package->getName()] instanceof AliasPackage) {
$packagesByName[$package->getName()] = $package;
}
}
$canonicalPackages = array();
// unfold aliased packages
foreach ($packagesByName as $package) {
while ($package instanceof AliasPackage) {
$package = $package->getAliasOf();
}
$canonicalPackages[] = $package;
}
return $canonicalPackages;
}
}