本文整理汇总了PHP中Composer\Repository\ArrayRepository类的典型用法代码示例。如果您正苦于以下问题:PHP ArrayRepository类的具体用法?PHP ArrayRepository怎么用?PHP ArrayRepository使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ArrayRepository类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testPrettyString
public function testPrettyString()
{
$repo = new ArrayRepository();
$repo->addPackage($p1 = $this->getPackage('foo', '2.1'));
$repo->addPackage($p2 = $this->getPackage('baz', '1.1'));
$this->pool->addRepository($repo);
$rule = new Rule(array($p1->getId(), -$p2->getId()), 'job1', null);
$this->assertEquals('(don\'t install baz 1.1|install foo 2.1)', $rule->getPrettyString($this->pool));
}
示例2: testToString
public function testToString()
{
$repo = new ArrayRepository();
$repo->addPackage($p1 = $this->getPackage('foo', '2.1'));
$repo->addPackage($p2 = $this->getPackage('baz', '1.1'));
$this->pool->addRepository($repo);
$rule = new Rule($this->pool, array($p1->getId(), -$p2->getId()), 'job1', null);
$this->assertEquals('(-baz-1.1.0.0|+foo-2.1.0.0)', $rule->__toString());
}
示例3: testAutomaticallyAddAliasedPackage
public function testAutomaticallyAddAliasedPackage()
{
$repo = new ArrayRepository();
$package = $this->getPackage('foo', '1');
$alias = $this->getAliasPackage($package, '2');
$repo->addPackage($alias);
$this->assertEquals(2, count($repo));
$this->assertTrue($repo->hasPackage($this->getPackage('foo', '1')));
$this->assertTrue($repo->hasPackage($this->getPackage('foo', '2')));
}
示例4: testSolverInstallSamePackageFromDifferentRepositories
public function testSolverInstallSamePackageFromDifferentRepositories()
{
$repo1 = new ArrayRepository();
$repo2 = new ArrayRepository();
$repo1->addPackage($foo1 = $this->getPackage('foo', '1'));
$repo2->addPackage($foo2 = $this->getPackage('foo', '1'));
$this->pool->addRepository($this->repoInstalled);
$this->pool->addRepository($repo1);
$this->pool->addRepository($repo2);
$this->request->install('foo');
$this->checkSolverResult(array(array('job' => 'install', 'package' => $foo1)));
}
示例5: testRequestInstallSamePackageFromDifferentRepositories
public function testRequestInstallSamePackageFromDifferentRepositories()
{
$repo1 = new ArrayRepository();
$repo2 = new ArrayRepository();
$foo1 = $this->getPackage('foo', '1');
$foo2 = $this->getPackage('foo', '1');
$repo1->addPackage($foo1);
$repo2->addPackage($foo2);
$request = new Request();
$request->install('foo', $constraint = $this->getVersionConstraint('=', '1'));
$this->assertEquals(array(array('cmd' => 'install', 'packageName' => 'foo', 'constraint' => $constraint, 'fixed' => false)), $request->getJobs());
}
示例6: testGetMaxId
public function testGetMaxId()
{
$pool = new Pool();
$repository = new ArrayRepository();
$firstPackage = $this->getPackage('foo', '1');
$secondPackage = $this->getPackage('foo1', '1');
$this->assertEquals(0, $pool->getMaxId());
$repository->addPackage($firstPackage);
$repository->addPackage($secondPackage);
$pool->addRepository($repository);
$this->assertEquals(2, $pool->getMaxId());
}
示例7: testRequestInstallAndRemove
public function testRequestInstallAndRemove()
{
$pool = new Pool();
$repo = new ArrayRepository();
$foo = $this->getPackage('foo', '1');
$bar = $this->getPackage('bar', '1');
$foobar = $this->getPackage('foobar', '1');
$repo->addPackage($foo);
$repo->addPackage($bar);
$repo->addPackage($foobar);
$pool->addRepository($repo);
$request = new Request($pool);
$request->install('foo');
$request->install('bar');
$request->remove('foobar');
$this->assertEquals(array(array('packages' => array($foo), 'cmd' => 'install', 'packageName' => 'foo'), array('packages' => array($bar), 'cmd' => 'install', 'packageName' => 'bar'), array('packages' => array($foobar), 'cmd' => 'remove', 'packageName' => 'foobar')), $request->getJobs());
}
示例8: dataGetPackages
/**
* @return array
*/
public function dataGetPackages()
{
$emptyRepo = new ArrayRepository();
$vendorRepo = new ArrayRepository();
$vendorRepo2 = new ArrayRepository();
$package = new Package('vendor/name', '1.0.0.0', '1.0');
$package2 = new Package('vendor2/name', '1.0.0.0', '1.0');
$package3 = new Package('vendor2/name2', '1.0.0.0', '1.0');
$vendorRepo->addPackage($package);
$vendorRepo2->addPackage($package2);
$vendorRepo2->addPackage($package3);
$data = [];
$data['empty repository'] = [[], [], $emptyRepo];
$data['empty repository with filter'] = [[], ['vendor/name'], $emptyRepo];
$data['repository with one package'] = [[$package], [], $vendorRepo];
$data['repository with one package and filter'] = [[], ['othervendor/othername'], $vendorRepo];
$data['repository with two packages'] = [[$package2, $package3], [], $vendorRepo2];
$data['repository with two packages and filter'] = [[$package2], ['vendor2/name'], $vendorRepo2];
return $data;
}
示例9: dataGetPackages
public function dataGetPackages()
{
$emptyRepo = new ArrayRepository();
$vendorRepo = new ArrayRepository();
$vendorRepo2 = new ArrayRepository();
$package = new Package('vendor/name', '1.0.0.0', '1.0');
$package2 = new Package('vendor2/name', '1.0.0.0', '1.0');
$package3 = new Package('vendor2/name2', '1.0.0.0', '1.0');
$vendorRepo->addPackage($package);
$vendorRepo2->addPackage($package2);
$vendorRepo2->addPackage($package3);
$data = array();
$data['empty repository'] = array(array(), array(), $emptyRepo);
$data['empty repository with filter'] = array(array(), array('vendor/name'), $emptyRepo);
$data['repository with one package'] = array(array($package), array(), $vendorRepo);
$data['repository with one package and filter'] = array(array(), array('othervendor/othername'), $vendorRepo);
$data['repository with two packages'] = array(array($package2, $package3), array(), $vendorRepo2);
$data['repository with two packages and filter'] = array(array($package2), array('vendor2/name'), $vendorRepo2);
return $data;
}
示例10: testSearchWithPackageType
public function testSearchWithPackageType()
{
$repo = new ArrayRepository();
$repo->addPackage($this->getPackage('foo', '1', 'Composer\\Package\\CompletePackage'));
$repo->addPackage($this->getPackage('bar', '1', 'Composer\\Package\\CompletePackage'));
$package = $this->getPackage('foobar', '1', 'Composer\\Package\\CompletePackage');
$package->setType('composer-plugin');
$repo->addPackage($package);
$this->assertSame(array(array('name' => 'foo', 'description' => null)), $repo->search('foo', RepositoryInterface::SEARCH_FULLTEXT, 'library'));
$this->assertEmpty($repo->search('bar', RepositoryInterface::SEARCH_FULLTEXT, 'package'));
$this->assertSame(array(array('name' => 'foobar', 'description' => null)), $repo->search('foo', 0, 'composer-plugin'));
}
示例11: Construct
public static function Construct(IOInterface $io)
{
$repo = new ArrayRepository();
try {
$web_folder = Locator::getWebFolderPath();
$version_file = $web_folder . '/intranet/setup/_init/version.txt';
if (!file_exists($version_file)) {
throw new \Exception("No version.txt for core found - assuming framework is not installed");
}
$version_data = file($version_file);
$core_version = $version_data[1];
$normalizer = new VersionParser();
$core_version_normalized = $normalizer->normalize($core_version);
$io->write("Detected core version {$core_version} ({$core_version_normalized})");
$core_package = new Package(FrameworkInstallerV8::PACKAGE_NAME, $core_version_normalized, $core_version);
$repo->addPackage($core_package);
} catch (\Exception $e) {
$io->write($e->getMessage());
// if can't determine location of 'web' folder, not adding the core package therefore letting
// composer install it
}
return $repo;
}
示例12: getLockedRepository
public function getLockedRepository($withDevReqs = false)
{
$lockData = $this->getLockData();
$packages = new ArrayRepository();
$lockedPackages = $lockData['packages'];
if ($withDevReqs) {
if (isset($lockData['packages-dev'])) {
$lockedPackages = array_merge($lockedPackages, $lockData['packages-dev']);
} else {
throw new \RuntimeException('The lock file does not contain require-dev information, run install with the --no-dev option or run update to install those packages.');
}
}
if (empty($lockedPackages)) {
return $packages;
}
if (isset($lockedPackages[0]['name'])) {
foreach ($lockedPackages as $info) {
$packages->addPackage($this->loader->load($info));
}
return $packages;
}
throw new \RuntimeException('Your composer.lock was created before 2012-09-15, and is not supported anymore. Run "composer update" to generate a new one.');
}
示例13: initialize
protected function initialize()
{
parent::initialize();
$versionParser = new VersionParser();
try {
$prettyVersion = PHP_VERSION;
$version = $versionParser->normalize($prettyVersion);
} catch (\UnexpectedValueException $e) {
$prettyVersion = preg_replace('#^(.+?)(-.+)?$#', '$1', PHP_VERSION);
$version = $versionParser->normalize($prettyVersion);
}
$php = new MemoryPackage('php', $version, $prettyVersion);
$php->setDescription('The PHP interpreter');
parent::addPackage($php);
foreach (get_loaded_extensions() as $name) {
if (in_array($name, array('standard', 'Core'))) {
continue;
}
$reflExt = new \ReflectionExtension($name);
try {
$prettyVersion = $reflExt->getVersion();
$version = $versionParser->normalize($prettyVersion);
} catch (\UnexpectedValueException $e) {
$prettyVersion = '0';
$version = $versionParser->normalize($prettyVersion);
}
$ext = new MemoryPackage('ext-' . $name, $version, $prettyVersion);
$ext->setDescription('The ' . $name . ' PHP extension');
parent::addPackage($ext);
}
}
示例14: initialize
protected function initialize()
{
parent::initialize();
$this->io->write('Initializing PEAR repository ' . $this->url);
$this->initializeChannel();
$this->io->write('Packages names will be prefixed with: pear-' . $this->channel . '/');
// try to load as a composer repo
try {
$json = new JsonFile($this->url . '/packages.json', new RemoteFilesystem($this->io));
$packages = $json->read();
if ($this->io->isVerbose()) {
$this->io->write('Repository is Composer-compatible, loading via packages.json instead of PEAR protocol');
}
$loader = new ArrayLoader();
foreach ($packages as $data) {
foreach ($data['versions'] as $rev) {
if (strpos($rev['name'], 'pear-' . $this->channel) !== 0) {
$rev['name'] = 'pear-' . $this->channel . '/' . $rev['name'];
}
$this->addPackage($loader->load($rev));
if ($this->io->isVerbose()) {
$this->io->write('Loaded ' . $rev['name'] . ' ' . $rev['version']);
}
}
}
return;
} catch (\Exception $e) {
}
$this->fetchFromServer();
}
示例15: initialize
/**
* Initializes repository (reads file, or remote address).
*/
protected function initialize()
{
parent::initialize();
if (!$this->file->exists()) {
return;
}
$packages = $this->file->read();
if (!is_array($packages)) {
throw new \UnexpectedValueException('Could not parse package list from the ' . $this->file->getPath() . ' repository');
}
$loader = new ArrayLoader();
foreach ($packages as $packageData) {
$package = $loader->load($packageData);
// package was installed as alias, so we only add the alias
if ($this instanceof InstalledRepositoryInterface && !empty($packageData['installed-as-alias'])) {
$alias = $packageData['installed-as-alias'];
$package->setAlias($alias);
$package->setPrettyAlias($alias);
$package->setInstalledAsAlias(true);
$this->addPackage($this->createAliasPackage($package, $alias, $alias));
} else {
// only add regular package - if it's not an installed repo the alias will be created on the fly
$this->addPackage($package);
}
}
}