當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。