當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Pool::literalToPackage方法代碼示例

本文整理匯總了PHP中Composer\DependencyResolver\Pool::literalToPackage方法的典型用法代碼示例。如果您正苦於以下問題:PHP Pool::literalToPackage方法的具體用法?PHP Pool::literalToPackage怎麽用?PHP Pool::literalToPackage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Composer\DependencyResolver\Pool的用法示例。


在下文中一共展示了Pool::literalToPackage方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getPrettyString

 public function getPrettyString(Pool $pool, array $installedMap = array())
 {
     $ruleText = '';
     foreach ($this->literals as $i => $literal) {
         if ($i != 0) {
             $ruleText .= '|';
         }
         $ruleText .= $pool->literalToPrettyString($literal, $installedMap);
     }
     switch ($this->getReason()) {
         case self::RULE_INTERNAL_ALLOW_UPDATE:
             return $ruleText;
         case self::RULE_JOB_INSTALL:
             return "Install command rule ({$ruleText})";
         case self::RULE_JOB_REMOVE:
             return "Remove command rule ({$ruleText})";
         case self::RULE_PACKAGE_CONFLICT:
             $package1 = $pool->literalToPackage($this->literals[0]);
             $package2 = $pool->literalToPackage($this->literals[1]);
             return $package1->getPrettyString() . ' conflicts with ' . $this->formatPackagesUnique($pool, array($package2)) . '.';
         case self::RULE_PACKAGE_REQUIRES:
             $literals = $this->literals;
             $sourceLiteral = array_shift($literals);
             $sourcePackage = $pool->literalToPackage($sourceLiteral);
             $requires = array();
             foreach ($literals as $literal) {
                 $requires[] = $pool->literalToPackage($literal);
             }
             $text = $this->reasonData->getPrettyString($sourcePackage);
             if ($requires) {
                 $text .= ' -> satisfiable by ' . $this->formatPackagesUnique($pool, $requires) . '.';
             } else {
                 $targetName = $this->reasonData->getTarget();
                 if ($targetName === 'php' || $targetName === 'php-64bit' || $targetName === 'hhvm') {
                     // handle php/hhvm
                     if (defined('HHVM_VERSION')) {
                         return $text . ' -> your HHVM version does not satisfy that requirement.';
                     } elseif ($targetName === 'hhvm') {
                         return $text . ' -> you are running this with PHP and not HHVM.';
                     } else {
                         $packages = $pool->whatProvides($targetName);
                         $package = count($packages) ? current($packages) : phpversion();
                         if (!$package instanceof CompletePackage) {
                             return $text . ' -> your PHP version (' . phpversion() . ') does not satisfy that requirement.';
                         }
                         $extra = $package->getExtra();
                         if (!empty($extra['config.platform'])) {
                             $text .= ' -> your PHP version (' . phpversion() . ') overriden by "config.platform.php" version (' . $package->getPrettyVersion() . ') does not satisfy that requirement.';
                         } else {
                             $text .= ' -> your PHP version (' . $package->getPrettyVersion() . ') does not satisfy that requirement.';
                         }
                         return $text;
                     }
                 } elseif (0 === strpos($targetName, 'ext-')) {
                     // handle php extensions
                     $ext = substr($targetName, 4);
                     $error = extension_loaded($ext) ? 'has the wrong version (' . (phpversion($ext) ?: '0') . ') installed' : 'is missing from your system';
                     return $text . ' -> the requested PHP extension ' . $ext . ' ' . $error . '.';
                 } elseif (0 === strpos($targetName, 'lib-')) {
                     // handle linked libs
                     $lib = substr($targetName, 4);
                     return $text . ' -> the requested linked library ' . $lib . ' has the wrong version installed or is missing from your system, make sure to have the extension providing it.';
                 } else {
                     return $text . ' -> no matching package found.';
                 }
             }
             return $text;
         case self::RULE_PACKAGE_OBSOLETES:
             return $ruleText;
         case self::RULE_INSTALLED_PACKAGE_OBSOLETES:
             return $ruleText;
         case self::RULE_PACKAGE_SAME_NAME:
             return 'Can only install one of: ' . $this->formatPackagesUnique($pool, $this->literals) . '.';
         case self::RULE_PACKAGE_IMPLICIT_OBSOLETES:
             return $ruleText;
         case self::RULE_LEARNED:
             return 'Conclusion: ' . $ruleText;
         case self::RULE_PACKAGE_ALIAS:
             return $ruleText;
         default:
             return '(' . $ruleText . ')';
     }
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:83,代碼來源:Rule.php

示例2: pruneRemoteAliases

 /**
  * Assumes that locally aliased (in root package requires) packages take priority over branch-alias ones
  *
  * If no package is a local alias, nothing happens
  */
 protected function pruneRemoteAliases(Pool $pool, array $literals)
 {
     $hasLocalAlias = false;
     foreach ($literals as $literal) {
         $package = $pool->literalToPackage($literal);
         if ($package instanceof AliasPackage && $package->isRootPackageAlias()) {
             $hasLocalAlias = true;
             break;
         }
     }
     if (!$hasLocalAlias) {
         return $literals;
     }
     $selected = array();
     foreach ($literals as $literal) {
         $package = $pool->literalToPackage($literal);
         if ($package instanceof AliasPackage && $package->isRootPackageAlias()) {
             $selected[] = $literal;
         }
     }
     return $selected;
 }
開發者ID:aminembarki,項目名稱:composer,代碼行數:27,代碼來源:DefaultPolicy.php


注:本文中的Composer\DependencyResolver\Pool::literalToPackage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。