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


PHP PEAR_PackageFile::getExtends方法代碼示例

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


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

示例1: validateVersion

 /**
  * @access protected
  */
 function validateVersion()
 {
     if ($this->_state != PEAR_VALIDATE_PACKAGING) {
         if (!$this->validVersion($this->_packagexml->getVersion())) {
             $this->_addFailure('version', 'Invalid version number "' . $this->_packagexml->getVersion() . '"');
         }
         return false;
     }
     $version = $this->_packagexml->getVersion();
     $versioncomponents = explode('.', $version);
     if (count($versioncomponents) != 3) {
         $this->_addWarning('version', 'A version number should have 3 decimals (x.y.z)');
         return true;
     }
     $name = $this->_packagexml->getPackage();
     // version must be based upon state
     switch ($this->_packagexml->getState()) {
         case 'snapshot':
             return true;
         case 'devel':
             if ($versioncomponents[0] . 'a' == '0a') {
                 return true;
             }
             if ($versioncomponents[0] == 0) {
                 $versioncomponents[0] = '0';
                 $this->_addWarning('version', 'version "' . $version . '" should be "' . implode('.', $versioncomponents) . '"');
             } else {
                 $this->_addWarning('version', 'packages with devel stability must be < version 1.0.0');
             }
             return true;
             break;
         case 'alpha':
         case 'beta':
             // check for a package that extends a package,
             // like Foo and Foo2
             if (!$this->_packagexml->getExtends()) {
                 if ($versioncomponents[0] == '1') {
                     if ($versioncomponents[2][0] == '0') {
                         if ($versioncomponents[2] == '0') {
                             // version 1.*.0000
                             $this->_addWarning('version', 'version 1.' . $versioncomponents[1] . '.0 probably should not be alpha or beta');
                             return true;
                         } elseif (strlen($versioncomponents[2]) > 1) {
                             // version 1.*.0RC1 or 1.*.0beta24 etc.
                             return true;
                         } else {
                             // version 1.*.0
                             $this->_addWarning('version', 'version 1.' . $versioncomponents[1] . '.0 probably should not be alpha or beta');
                             return true;
                         }
                     } else {
                         $this->_addWarning('version', 'bugfix versions (1.3.x where x > 0) probably should ' . 'not be alpha or beta');
                         return true;
                     }
                 } elseif ($versioncomponents[0] != '0') {
                     $this->_addWarning('version', 'major versions greater than 1 are not allowed for packages ' . 'without an <extends> tag or an identical postfix (foo2 v2.0.0)');
                     return true;
                 }
                 if ($versioncomponents[0] . 'a' == '0a') {
                     return true;
                 }
                 if ($versioncomponents[0] == 0) {
                     $versioncomponents[0] = '0';
                     $this->_addWarning('version', 'version "' . $version . '" should be "' . implode('.', $versioncomponents) . '"');
                 }
             } else {
                 $vlen = strlen($versioncomponents[0] . '');
                 $majver = substr($name, strlen($name) - $vlen);
                 while ($majver && !is_numeric($majver[0])) {
                     $majver = substr($majver, 1);
                 }
                 if ($versioncomponents[0] != 0 && $majver != $versioncomponents[0]) {
                     $this->_addWarning('version', 'first version number "' . $versioncomponents[0] . '" must match the postfix of ' . 'package name "' . $name . '" (' . $majver . ')');
                     return true;
                 }
                 if ($versioncomponents[0] == $majver) {
                     if ($versioncomponents[2][0] == '0') {
                         if ($versioncomponents[2] == '0') {
                             // version 2.*.0000
                             $this->_addWarning('version', "version {$majver}." . $versioncomponents[1] . '.0 probably should not be alpha or beta');
                             return false;
                         } elseif (strlen($versioncomponents[2]) > 1) {
                             // version 2.*.0RC1 or 2.*.0beta24 etc.
                             return true;
                         } else {
                             // version 2.*.0
                             $this->_addWarning('version', "version {$majver}." . $versioncomponents[1] . '.0 cannot be alpha or beta');
                             return true;
                         }
                     } else {
                         $this->_addWarning('version', "bugfix versions ({$majver}.x.y where y > 0) should " . 'not be alpha or beta');
                         return true;
                     }
                 } elseif ($versioncomponents[0] != '0') {
                     $this->_addWarning('version', "only versions 0.x.y and {$majver}.x.y are allowed for alpha/beta releases");
                     return true;
                 }
//.........這裏部分代碼省略.........
開發者ID:vojtajina,項目名稱:sitellite,代碼行數:101,代碼來源:Validate.php


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