summaryrefslogtreecommitdiff
path: root/pear/PEAR
diff options
context:
space:
mode:
authorGreg Beaver <cellog@php.net>2003-10-31 22:53:20 +0000
committerGreg Beaver <cellog@php.net>2003-10-31 22:53:20 +0000
commit6d0360204d1d14f7c1ce9cbc282a50d66edc3281 (patch)
treef0f9962b794d20592ca8e2787b2e923412d694f3 /pear/PEAR
parent5d0cc088054b70dd2d527c430178bf4dde78b047 (diff)
downloadphp-git-6d0360204d1d14f7c1ce9cbc282a50d66edc3281.tar.gz
better error messages, fix potential problems in the future
Diffstat (limited to 'pear/PEAR')
-rw-r--r--pear/PEAR/Dependency.php22
1 files changed, 15 insertions, 7 deletions
diff --git a/pear/PEAR/Dependency.php b/pear/PEAR/Dependency.php
index 12b2dffaef..cd62573841 100644
--- a/pear/PEAR/Dependency.php
+++ b/pear/PEAR/Dependency.php
@@ -27,6 +27,9 @@ define('PEAR_DEPENDENCY_UPGRADE_MINOR', -3);
define('PEAR_DEPENDENCY_UPGRADE_MAJOR', -4);
define('PEAR_DEPENDENCY_BAD_DEPENDENCY', -5);
define('PEAR_DEPENDENCY_MISSING_OPTIONAL', -6);
+define('PEAR_DEPENDENCY_CONFLICT_OPTIONAL', -7);
+define('PEAR_DEPENDENCY_UPGRADE_MINOR_OPTIONAL', -8);
+define('PEAR_DEPENDENCY_UPGRADE_MAJOR_OPTIONAL', -9);
/**
* Dependency check for PEAR packages
@@ -156,10 +159,11 @@ class PEAR_Dependency
if (!$this->registry->packageExists($name)
|| !version_compare("$version", "$req", $relation))
{
- $code = $this->codeFromRelation($relation, $version, $req);
+ $code = $this->codeFromRelation($relation, $version, $req, $opt);
if ($opt) {
- $errmsg = "package `$name' version $req is recommended to utilize some features.";
- return PEAR_DEPENDENCY_MISSING_OPTIONAL;
+ $errmsg = "package `$name' version " . $this->signOperator($relation) .
+ " $req is recommended to utilize some features. Installed version is $version";
+ return $code;
}
$errmsg = "requires package `$name' " .
$this->signOperator($relation) . " $req";
@@ -425,9 +429,10 @@ class PEAR_Dependency
* @param string Relation
* @param string Version
* @param string Requirement
+ * @param bool Optional dependency indicator
* @return integer
*/
- function codeFromRelation($relation, $version, $req)
+ function codeFromRelation($relation, $version, $req, $opt = false)
{
$code = PEAR_DEPENDENCY_BAD_DEPENDENCY;
switch ($relation) {
@@ -436,13 +441,16 @@ class PEAR_Dependency
$have_major = preg_replace('/\D.*/', '', $version);
$need_major = preg_replace('/\D.*/', '', $req);
if ($need_major > $have_major) {
- $code = PEAR_DEPENDENCY_UPGRADE_MAJOR;
+ $code = $opt ? PEAR_DEPENDENCY_UPGRADE_MAJOR_OPTIONAL :
+ PEAR_DEPENDENCY_UPGRADE_MAJOR;
} else {
- $code = PEAR_DEPENDENCY_UPGRADE_MINOR;
+ $code = $opt ? PEAR_DEPENDENCY_UPGRADE_MINOR_OPTIONAL :
+ PEAR_DEPENDENCY_UPGRADE_MINOR;
}
break;
case 'lt': case 'le': case 'ne':
- $code = PEAR_DEPENDENCY_CONFLICT;
+ $code = $opt ? PEAR_DEPENDENCY_CONFLICT_OPTIONAL :
+ PEAR_DEPENDENCY_CONFLICT;
break;
}
return $code;