当前位置: 首页>>代码示例>>PHP>>正文


PHP Pool::whatProvides方法代码示例

本文整理汇总了PHP中Composer\DependencyResolver\Pool::whatProvides方法的典型用法代码示例。如果您正苦于以下问题:PHP Pool::whatProvides方法的具体用法?PHP Pool::whatProvides怎么用?PHP Pool::whatProvides使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Composer\DependencyResolver\Pool的用法示例。


在下文中一共展示了Pool::whatProvides方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: matchesCakeVersion

 /**
  * Check if CakePHP version matches against a version
  *
  * @param string $matcher
  * @param string $version
  * @return bool
  */
 protected function matchesCakeVersion($matcher, $version)
 {
     if (class_exists('Composer\\Semver\\Constraint\\MultiConstraint')) {
         $multiClass = 'Composer\\Semver\\Constraint\\MultiConstraint';
         $constraintClass = 'Composer\\Semver\\Constraint\\Constraint';
     } else {
         $multiClass = 'Composer\\Package\\LinkConstraint\\MultiConstraint';
         $constraintClass = 'Composer\\Package\\LinkConstraint\\VersionConstraint';
     }
     $repositoryManager = $this->composer->getRepositoryManager();
     if ($repositoryManager) {
         $repos = $repositoryManager->getLocalRepository();
         if (!$repos) {
             return false;
         }
         $cake3 = new $multiClass(array(new $constraintClass($matcher, $version), new $constraintClass('!=', '9999999-dev')));
         $pool = new Pool('dev');
         $pool->addRepository($repos);
         $packages = $pool->whatProvides('cakephp/cakephp');
         foreach ($packages as $package) {
             $installed = new $constraintClass('=', $package->getVersion());
             if ($cake3->matches($installed)) {
                 return true;
                 break;
             }
         }
     }
     return false;
 }
开发者ID:billythekid,项目名称:prodder,代码行数:36,代码来源:CakePHPInstaller.php

示例2: checkForRootRequireProblems

 /**
  * @param bool $ignorePlatformReqs
  */
 protected function checkForRootRequireProblems($ignorePlatformReqs)
 {
     foreach ($this->jobs as $job) {
         switch ($job['cmd']) {
             case 'update':
                 $packages = $this->pool->whatProvides($job['packageName'], $job['constraint']);
                 foreach ($packages as $package) {
                     if (isset($this->installedMap[$package->id])) {
                         $this->updateMap[$package->id] = true;
                     }
                 }
                 break;
             case 'update-all':
                 foreach ($this->installedMap as $package) {
                     $this->updateMap[$package->id] = true;
                 }
                 break;
             case 'install':
                 if ($ignorePlatformReqs && preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $job['packageName'])) {
                     break;
                 }
                 if (!$this->pool->whatProvides($job['packageName'], $job['constraint'])) {
                     $problem = new Problem($this->pool);
                     $problem->addRule(new Rule(array(), null, null, $job));
                     $this->problems[] = $problem;
                 }
                 break;
         }
     }
 }
开发者ID:Rudloff,项目名称:composer,代码行数:33,代码来源:Solver.php

示例3: testSelectLocalReposFirst

    public function testSelectLocalReposFirst()
    {
        $repoImportant = new ArrayRepository;

        $this->repo->addPackage($packageA = $this->getPackage('A', 'dev-master'));
        $this->repo->addPackage($packageAAlias = new AliasPackage($packageA, '2.1.9999999.9999999-dev', '2.1.x-dev'));
        $repoImportant->addPackage($packageAImportant = $this->getPackage('A', 'dev-feature-a'));
        $repoImportant->addPackage($packageAAliasImportant = new AliasPackage($packageAImportant, '2.1.9999999.9999999-dev', '2.1.x-dev'));
        $repoImportant->addPackage($packageA2Important = $this->getPackage('A', 'dev-master'));
        $repoImportant->addPackage($packageA2AliasImportant = new AliasPackage($packageA2Important, '2.1.9999999.9999999-dev', '2.1.x-dev'));
        $packageAAliasImportant->setRootPackageAlias(true);

        $this->pool->addRepository($this->repoInstalled);
        $this->pool->addRepository($repoImportant);
        $this->pool->addRepository($this->repo);

        $packages = $this->pool->whatProvides('a', new Constraint('=', '2.1.9999999.9999999-dev'));
        $literals = array();
        foreach ($packages as $package) {
            $literals[] = $package->getId();
        }

        $expected = array($packageAAliasImportant->getId());

        $selected = $this->policy->selectPreferredPackages($this->pool, array(), $literals);

        $this->assertSame($expected, $selected);
    }
开发者ID:Rudloff,项目名称:composer,代码行数:28,代码来源:DefaultPolicyTest.php

示例4: doExecute

 /**
  * Execute the command.
  *
  * @param  InputInterface  $input
  * @param  OutputInterface $output
  * @param  bool            $inverted Whether to invert matching process (why-not vs why behaviour)
  * @return int|null        Exit code of the operation.
  */
 protected function doExecute(InputInterface $input, OutputInterface $output, $inverted = false)
 {
     // Emit command event on startup
     $composer = $this->getComposer();
     $commandEvent = new CommandEvent(PluginEvents::COMMAND, $this->getName(), $input, $output);
     $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
     // Prepare repositories and set up a pool
     $platformOverrides = $composer->getConfig()->get('platform') ?: array();
     $repository = new CompositeRepository(array(new ArrayRepository(array($composer->getPackage())), $composer->getRepositoryManager()->getLocalRepository(), new PlatformRepository(array(), $platformOverrides)));
     $pool = new Pool();
     $pool->addRepository($repository);
     // Parse package name and constraint
     list($needle, $textConstraint) = array_pad(explode(':', $input->getArgument(self::ARGUMENT_PACKAGE)), 2, $input->getArgument(self::ARGUMENT_CONSTRAINT));
     // Find packages that are or provide the requested package first
     $packages = $pool->whatProvides($needle);
     if (empty($packages)) {
         throw new \InvalidArgumentException(sprintf('Could not find package "%s" in your project', $needle));
     }
     // If the version we ask for is not installed then we need to locate it in remote repos and add it.
     // This is needed for why-not to resolve conflicts from an uninstalled version against installed packages.
     if (!$repository->findPackage($needle, $textConstraint)) {
         $defaultRepos = new CompositeRepository(RepositoryFactory::defaultRepos($this->getIO()));
         if ($match = $defaultRepos->findPackage($needle, $textConstraint)) {
             $repository->addRepository(new ArrayRepository(array(clone $match)));
         }
     }
     // Include replaced packages for inverted lookups as they are then the actual starting point to consider
     $needles = array($needle);
     if ($inverted) {
         foreach ($packages as $package) {
             $needles = array_merge($needles, array_map(function (Link $link) {
                 return $link->getTarget();
             }, $package->getReplaces()));
         }
     }
     // Parse constraint if one was supplied
     if ('*' !== $textConstraint) {
         $versionParser = new VersionParser();
         $constraint = $versionParser->parseConstraints($textConstraint);
     } else {
         $constraint = null;
     }
     // Parse rendering options
     $renderTree = $input->getOption(self::OPTION_TREE);
     $recursive = $renderTree || $input->getOption(self::OPTION_RECURSIVE);
     // Resolve dependencies
     $results = $repository->getDependents($needles, $constraint, $inverted, $recursive);
     if (empty($results)) {
         $extra = null !== $constraint ? sprintf(' in versions %smatching %s', $inverted ? 'not ' : '', $textConstraint) : '';
         $this->getIO()->writeError(sprintf('<info>There is no installed package depending on "%s"%s</info>', $needle, $extra));
     } elseif ($renderTree) {
         $this->initStyles($output);
         $root = $packages[0];
         $this->getIO()->write(sprintf('<info>%s</info> %s %s', $root->getPrettyName(), $root->getPrettyVersion(), $root->getDescription()));
         $this->printTree($results);
     } else {
         $this->printTable($output, $results);
     }
     return 0;
 }
开发者ID:neon64,项目名称:composer,代码行数:68,代码来源:BaseDependencyCommand.php

示例5: selectPackage

 protected function selectPackage(IOInterface $io, $packageName, $version = null)
 {
     $io->write('<info>Searching for the specified package.</info>');
     if ($composer = $this->getComposer(false)) {
         $localRepo = $composer->getRepositoryManager()->getLocalRepository();
         $repos = new CompositeRepository(array_merge(array($localRepo), $composer->getRepositoryManager()->getRepositories()));
     } else {
         $defaultRepos = Factory::createDefaultRepositories($this->getIO());
         $io->write('No composer.json found in the current directory, searching packages from ' . implode(', ', array_keys($defaultRepos)));
         $repos = new CompositeRepository($defaultRepos);
     }
     $pool = new Pool();
     $pool->addRepository($repos);
     $constraint = $version ? new VersionConstraint('>=', $version) : null;
     $packages = $pool->whatProvides($packageName, $constraint);
     if (count($packages) > 1) {
         $package = $packages[0];
         $io->write('<info>Found multiple matches, selected ' . $package->getPrettyString() . '.</info>');
         $io->write('Alternatives were ' . implode(', ', array_map(function ($p) {
             return $p->getPrettyString();
         }, $packages)) . '.');
         $io->write('<comment>Please use a more specific constraint to pick a different package.</comment>');
     } elseif ($packages) {
         $package = $packages[0];
         $io->write('<info>Found an exact match ' . $package->getPrettyString() . '.</info>');
     } else {
         $io->write('<error>Could not find a package matching ' . $packageName . '.</error>');
         return false;
     }
     return $package;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:31,代码来源:ArchiveCommand.php

示例6: testInjectCoreBundles

 /**
  * Test that the core bundles get correctly injected.
  *
  * @return void
  */
 public function testInjectCoreBundles()
 {
     $inOut = $this->getMock('Composer\\IO\\IOInterface');
     $factory = new Factory();
     $composer = $factory->createComposer($inOut, $this->config);
     $plugin = new Plugin();
     $local = $composer->getRepositoryManager()->getLocalRepository();
     if ($core = $local->findPackages('contao/core')) {
         $this->fail('Contao core has already been injected, found version ' . $core[0]->getVersion());
     }
     $plugin->activate($composer, $inOut);
     if (!($core = $local->findPackages('contao/core'))) {
         $this->fail('Contao core has not been injected.');
     }
     $core = $core[0];
     $constraint = new Constraint('=', $core->getVersion());
     $pool = new Pool('dev');
     $pool->addRepository($local);
     $this->assertNotNull($core = $pool->whatProvides('contao/core', $constraint));
     // bundle names + 'contao-community-alliance/composer-client'
     $this->assertCount(8, $core[0]->getRequires());
     foreach (array('contao/calendar-bundle', 'contao/comments-bundle', 'contao/core-bundle', 'contao/faq-bundle', 'contao/listing-bundle', 'contao/news-bundle', 'contao/newsletter-bundle') as $bundleName) {
         $this->assertNotNull($matches = $pool->whatProvides($bundleName, $constraint));
         $this->assertCount(1, $matches);
         $this->assertEquals('metapackage', $matches[0]->getType());
     }
 }
开发者ID:Jobu,项目名称:core,代码行数:32,代码来源:InjectCoreBundlesTest.php

示例7: findUpdatePackages

 public function findUpdatePackages(Pool $pool, array $installedMap, PackageInterface $package, $mustMatchName = false)
 {
     $packages = array();
     foreach ($pool->whatProvides($package->getName(), null, $mustMatchName) as $candidate) {
         if ($candidate !== $package) {
             $packages[] = $candidate;
         }
     }
     return $packages;
 }
开发者ID:aminembarki,项目名称:composer,代码行数:10,代码来源:DefaultPolicy.php

示例8: findUpdatePackages

 public function findUpdatePackages(Solver $solver, Pool $pool, array $installedMap, PackageInterface $package)
 {
     $packages = array();
     foreach ($pool->whatProvides($package->getName()) as $candidate) {
         if ($candidate !== $package) {
             $packages[] = $candidate;
         }
     }
     return $packages;
 }
开发者ID:nlegoff,项目名称:composer,代码行数:10,代码来源:DefaultPolicy.php

示例9: getPackageMatches

 private function getPackageMatches($repository, $name, $version = null)
 {
     $pool = new Pool('dev');
     $pool->addRepository($repository);
     $constraint = null;
     if ($version) {
         $parser = new VersionParser();
         $constraint = $parser->parseConstraints($version);
     }
     return $pool->whatProvides($name, $constraint);
 }
开发者ID:quickstrap,项目名称:quickstrap,代码行数:11,代码来源:PackageHelper.php

示例10: getPackage

 /**
  * finds a package by name
  *
  * @param  RepositoryInterface $repos
  * @param  string              $name
  * @return CompletePackageInterface
  */
 protected function getPackage(RepositoryInterface $repos, $name)
 {
     $name = strtolower($name);
     $pool = new Pool('dev');
     $pool->addRepository($repos);
     $matches = $pool->whatProvides($name);
     foreach ($matches as $index => $package) {
         // skip providers/replacers
         if ($package->getName() !== $name) {
             unset($matches[$index]);
             continue;
         }
         return $package;
     }
 }
开发者ID:composer-fork,项目名称:composer,代码行数:22,代码来源:HomeCommand.php

示例11: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $composer = $this->getComposer();
     $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'depends', $input, $output);
     $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
     $repo = new CompositeRepository(array(new ArrayRepository(array($composer->getPackage())), $composer->getRepositoryManager()->getLocalRepository()));
     $needle = $input->getArgument('package');
     $pool = new Pool();
     $pool->addRepository($repo);
     $packages = $pool->whatProvides($needle);
     if (empty($packages)) {
         throw new \InvalidArgumentException('Could not find package "' . $needle . '" in your project.');
     }
     $linkTypes = $this->linkTypes;
     $types = array_map(function ($type) use($linkTypes) {
         $type = rtrim($type, 's');
         if (!isset($linkTypes[$type])) {
             throw new \InvalidArgumentException('Unexpected link type: ' . $type . ', valid types: ' . implode(', ', array_keys($linkTypes)));
         }
         return $type;
     }, $input->getOption('link-type'));
     $messages = array();
     $outputPackages = array();
     $io = $this->getIO();
     /** @var PackageInterface $package */
     foreach ($repo->getPackages() as $package) {
         foreach ($types as $type) {
             /** @var Link $link */
             foreach ($package->{'get' . $linkTypes[$type][0]}() as $link) {
                 if ($link->getTarget() === $needle) {
                     if (!isset($outputPackages[$package->getName()])) {
                         $messages[] = '<info>' . $package->getPrettyName() . '</info> ' . $linkTypes[$type][1] . ' ' . $needle . ' (<info>' . $link->getPrettyConstraint() . '</info>)';
                         $outputPackages[$package->getName()] = true;
                     }
                 }
             }
         }
     }
     if ($messages) {
         sort($messages);
         $io->write($messages);
     } else {
         $io->writeError('<info>There is no installed package depending on "' . $needle . '".</info>');
     }
 }
开发者ID:hanovruslan,项目名称:composer,代码行数:45,代码来源:DependsCommand.php

示例12: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $repos = $this->getComposer()->getRepositoryManager()->getLocalRepositories();
     $needle = $input->getArgument('package');
     $pool = new Pool();
     foreach ($repos as $repo) {
         $pool->addRepository($repo);
     }
     $packages = $pool->whatProvides($needle);
     if (empty($packages)) {
         throw new \InvalidArgumentException('Could not find package "' . $needle . '" in your project.');
     }
     $linkTypes = $this->linkTypes;
     $verbose = (bool) $input->getOption('verbose');
     $types = array_map(function ($type) use($linkTypes) {
         $type = rtrim($type, 's');
         if (!isset($linkTypes[$type])) {
             throw new \InvalidArgumentException('Unexpected link type: ' . $type . ', valid types: ' . implode(', ', array_keys($linkTypes)));
         }
         return $type;
     }, $input->getOption('link-type'));
     $dependsOnPackages = false;
     foreach ($repos as $repo) {
         $repo->filterPackages(function ($package) use($needle, $types, $linkTypes, $output, $verbose, &$dependsOnPackages) {
             static $outputPackages = array();
             foreach ($types as $type) {
                 foreach ($package->{'get' . $linkTypes[$type]}() as $link) {
                     if ($link->getTarget() === $needle) {
                         $dependsOnPackages = true;
                         if ($verbose) {
                             $output->writeln($package->getPrettyName() . ' ' . $package->getPrettyVersion() . ' <info>' . $type . '</info> ' . $link->getPrettyConstraint());
                         } elseif (!isset($outputPackages[$package->getName()])) {
                             $output->writeln($package->getPrettyName());
                             $outputPackages[$package->getName()] = true;
                         }
                     }
                 }
             }
         });
     }
     if (!$dependsOnPackages) {
         $output->writeln('<info>There is no installed package depending on "' . $needle . '".</info>');
     }
 }
开发者ID:nickelc,项目名称:composer,代码行数:44,代码来源:DependsCommand.php

示例13: matchesCakeVersion

 /**
  * Check if CakePHP version matches against a version
  *
  * @param string $matcher
  * @param string $version
  * @return bool
  */
 protected function matchesCakeVersion($matcher, $version)
 {
     $repositoryManager = $this->composer->getRepositoryManager();
     if ($repositoryManager) {
         $repos = $repositoryManager->getLocalRepository();
         if (!$repos) {
             return false;
         }
         $cake3 = new MultiConstraint(array(new VersionConstraint($matcher, $version), new VersionConstraint('!=', '9999999-dev')));
         $pool = new Pool('dev');
         $pool->addRepository($repos);
         $packages = $pool->whatProvides('cakephp/cakephp');
         foreach ($packages as $package) {
             $installed = new VersionConstraint('=', $package->getVersion());
             if ($cake3->matches($installed)) {
                 return true;
                 break;
             }
         }
     }
     return false;
 }
开发者ID:grBro,项目名称:taskmanager,代码行数:29,代码来源:CakePHPInstaller.php

示例14: getLocations

 /**
  * Change the default plugin location when cakephp >= 3.0
  */
 public function getLocations()
 {
     $repositoryManager = $this->composer->getRepositoryManager();
     if ($repositoryManager) {
         $repos = $repositoryManager->getLocalRepository();
         if (!$repos) {
             return $this->locations;
         }
         $cake3 = new MultiConstraint(array(new VersionConstraint('>=', '3.0.0'), new VersionConstraint('!=', '9999999-dev')));
         $pool = new Pool('dev');
         $pool->addRepository($repos);
         $packages = $pool->whatProvides('cakephp/cakephp');
         foreach ($packages as $package) {
             $installed = new VersionConstraint('=', $package->getVersion());
             if ($cake3->matches($installed)) {
                 $this->locations['plugin'] = 'plugins/{$name}/';
                 break;
             }
         }
     }
     return $this->locations;
 }
开发者ID:buonzz,项目名称:youthere-ci,代码行数:25,代码来源:CakePHPInstaller.php

示例15: package

 public function package($info)
 {
     preg_match('{^(?<name>.*)\\$(?<hash>.*)\\.json$}i', $info, $matches);
     $hash = $matches['hash'];
     $name = $matches['name'];
     $filename = 'p/hash/' . substr($hash, 0, 2) . '/' . substr($hash, 2, 2) . '/' . hash('sha256', $hash . $name) . '.json';
     if (!Storage::has($filename)) {
         $repos = $this->getRepos();
         $installedRepo = new CompositeRepository($repos);
         $pool = new Pool('dev');
         $pool->addRepository($installedRepo);
         $matches = $pool->whatProvides($name, null);
         if (!$matches) {
             return '{}';
         } else {
             $match = $matches[0];
             $repo = $match->getRepository();
             $ref = new \ReflectionProperty($repo, 'providersUrl');
             $ref->setAccessible(true);
             $providersUrl = $ref->getValue($repo);
             $ref = new \ReflectionProperty($repo, 'cache');
             $ref->setAccessible(true);
             $cache = $ref->getValue($repo);
             $url = str_replace(array('%package%', '%hash%'), array($name, $hash), $providersUrl);
             $cacheKey = 'provider-' . strtr($name, '/', '$') . '.json';
             if ($cache->sha256($cacheKey) === $hash) {
                 $packages = $cache->read($cacheKey);
             }
             if (!isset($packages) && empty($packages)) {
                 throw new Exception("Cache should exists, please report this issue on github", 1);
             }
             Storage::put($filename, $packages);
         }
     }
     return Storage::get($filename);
 }
开发者ID:garveen,项目名称:imagist-old,代码行数:36,代码来源:ProxyController.php


注:本文中的Composer\DependencyResolver\Pool::whatProvides方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。