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


PHP PEAR_Common::getDependencyTypes方法代码示例

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


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

示例1: validate

 /**
  * Validate XML package definition file.
  *
  * @access public
  * @return boolean
  */
 function validate($state = PEAR_VALIDATE_NORMAL, $nofilechecking = false)
 {
     if (($this->_isValid & $state) == $state) {
         return true;
     }
     $this->_isValid = true;
     $info = $this->_packageInfo;
     if (empty($info['package'])) {
         $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_NAME);
         $this->_packageName = $pn = 'unknown';
     } else {
         $this->_packageName = $pn = $info['package'];
     }
     if (empty($info['summary'])) {
         $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_SUMMARY);
     } elseif (strpos(trim($info['summary']), "\n") !== false) {
         $this->_validateWarning(PEAR_PACKAGEFILE_ERROR_MULTILINE_SUMMARY, array('summary' => $info['summary']));
     }
     if (empty($info['description'])) {
         $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_DESCRIPTION);
     }
     if (empty($info['release_license'])) {
         $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_LICENSE);
     }
     if (empty($info['version'])) {
         $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_VERSION);
     }
     if (empty($info['release_state'])) {
         $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_STATE);
     }
     if (empty($info['release_date'])) {
         $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_DATE);
     }
     if (empty($info['release_notes'])) {
         $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_NOTES);
     }
     if (empty($info['maintainers'])) {
         $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_MAINTAINERS);
     } else {
         $haslead = false;
         $i = 1;
         foreach ($info['maintainers'] as $m) {
             if (empty($m['handle'])) {
                 $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_MAINTHANDLE, array('index' => $i));
             }
             if (empty($m['role'])) {
                 $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_MAINTROLE, array('index' => $i, 'roles' => PEAR_Common::getUserRoles()));
             } elseif ($m['role'] == 'lead') {
                 $haslead = true;
             }
             if (empty($m['name'])) {
                 $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_MAINTNAME, array('index' => $i));
             }
             if (empty($m['email'])) {
                 $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_MAINTEMAIL, array('index' => $i));
             }
             $i++;
         }
         if (!$haslead) {
             $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_LEAD);
         }
     }
     if (!empty($info['release_deps'])) {
         $i = 1;
         foreach ($info['release_deps'] as $d) {
             if (!isset($d['type']) || empty($d['type'])) {
                 $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_DEPTYPE, array('index' => $i, 'types' => PEAR_Common::getDependencyTypes()));
                 continue;
             }
             if (!isset($d['rel']) || empty($d['rel'])) {
                 $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_DEPREL, array('index' => $i, 'rels' => PEAR_Common::getDependencyRelations()));
                 continue;
             }
             if (!empty($d['optional'])) {
                 if (!in_array($d['optional'], array('yes', 'no'))) {
                     $this->_validateError(PEAR_PACKAGEFILE_ERROR_INVALID_DEPOPTIONAL, array('index' => $i, 'opt' => $d['optional']));
                 }
             }
             if ($d['rel'] != 'has' && $d['rel'] != 'not' && empty($d['version'])) {
                 $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_DEPVERSION, array('index' => $i));
             } elseif (($d['rel'] == 'has' || $d['rel'] == 'not') && !empty($d['version'])) {
                 $this->_validateWarning(PEAR_PACKAGEFILE_ERROR_DEPVERSION_IGNORED, array('index' => $i, 'rel' => $d['rel']));
             }
             if ($d['type'] == 'php' && !empty($d['name'])) {
                 $this->_validateWarning(PEAR_PACKAGEFILE_ERROR_DEPNAME_IGNORED, array('index' => $i, 'name' => $d['name']));
             } elseif ($d['type'] != 'php' && empty($d['name'])) {
                 $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_DEPNAME, array('index' => $i));
             }
             if ($d['type'] == 'php' && empty($d['version'])) {
                 $this->_validateError(PEAR_PACKAGEFILE_ERROR_NO_DEPPHPVERSION, array('index' => $i));
             }
             if ($d['rel'] == 'not' && $d['type'] == 'php') {
                 $this->_validateError(PEAR_PACKAGEFILE_PHP_NO_NOT, array('index' => $i));
             }
//.........这里部分代码省略.........
开发者ID:michabbb,项目名称:pear-core,代码行数:101,代码来源:v1.php

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