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


PHP PackageInterface::getStability方法代码示例

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


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

示例1: versionCompare

 public function versionCompare(PackageInterface $a, PackageInterface $b, $operator)
 {
     if ($this->preferStable && ($stabA = $a->getStability()) !== ($stabB = $b->getStability())) {
         return BasePackage::$stabilities[$stabA] < BasePackage::$stabilities[$stabB];
     }
     $constraint = new VersionConstraint($operator, $b->getVersion());
     $version = new VersionConstraint('==', $a->getVersion());
     return $constraint->matchSpecific($version, true);
 }
开发者ID:aminembarki,项目名称:composer,代码行数:9,代码来源:DefaultPolicy.php

示例2: convertPackageVersion

 /**
  * Convert a package version into string representation.
  *
  * @param PackageInterface $package       The package to extract the version from.
  *
  * @param bool             $fullReference Flag if the complete reference shall be added or an abbreviated form.
  *
  * @return string
  *
  * @throws \RuntimeException If the package is a dev package and does not have valid reference information.
  */
 public static function convertPackageVersion(PackageInterface $package, $fullReference = false)
 {
     $version = $package->getPrettyVersion();
     if ('dev' === $package->getStability()) {
         if (null === ($reference = $package->getDistReference())) {
             if (null === ($reference = $package->getSourceReference())) {
                 throw new \RuntimeException('Unable to determine reference for ' . $package->getPrettyName());
             }
         }
         $version .= '#' . (!$fullReference ? substr($reference, 0, 8) : $reference);
     }
     return $version;
 }
开发者ID:tenside,项目名称:core,代码行数:24,代码来源:PackageConverter.php

示例3: findRecommendedRequireVersion

 /**
  * Given a concrete version, this returns a ~ constraint (when possible)
  * that should be used, for example, in composer.json.
  *
  * For example:
  *  * 1.2.1         -> ~1.2
  *  * 1.2           -> ~1.2
  *  * v3.2.1        -> ~3.2
  *  * 2.0-beta.1    -> ~2.0@beta
  *  * dev-master    -> ~2.1@dev      (dev version with alias)
  *  * dev-master    -> dev-master    (dev versions are untouched)
  *
  * @param PackageInterface $package
  * @return string
  */
 public function findRecommendedRequireVersion(PackageInterface $package)
 {
     $version = $package->getVersion();
     if (!$package->isDev()) {
         return $this->transformVersion($version, $package->getPrettyVersion(), $package->getStability());
     }
     $loader = new ArrayLoader($this->getParser());
     $dumper = new ArrayDumper();
     $extra = $loader->getBranchAlias($dumper->dump($package));
     if ($extra) {
         $extra = preg_replace('{^(\\d+\\.\\d+\\.\\d+)(\\.9999999)-dev$}', '$1.0', $extra, -1, $count);
         if ($count) {
             $extra = str_replace('.9999999', '.0', $extra);
             return $this->transformVersion($extra, $extra, 'dev');
         }
     }
     return $package->getPrettyVersion();
 }
开发者ID:composer-fork,项目名称:composer,代码行数:33,代码来源:VersionSelector.php

示例4: find_latest_package

 /**
  * Given a package, this finds the latest package matching it
  *
  * @param  PackageInterface $package
  * @param  Composer         $composer
  * @param  string           $phpVersion
  * @param  bool             $minorOnly
  *
  * @return PackageInterface|null
  */
 private function find_latest_package(PackageInterface $package, Composer $composer, $phpVersion, $minorOnly = false)
 {
     // find the latest version allowed in this pool
     $name = $package->getName();
     $versionSelector = new VersionSelector($this->get_pool($composer));
     $stability = $composer->getPackage()->getMinimumStability();
     $flags = $composer->getPackage()->getStabilityFlags();
     if (isset($flags[$name])) {
         $stability = array_search($flags[$name], BasePackage::$stabilities, true);
     }
     $bestStability = $stability;
     if ($composer->getPackage()->getPreferStable()) {
         $bestStability = $package->getStability();
     }
     $targetVersion = null;
     if (0 === strpos($package->getVersion(), 'dev-')) {
         $targetVersion = $package->getVersion();
     }
     if ($targetVersion === null && $minorOnly) {
         $targetVersion = '^' . $package->getVersion();
     }
     return $versionSelector->findBestCandidate($name, $targetVersion, $phpVersion, $bestStability);
 }
开发者ID:wp-cli,项目名称:wp-cli,代码行数:33,代码来源:package.php

示例5: match

 /**
  * Checks if the package matches the given constraint directly or through
  * provided or replaced packages
  *
  * @param  array|PackageInterface $candidate
  * @param  string                 $name       Name of the package to be matched
  * @param  ConstraintInterface    $constraint The constraint to verify
  * @return int                    One of the MATCH* constants of this class or 0 if there is no match
  */
 private function match($candidate, $name, ConstraintInterface $constraint = null)
 {
     $candidateName = $candidate->getName();
     $candidateVersion = $candidate->getVersion();
     $isDev = $candidate->getStability() === 'dev';
     $isAlias = $candidate instanceof AliasPackage;
     if (!$isDev && !$isAlias && isset($this->filterRequires[$name])) {
         $requireFilter = $this->filterRequires[$name];
     } else {
         $requireFilter = new EmptyConstraint();
     }
     if ($candidateName === $name) {
         $pkgConstraint = new Constraint('==', $candidateVersion);
         if ($constraint === null || $constraint->matches($pkgConstraint)) {
             return $requireFilter->matches($pkgConstraint) ? self::MATCH : self::MATCH_FILTERED;
         }
         return self::MATCH_NAME;
     }
     $provides = $candidate->getProvides();
     $replaces = $candidate->getReplaces();
     // aliases create multiple replaces/provides for one target so they can not use the shortcut below
     if (isset($replaces[0]) || isset($provides[0])) {
         foreach ($provides as $link) {
             if ($link->getTarget() === $name && ($constraint === null || $constraint->matches($link->getConstraint()))) {
                 return $requireFilter->matches($link->getConstraint()) ? self::MATCH_PROVIDE : self::MATCH_FILTERED;
             }
         }
         foreach ($replaces as $link) {
             if ($link->getTarget() === $name && ($constraint === null || $constraint->matches($link->getConstraint()))) {
                 return $requireFilter->matches($link->getConstraint()) ? self::MATCH_REPLACE : self::MATCH_FILTERED;
             }
         }
         return self::MATCH_NONE;
     }
     if (isset($provides[$name]) && ($constraint === null || $constraint->matches($provides[$name]->getConstraint()))) {
         return $requireFilter->matches($provides[$name]->getConstraint()) ? self::MATCH_PROVIDE : self::MATCH_FILTERED;
     }
     if (isset($replaces[$name]) && ($constraint === null || $constraint->matches($replaces[$name]->getConstraint()))) {
         return $requireFilter->matches($replaces[$name]->getConstraint()) ? self::MATCH_REPLACE : self::MATCH_FILTERED;
     }
     return self::MATCH_NONE;
 }
开发者ID:zqcloveping,项目名称:pagekit,代码行数:51,代码来源:Pool.php

示例6: getStability

 /**
  * {@inheritdoc}
  */
 public function getStability()
 {
     return $this->package->getStability();
 }
开发者ID:tenside,项目名称:core,代码行数:7,代码来源:VersionedPackage.php

示例7: getDrupalCoreVersion

 /**
  * Returns the Drupal core version for the given package.
  *
  * @param \Composer\Package\PackageInterface $drupalCorePackage
  *
  * @return string
  */
 protected function getDrupalCoreVersion(PackageInterface $drupalCorePackage)
 {
     $version = $drupalCorePackage->getPrettyVersion();
     if ($drupalCorePackage->getStability() == 'dev' && substr($version, -4) == '-dev') {
         $version = substr($version, 0, -4);
         return $version;
     }
     return $version;
 }
开发者ID:drupal-composer,项目名称:drupal-scaffold,代码行数:16,代码来源:Handler.php


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