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


PHP ArrayRepository::findPackages方法代码示例

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


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

示例1: testFindPackages

 public function testFindPackages()
 {
     $repo = new ArrayRepository();
     $repo->addPackage($this->getPackage('foo', '1'));
     $repo->addPackage($this->getPackage('bar', '2'));
     $repo->addPackage($this->getPackage('bar', '3'));
     $foo = $repo->findPackages('foo');
     $this->assertCount(1, $foo);
     $this->assertEquals('foo', $foo[0]->getName());
     $bar = $repo->findPackages('bar');
     $this->assertCount(2, $bar);
     $this->assertEquals('bar', $bar[0]->getName());
 }
开发者ID:neon64,项目名称:composer,代码行数:13,代码来源:ArrayRepositoryTest.php

示例2: findPackages

 /**
  * {@inheritDoc}
  */
 public function findPackages($name, $constraint = null)
 {
     if (!$this->hasProviders()) {
         return parent::findPackages($name, $constraint);
     }
     // normalize name
     $name = strtolower($name);
     if (null !== $constraint && !$constraint instanceof ConstraintInterface) {
         $versionParser = new VersionParser();
         $constraint = $versionParser->parseConstraints($constraint);
     }
     $packages = array();
     foreach ($this->getProviderNames() as $providerName) {
         if ($name === $providerName) {
             $candidates = $this->whatProvides(new Pool('dev'), $providerName);
             foreach ($candidates as $package) {
                 if ($name === $package->getName()) {
                     $pkgConstraint = new Constraint('==', $package->getVersion());
                     if (null === $constraint || $constraint->matches($pkgConstraint)) {
                         $packages[] = $package;
                     }
                 }
             }
             break;
         }
     }
     return $packages;
 }
开发者ID:detain,项目名称:composer,代码行数:31,代码来源:ComposerRepository.php

示例3: findPackages

 public function findPackages($name, $version = null)
 {
     if (!$this->hasProviders()) {
         return parent::findPackages($name, $version);
     }
     $name = strtolower($name);
     if (null !== $version) {
         $versionParser = new VersionParser();
         $version = $versionParser->normalize($version);
     }
     $packages = array();
     foreach ($this->getProviderNames() as $providerName) {
         if ($name === $providerName) {
             $packages = $this->whatProvides(new Pool('dev'), $providerName);
             foreach ($packages as $package) {
                 if ($name == $package->getName() && (null === $version || $version === $package->getVersion())) {
                     $packages[] = $package;
                 }
             }
         }
     }
     return $packages;
 }
开发者ID:VicDeo,项目名称:poc,代码行数:23,代码来源:ComposerRepository.php


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