/usr/share/php/Composer/Package/BasePackage.php is in composer 1.6.3-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | <?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\Package;
use Composer\Repository\RepositoryInterface;
use Composer\Repository\PlatformRepository;
/**
* Base class for packages providing name storage and default match implementation
*
* @author Nils Adermann <naderman@naderman.de>
*/
abstract class BasePackage implements PackageInterface
{
public static $supportedLinkTypes = array(
'require' => array('description' => 'requires', 'method' => 'requires'),
'conflict' => array('description' => 'conflicts', 'method' => 'conflicts'),
'provide' => array('description' => 'provides', 'method' => 'provides'),
'replace' => array('description' => 'replaces', 'method' => 'replaces'),
'require-dev' => array('description' => 'requires (for development)', 'method' => 'devRequires'),
);
const STABILITY_STABLE = 0;
const STABILITY_RC = 5;
const STABILITY_BETA = 10;
const STABILITY_ALPHA = 15;
const STABILITY_DEV = 20;
public static $stabilities = array(
'stable' => self::STABILITY_STABLE,
'RC' => self::STABILITY_RC,
'beta' => self::STABILITY_BETA,
'alpha' => self::STABILITY_ALPHA,
'dev' => self::STABILITY_DEV,
);
/**
* READ-ONLY: The package id, public for fast access in dependency solver
* @var int
*/
public $id;
/** @var string */
protected $name;
/** @var string */
protected $prettyName;
/** @var RepositoryInterface */
protected $repository;
/** @var array */
protected $transportOptions = array();
/**
* All descendants' constructors should call this parent constructor
*
* @param string $name The package's name
*/
public function __construct($name)
{
$this->prettyName = $name;
$this->name = strtolower($name);
$this->id = -1;
}
/**
* {@inheritDoc}
*/
public function getName()
{
return $this->name;
}
/**
* {@inheritDoc}
*/
public function getPrettyName()
{
return $this->prettyName;
}
/**
* {@inheritDoc}
*/
public function getNames()
{
$names = array(
$this->getName() => true,
);
foreach ($this->getProvides() as $link) {
$names[$link->getTarget()] = true;
}
foreach ($this->getReplaces() as $link) {
$names[$link->getTarget()] = true;
}
return array_keys($names);
}
/**
* {@inheritDoc}
*/
public function setId($id)
{
$this->id = $id;
}
/**
* {@inheritDoc}
*/
public function getId()
{
return $this->id;
}
/**
* {@inheritDoc}
*/
public function setRepository(RepositoryInterface $repository)
{
if ($this->repository && $repository !== $this->repository) {
throw new \LogicException('A package can only be added to one repository');
}
$this->repository = $repository;
}
/**
* {@inheritDoc}
*/
public function getRepository()
{
return $this->repository;
}
/**
* {@inheritDoc}
*/
public function getTransportOptions()
{
return $this->transportOptions;
}
/**
* Configures the list of options to download package dist files
*
* @param array $options
*/
public function setTransportOptions(array $options)
{
$this->transportOptions = $options;
}
/**
* checks if this package is a platform package
*
* @return bool
*/
public function isPlatform()
{
return $this->getRepository() instanceof PlatformRepository;
}
/**
* Returns package unique name, constructed from name, version and release type.
*
* @return string
*/
public function getUniqueName()
{
return $this->getName().'-'.$this->getVersion();
}
public function equals(PackageInterface $package)
{
$self = $this;
if ($this instanceof AliasPackage) {
$self = $this->getAliasOf();
}
if ($package instanceof AliasPackage) {
$package = $package->getAliasOf();
}
return $package === $self;
}
/**
* Converts the package into a readable and unique string
*
* @return string
*/
public function __toString()
{
return $this->getUniqueName();
}
public function getPrettyString()
{
return $this->getPrettyName().' '.$this->getPrettyVersion();
}
/**
* {@inheritDoc}
*/
public function getFullPrettyVersion($truncate = true)
{
if (!$this->isDev() || !in_array($this->getSourceType(), array('hg', 'git'))) {
return $this->getPrettyVersion();
}
// if source reference is a sha1 hash -- truncate
if ($truncate && strlen($this->getSourceReference()) === 40) {
return $this->getPrettyVersion() . ' ' . substr($this->getSourceReference(), 0, 7);
}
return $this->getPrettyVersion() . ' ' . $this->getSourceReference();
}
public function getStabilityPriority()
{
return self::$stabilities[$this->getStability()];
}
public function __clone()
{
$this->repository = null;
$this->id = -1;
}
}
|