/** * Creates a new in memory package. * * @param string $name The package's name * @param string $version The package's version * @param string $prettyVersion The package's non-normalized version */ public function __construct($name, $version, $prettyVersion) { parent::__construct($name); $this->version = $version; $this->prettyVersion = $prettyVersion; $this->dev = VersionParser::isDev($version); }
/** * All descendants' constructors should call this parent constructor * * @param PackageInterface $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(PackageInterface $aliasOf, $version, $prettyVersion) { parent::__construct($aliasOf->getName()); $this->version = $version; $this->prettyVersion = $prettyVersion; $this->aliasOf = $aliasOf; $this->dev = VersionParser::isDev($version); // replace self.version dependencies foreach (array('requires', 'recommends', 'suggests') as $type) { $links = $aliasOf->{'get' . ucfirst($type)}(); foreach ($links as $index => $link) { // link is self.version, but must be replacing also the replaced version if ('self.version' === $link->getPrettyConstraint()) { $links[$index] = new Link($link->getSource(), $link->getTarget(), new VersionConstraint('=', $this->version), $type, $this->version); } } $this->{$type} = $links; } // duplicate self.version provides foreach (array('conflicts', 'provides', 'replaces') as $type) { $links = $aliasOf->{'get' . ucfirst($type)}(); $newLinks = array(); 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(), new VersionConstraint('=', $this->version), $type, $this->version); } } $this->{$type} = array_merge($links, $newLinks); } }
/** * @dataProvider dataIsDev */ public function testIsDev($expected, $version) { $this->assertSame($expected, VersionParser::isDev($version)); }