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


PHP PEAR_Common::getReleaseStates方法代碼示例

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


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

示例1: validatePackageInfo

 /**
  * Validate XML package definition file.
  *
  * @param  string $info Filename of the package archive or of the
  *                package definition file
  * @param  array $errors Array that will contain the errors
  * @param  array $warnings Array that will contain the warnings
  * @param  string $dir_prefix (optional) directory where source files
  *                may be found, or empty if they are not available
  * @access public
  * @return boolean
  */
 function validatePackageInfo($info, &$errors, &$warnings, $dir_prefix = '')
 {
     if (PEAR::isError($info = $this->infoFromAny($info))) {
         return $this->raiseError($info);
     }
     if (!is_array($info)) {
         return false;
     }
     $errors = array();
     $warnings = array();
     if (!isset($info['package'])) {
         $errors[] = 'missing package name';
     } elseif (!$this->validPackageName($info['package'])) {
         $errors[] = 'invalid package name';
     }
     $this->_packageName = $pn = $info['package'];
     if (empty($info['summary'])) {
         $errors[] = 'missing summary';
     } elseif (strpos(trim($info['summary']), "\n") !== false) {
         $warnings[] = 'summary should be on a single line';
     }
     if (empty($info['description'])) {
         $errors[] = 'missing description';
     }
     if (empty($info['release_license'])) {
         $errors[] = 'missing license';
     }
     if (!isset($info['version'])) {
         $errors[] = 'missing version';
     } elseif (!$this->validPackageVersion($info['version'])) {
         $errors[] = 'invalid package version';
     }
     if (empty($info['release_state'])) {
         $errors[] = 'missing release state';
     } elseif (!in_array($info['release_state'], PEAR_Common::getReleaseStates())) {
         $errors[] = "invalid release state `{$info['release_state']}', should be one of: " . implode(' ', PEAR_Common::getReleaseStates());
     }
     if (empty($info['release_date'])) {
         $errors[] = 'missing release date';
     } elseif (!preg_match('/^\\d{4}-\\d\\d-\\d\\d$/', $info['release_date'])) {
         $errors[] = "invalid release date `{$info['release_date']}', format is YYYY-MM-DD";
     }
     if (empty($info['release_notes'])) {
         $errors[] = "missing release notes";
     }
     if (empty($info['maintainers'])) {
         $errors[] = 'no maintainer(s)';
     } else {
         $i = 1;
         foreach ($info['maintainers'] as $m) {
             if (empty($m['handle'])) {
                 $errors[] = "maintainer {$i}: missing handle";
             }
             if (empty($m['role'])) {
                 $errors[] = "maintainer {$i}: missing role";
             } elseif (!in_array($m['role'], PEAR_Common::getUserRoles())) {
                 $errors[] = "maintainer {$i}: invalid role `{$m['role']}', should be one of: " . implode(' ', PEAR_Common::getUserRoles());
             }
             if (empty($m['name'])) {
                 $errors[] = "maintainer {$i}: missing name";
             }
             if (empty($m['email'])) {
                 $errors[] = "maintainer {$i}: missing email";
             }
             $i++;
         }
     }
     if (!empty($info['deps'])) {
         $i = 1;
         foreach ($info['deps'] as $d) {
             if (empty($d['type'])) {
                 $errors[] = "dependency {$i}: missing type";
             } elseif (!in_array($d['type'], PEAR_Common::getDependencyTypes())) {
                 $errors[] = "dependency {$i}: invalid type, should be one of: " . implode(' ', PEAR_Common::getDependencyTypes());
             }
             if (empty($d['rel'])) {
                 $errors[] = "dependency {$i}: missing relation";
             } elseif (!in_array($d['rel'], PEAR_Common::getDependencyRelations())) {
                 $errors[] = "dependency {$i}: invalid relation, should be one of: " . implode(' ', PEAR_Common::getDependencyRelations());
             }
             if (!empty($d['optional'])) {
                 if (!in_array($d['optional'], array('yes', 'no'))) {
                     $errors[] = "dependency {$i}: invalid relation optional attribute, should be one of: yes no";
                 }
             }
             if ($d['rel'] != 'has' && empty($d['version'])) {
                 $warnings[] = "dependency {$i}: missing version";
             } elseif ($d['rel'] == 'has' && !empty($d['version'])) {
//.........這裏部分代碼省略.........
開發者ID:hendricson,項目名稱:couponator,代碼行數:101,代碼來源:Common.php


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