class AliasPackage
@author Jordi Boggiano <j.boggiano@seld.be>
Hierarchy
- class \Composer\Package\BasePackage implements \Composer\Package\PackageInterface
- class \Composer\Package\AliasPackage extends \Composer\Package\BasePackage
Expanded class hierarchy of AliasPackage
27 files declare their use of AliasPackage
- ArrayRepository.php in vendor/
composer/ composer/ src/ Composer/ Repository/ ArrayRepository.php - AutoloadGenerator.php in vendor/
composer/ composer/ src/ Composer/ Autoload/ AutoloadGenerator.php - BumpCommand.php in vendor/
composer/ composer/ src/ Composer/ Command/ BumpCommand.php - CanonicalPackagesTrait.php in vendor/
composer/ composer/ src/ Composer/ Repository/ CanonicalPackagesTrait.php - ComposerRepository.php in vendor/
composer/ composer/ src/ Composer/ Repository/ ComposerRepository.php
File
-
vendor/
composer/ composer/ src/ Composer/ Package/ AliasPackage.php, line 21
Namespace
Composer\PackageView source
class AliasPackage extends BasePackage {
/** @var string */
protected $version;
/** @var string */
protected $prettyVersion;
/** @var bool */
protected $dev;
/** @var bool */
protected $rootPackageAlias = false;
/**
* @var string
* @phpstan-var 'stable'|'RC'|'beta'|'alpha'|'dev'
*/
protected $stability;
/** @var bool */
protected $hasSelfVersionRequires = false;
/** @var BasePackage */
protected $aliasOf;
/** @var Link[] */
protected $requires;
/** @var Link[] */
protected $devRequires;
/** @var Link[] */
protected $conflicts;
/** @var Link[] */
protected $provides;
/** @var Link[] */
protected $replaces;
/**
* All descendants' constructors should call this parent constructor
*
* @param BasePackage $aliasOf The package this package is an alias of
* @param string $version The version the alias must report
* @param string $prettyVersion The alias's non-normalized version
*/
public function __construct(BasePackage $aliasOf, string $version, string $prettyVersion) {
parent::__construct($aliasOf->getName());
$this->version = $version;
$this->prettyVersion = $prettyVersion;
$this->aliasOf = $aliasOf;
$this->stability = VersionParser::parseStability($version);
$this->dev = $this->stability === 'dev';
foreach (Link::$TYPES as $type) {
$links = $aliasOf->{'get' . ucfirst($type)}();
$this->{$type} = $this->replaceSelfVersionDependencies($links, $type);
}
}
/**
* @return BasePackage
*/
public function getAliasOf() {
return $this->aliasOf;
}
/**
* @inheritDoc
*/
public function getVersion() : string {
return $this->version;
}
/**
* @inheritDoc
*/
public function getStability() : string {
return $this->stability;
}
/**
* @inheritDoc
*/
public function getPrettyVersion() : string {
return $this->prettyVersion;
}
/**
* @inheritDoc
*/
public function isDev() : bool {
return $this->dev;
}
/**
* @inheritDoc
*/
public function getRequires() : array {
return $this->requires;
}
/**
* @inheritDoc
* @return array<string|int, Link>
*/
public function getConflicts() : array {
return $this->conflicts;
}
/**
* @inheritDoc
* @return array<string|int, Link>
*/
public function getProvides() : array {
return $this->provides;
}
/**
* @inheritDoc
* @return array<string|int, Link>
*/
public function getReplaces() : array {
return $this->replaces;
}
/**
* @inheritDoc
*/
public function getDevRequires() : array {
return $this->devRequires;
}
/**
* Stores whether this is an alias created by an aliasing in the requirements of the root package or not
*
* Use by the policy for sorting manually aliased packages first, see #576
*/
public function setRootPackageAlias(bool $value) : void {
$this->rootPackageAlias = $value;
}
/**
* @see setRootPackageAlias
*/
public function isRootPackageAlias() : bool {
return $this->rootPackageAlias;
}
/**
* @param Link[] $links
* @param Link::TYPE_* $linkType
*
* @return Link[]
*/
protected function replaceSelfVersionDependencies(array $links, $linkType) : array {
// for self.version requirements, we use the original package's branch name instead, to avoid leaking the magic dev-master-alias to users
$prettyVersion = $this->prettyVersion;
if ($prettyVersion === VersionParser::DEFAULT_BRANCH_ALIAS) {
$prettyVersion = $this->aliasOf
->getPrettyVersion();
}
if (\in_array($linkType, [
Link::TYPE_CONFLICT,
Link::TYPE_PROVIDE,
Link::TYPE_REPLACE,
], true)) {
$newLinks = [];
foreach ($links as $link) {
// link is self.version, but must be replacing also the replaced version
if ('self.version' === $link->getPrettyConstraint()) {
$newLinks[] = new Link($link->getSource(), $link->getTarget(), $constraint = new Constraint('=', $this->version), $linkType, $prettyVersion);
$constraint->setPrettyString($prettyVersion);
}
}
$links = array_merge($links, $newLinks);
}
else {
foreach ($links as $index => $link) {
if ('self.version' === $link->getPrettyConstraint()) {
if ($linkType === Link::TYPE_REQUIRE) {
$this->hasSelfVersionRequires = true;
}
$links[$index] = new Link($link->getSource(), $link->getTarget(), $constraint = new Constraint('=', $this->version), $linkType, $prettyVersion);
$constraint->setPrettyString($prettyVersion);
}
}
}
return $links;
}
public function hasSelfVersionRequires() : bool {
return $this->hasSelfVersionRequires;
}
public function __toString() : string {
return parent::__toString() . ' (' . ($this->rootPackageAlias ? 'root ' : '') . 'alias of ' . $this->aliasOf
->getVersion() . ')';
}
/***************************************
* Wrappers around the aliased package *
***************************************/
public function getType() : string {
return $this->aliasOf
->getType();
}
public function getTargetDir() : ?string {
return $this->aliasOf
->getTargetDir();
}
public function getExtra() : array {
return $this->aliasOf
->getExtra();
}
public function setInstallationSource(?string $type) : void {
$this->aliasOf
->setInstallationSource($type);
}
public function getInstallationSource() : ?string {
return $this->aliasOf
->getInstallationSource();
}
public function getSourceType() : ?string {
return $this->aliasOf
->getSourceType();
}
public function getSourceUrl() : ?string {
return $this->aliasOf
->getSourceUrl();
}
public function getSourceUrls() : array {
return $this->aliasOf
->getSourceUrls();
}
public function getSourceReference() : ?string {
return $this->aliasOf
->getSourceReference();
}
public function setSourceReference(?string $reference) : void {
$this->aliasOf
->setSourceReference($reference);
}
public function setSourceMirrors(?array $mirrors) : void {
$this->aliasOf
->setSourceMirrors($mirrors);
}
public function getSourceMirrors() : ?array {
return $this->aliasOf
->getSourceMirrors();
}
public function getDistType() : ?string {
return $this->aliasOf
->getDistType();
}
public function getDistUrl() : ?string {
return $this->aliasOf
->getDistUrl();
}
public function getDistUrls() : array {
return $this->aliasOf
->getDistUrls();
}
public function getDistReference() : ?string {
return $this->aliasOf
->getDistReference();
}
public function setDistReference(?string $reference) : void {
$this->aliasOf
->setDistReference($reference);
}
public function getDistSha1Checksum() : ?string {
return $this->aliasOf
->getDistSha1Checksum();
}
public function setTransportOptions(array $options) : void {
$this->aliasOf
->setTransportOptions($options);
}
public function getTransportOptions() : array {
return $this->aliasOf
->getTransportOptions();
}
public function setDistMirrors(?array $mirrors) : void {
$this->aliasOf
->setDistMirrors($mirrors);
}
public function getDistMirrors() : ?array {
return $this->aliasOf
->getDistMirrors();
}
public function getAutoload() : array {
return $this->aliasOf
->getAutoload();
}
public function getDevAutoload() : array {
return $this->aliasOf
->getDevAutoload();
}
public function getIncludePaths() : array {
return $this->aliasOf
->getIncludePaths();
}
public function getPhpExt() : ?array {
return $this->aliasOf
->getPhpExt();
}
public function getReleaseDate() : ?\DateTimeInterface {
return $this->aliasOf
->getReleaseDate();
}
public function getBinaries() : array {
return $this->aliasOf
->getBinaries();
}
public function getSuggests() : array {
return $this->aliasOf
->getSuggests();
}
public function getNotificationUrl() : ?string {
return $this->aliasOf
->getNotificationUrl();
}
public function isDefaultBranch() : bool {
return $this->aliasOf
->isDefaultBranch();
}
public function setDistUrl(?string $url) : void {
$this->aliasOf
->setDistUrl($url);
}
public function setDistType(?string $type) : void {
$this->aliasOf
->setDistType($type);
}
public function setSourceDistReferences(string $reference) : void {
$this->aliasOf
->setSourceDistReferences($reference);
}
}
Members
Title Sort descending | Deprecated | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|---|
AliasPackage::$aliasOf | protected | property | @var BasePackage | 1 | ||
AliasPackage::$conflicts | protected | property | @var Link[] | |||
AliasPackage::$dev | protected | property | @var bool | |||
AliasPackage::$devRequires | protected | property | @var Link[] | |||
AliasPackage::$hasSelfVersionRequires | protected | property | @var bool | |||
AliasPackage::$prettyVersion | protected | property | @var string | |||
AliasPackage::$provides | protected | property | @var Link[] | |||
AliasPackage::$replaces | protected | property | @var Link[] | |||
AliasPackage::$requires | protected | property | @var Link[] | |||
AliasPackage::$rootPackageAlias | protected | property | @var bool | |||
AliasPackage::$stability | protected | property | @phpstan-var 'stable'|'RC'|'beta'|'alpha'|'dev' | |||
AliasPackage::$version | protected | property | @var string | |||
AliasPackage::getAliasOf | public | function | 1 | |||
AliasPackage::getAutoload | public | function | Returns an associative array of autoloading rules | Overrides PackageInterface::getAutoload | ||
AliasPackage::getBinaries | public | function | Returns the package binaries | Overrides PackageInterface::getBinaries | ||
AliasPackage::getConflicts | public | function | @inheritDoc | Overrides PackageInterface::getConflicts | ||
AliasPackage::getDevAutoload | public | function | Returns an associative array of dev autoloading rules | Overrides PackageInterface::getDevAutoload | ||
AliasPackage::getDevRequires | public | function | @inheritDoc | Overrides PackageInterface::getDevRequires | ||
AliasPackage::getDistMirrors | public | function | Returns the dist mirrors of this package | Overrides PackageInterface::getDistMirrors | ||
AliasPackage::getDistReference | public | function | Returns the reference of the distribution archive of this version, e.g. master, 1.0.0 or a commit hash for git | Overrides PackageInterface::getDistReference | ||
AliasPackage::getDistSha1Checksum | public | function | Returns the sha1 checksum for the distribution archive of this version | Overrides PackageInterface::getDistSha1Checksum | ||
AliasPackage::getDistType | public | function | Returns the type of the distribution archive of this version, e.g. zip, tarball | Overrides PackageInterface::getDistType | ||
AliasPackage::getDistUrl | public | function | Returns the url of the distribution archive of this version | Overrides PackageInterface::getDistUrl | ||
AliasPackage::getDistUrls | public | function | Returns the urls of the distribution archive of this version, including mirrors | Overrides PackageInterface::getDistUrls | ||
AliasPackage::getExtra | public | function | Returns the package extra data | Overrides PackageInterface::getExtra | ||
AliasPackage::getIncludePaths | public | function | Returns a list of directories which should get added to PHP's include path. |
Overrides PackageInterface::getIncludePaths | ||
AliasPackage::getInstallationSource | public | function | Returns source from which this package was installed (source/dist). | Overrides PackageInterface::getInstallationSource | ||
AliasPackage::getNotificationUrl | public | function | Returns the package notification url | Overrides PackageInterface::getNotificationUrl | ||
AliasPackage::getPhpExt | public | function | Returns the settings for php extension packages | Overrides PackageInterface::getPhpExt | ||
AliasPackage::getPrettyVersion | public | function | @inheritDoc | Overrides PackageInterface::getPrettyVersion | ||
AliasPackage::getProvides | public | function | @inheritDoc | Overrides PackageInterface::getProvides | ||
AliasPackage::getReleaseDate | public | function | Returns the release date of the package | Overrides PackageInterface::getReleaseDate | ||
AliasPackage::getReplaces | public | function | @inheritDoc | Overrides PackageInterface::getReplaces | ||
AliasPackage::getRequires | public | function | @inheritDoc | Overrides PackageInterface::getRequires | ||
AliasPackage::getSourceMirrors | public | function | Returns the source mirrors of this package | Overrides PackageInterface::getSourceMirrors | ||
AliasPackage::getSourceReference | public | function | Returns the repository reference of this package, e.g. master, 1.0.0 or a commit hash for git | Overrides PackageInterface::getSourceReference | ||
AliasPackage::getSourceType | public | function | Returns the repository type of this package, e.g. git, svn | Overrides PackageInterface::getSourceType | ||
AliasPackage::getSourceUrl | public | function | Returns the repository url of this package, e.g. git://github.com/naderman/composer.git | Overrides PackageInterface::getSourceUrl | ||
AliasPackage::getSourceUrls | public | function | Returns the repository urls of this package including mirrors, e.g. git://github.com/naderman/composer.git | Overrides PackageInterface::getSourceUrls | ||
AliasPackage::getStability | public | function | @inheritDoc | Overrides PackageInterface::getStability | ||
AliasPackage::getSuggests | public | function | Returns a set of package names and reasons why they are useful in combination with this package. |
Overrides PackageInterface::getSuggests | ||
AliasPackage::getTargetDir | public | function | Returns the package targetDir property | Overrides PackageInterface::getTargetDir | ||
AliasPackage::getTransportOptions | public | function | Returns a list of options to download package dist files | Overrides PackageInterface::getTransportOptions | ||
AliasPackage::getType | public | function | Returns the package type, e.g. library | Overrides PackageInterface::getType | ||
AliasPackage::getVersion | public | function | @inheritDoc | Overrides PackageInterface::getVersion | ||
AliasPackage::hasSelfVersionRequires | public | function | ||||
AliasPackage::isDefaultBranch | public | function | Overrides PackageInterface::isDefaultBranch | |||
AliasPackage::isDev | public | function | @inheritDoc | Overrides PackageInterface::isDev | ||
AliasPackage::isRootPackageAlias | public | function | ||||
AliasPackage::replaceSelfVersionDependencies | protected | function | ||||
AliasPackage::setDistMirrors | public | function | Overrides PackageInterface::setDistMirrors | |||
AliasPackage::setDistReference | public | function | Overrides PackageInterface::setDistReference | |||
AliasPackage::setDistType | public | function | Overrides PackageInterface::setDistType | |||
AliasPackage::setDistUrl | public | function | Overrides PackageInterface::setDistUrl | |||
AliasPackage::setInstallationSource | public | function | Sets source from which this package was installed (source/dist). | Overrides PackageInterface::setInstallationSource | ||
AliasPackage::setRootPackageAlias | public | function | Stores whether this is an alias created by an aliasing in the requirements of the root package or not | |||
AliasPackage::setSourceDistReferences | public | function | Set dist and source references and update dist URL for ones that contain a reference | Overrides PackageInterface::setSourceDistReferences | ||
AliasPackage::setSourceMirrors | public | function | Overrides PackageInterface::setSourceMirrors | |||
AliasPackage::setSourceReference | public | function | Overrides PackageInterface::setSourceReference | |||
AliasPackage::setTransportOptions | public | function | Configures the list of options to download package dist files | Overrides PackageInterface::setTransportOptions | ||
AliasPackage::__construct | public | function | All descendants' constructors should call this parent constructor | Overrides BasePackage::__construct | 1 | |
AliasPackage::__toString | public | function | Converts the package into a readable and unique string | Overrides BasePackage::__toString | ||
BasePackage::$id | public | property | READ-ONLY: The package id, public for fast access in dependency solver @internal |
|||
BasePackage::$name | protected | property | @var string | |||
BasePackage::$prettyName | protected | property | @var string | |||
BasePackage::$repository | protected | property | @var ?RepositoryInterface | |||
BasePackage::$stabilities | Deprecated | public static | property | @phpstan-ignore property.readOnlyByPhpDocDefaultValue | ||
BasePackage::$supportedLinkTypes | public static | property | @phpstan-var array<non-empty-string, array{description: string, method: Link::TYPE_*}> @internal |
|||
BasePackage::equals | public | function | ||||
BasePackage::getFullPrettyVersion | public | function | @inheritDoc | Overrides PackageInterface::getFullPrettyVersion | ||
BasePackage::getId | public | function | @inheritDoc | Overrides PackageInterface::getId | ||
BasePackage::getName | public | function | @inheritDoc | Overrides PackageInterface::getName | ||
BasePackage::getNames | public | function | @inheritDoc | Overrides PackageInterface::getNames | ||
BasePackage::getPrettyName | public | function | @inheritDoc | Overrides PackageInterface::getPrettyName | ||
BasePackage::getPrettyString | public | function | Converts the package into a pretty readable string | Overrides PackageInterface::getPrettyString | ||
BasePackage::getRepository | public | function | @inheritDoc | Overrides PackageInterface::getRepository | ||
BasePackage::getStabilityPriority | public | function | @phpstan-return self::STABILITY_* | |||
BasePackage::getUniqueName | public | function | Returns package unique name, constructed from name, version and release type. | Overrides PackageInterface::getUniqueName | ||
BasePackage::isPlatform | public | function | checks if this package is a platform package | |||
BasePackage::packageNamesToRegexp | public static | function | Build a regexp from package names, expanding * globs as required | |||
BasePackage::packageNameToRegexp | public static | function | Build a regexp from a package name, expanding * globs as required | |||
BasePackage::setId | public | function | @inheritDoc | Overrides PackageInterface::setId | ||
BasePackage::setRepository | public | function | @inheritDoc | Overrides PackageInterface::setRepository | ||
BasePackage::STABILITIES | public | constant | ||||
BasePackage::STABILITY_ALPHA | public | constant | ||||
BasePackage::STABILITY_BETA | public | constant | ||||
BasePackage::STABILITY_DEV | public | constant | ||||
BasePackage::STABILITY_RC | public | constant | ||||
BasePackage::STABILITY_STABLE | public | constant | ||||
BasePackage::__clone | public | function | 1 | |||
PackageInterface::DISPLAY_DIST_REF | public | constant | ||||
PackageInterface::DISPLAY_SOURCE_REF | public | constant | ||||
PackageInterface::DISPLAY_SOURCE_REF_IF_DEV | public | constant |