cvs: pear-core /PEAR Validate.php
| From: | Greg Beaver | Date: | Fri, 10 Sep 2004 19:08:03 +0000 |
| Subject: | cvs: pear-core /PEAR Validate.php | ||
| Groups: | php.pear.cvs php.pear.core | ||
| Request: | Send a blank email to pear-cvs+get-23796@lists.php.net to get a copy of this message | ||
cellog Fri Sep 10 15:08:03 2004 EDT
Modified files:
/pear-core/PEAR Validate.php
Log:
tweaking of version number validation
1.3.0beta1 is allowed
1.3.1beta1 is not allowed (bugfix release is always stable)
1.x.0 must be stable
extends is now used for new major versions
<name extends="PHPUnit">PHPUnit2</name>
http://cvs.php.net/diff.php/pear-core/PEAR/Validate.php?r1=1.5&r2=1.6&ty=u
Index: pear-core/PEAR/Validate.php
diff -u pear-core/PEAR/Validate.php:1.5 pear-core/PEAR/Validate.php:1.6
--- pear-core/PEAR/Validate.php:1.5 Fri Sep 10 12:22:03 2004
+++ pear-core/PEAR/Validate.php Fri Sep 10 15:08:02 2004
@@ -16,7 +16,7 @@
// | Authors: Gregory Beaver <cellog@php.net> |
// +----------------------------------------------------------------------+
//
-// $Id: Validate.php,v 1.5 2004/09/10 16:22:03 cellog Exp $
+// $Id: Validate.php,v 1.6 2004/09/10 19:08:02 cellog Exp $
define('PEAR_VALIDATE_INSTALLING', 1);
define('PEAR_VALIDATE_NORMAL', 3);
define('PEAR_VALIDATE_PACKAGING', 7);
@@ -69,11 +69,17 @@
$this->_failures['warning'] = array('field' => $field,
'reason' => $reason);
}
- function validate()
+ /**
+ * @param int one of the PEAR_VALIDATE_* constants
+ */
+ function validate($state = null)
{
if (!isset($this->_packagexml)) {
return false;
}
+ if ($state !== null) {
+ $this->_state = $state;
+ }
}
function validatePackageName()
@@ -89,7 +95,8 @@
$version = $this->_packagexml->getVersion();
$versioncomponents = explode('.', $version);
if (count($versioncomponents) != 3) {
- $this->_addFailure('version', 'Must have 3 decimals (x.y.z) in a
version number');
+ $this->_addFailure('version',
+ 'Must have 3 decimals (x.y.z) in a version number');
return false;
}
$name = $this->_packagexml->getPackage();
@@ -104,39 +111,58 @@
break;
case 'alpha' :
case 'beta' :
- // check for Package2 version 2.0.0
- if ($name{strlen($name) - 1} != $versioncomponents[0]) {
+ // check for a package that extends a package,
+ // like Foo and Foo2
+ if ($this->_packagexml->getExtends()) {
if ($versioncomponents[0] == '1') {
- if ($versioncomponents[1] == '0' && $versioncomponents[2]{0}
== '0') {
+ if ($versioncomponents[2]{0} == '0') {
if (strlen($versioncomponents[2]) > 1) {
+ // version 1.*.0RC1 or 1.*.0beta24 etc.
return true;
} else {
- $this->_addFailure('version', 'version 1.0.0 cannot
be alpha or beta');
+ // version 1.*.0
+ $this->_addFailure('version',
+ 'version 1.' . $versioncomponents[1] .
+ '.0 cannot be alpha or beta');
return false;
}
} else {
- $this->_addFailure('version', 'versions greater than
1.0.0 cannot be alpha or beta');
+ $this->_addFailure('version',
+ 'bugfix versions (1.3.x where x > 0) cannot be alpha or
beta');
return false;
}
} else {
- $this->_addFailure('version', 'major versions greater than 1
are not allowed for packages ' .
+ $this->_addFailure('version',
+ 'major versions greater than 1 are not allowed for packages ' .
'not containing an identical postfix');
}
} else {
- if ($versioncomponents[1] == '0'&& $versioncomponents[2]{0} ==
'0') {
+ $vlen = strlen($versioncomponents[0] . '');
+ if ($name{strlen($name) - $vlen} != $versioncomponents[0]) {
+ $this->_addFailure('version', 'first version number
"' .
+ $versioncomponents[0] . '" must match the postfix of ' .
+ 'package name "' . $name . '" (' .
+ $name{strlen($name) - $vlen} . ')');
+ return false;
+ }
+ if ($versioncomponents[2]{0} == '0') {
if (strlen($versioncomponents[2]) > 1) {
+ // version 2.*.0RC1 etc.
return true;
} else {
- $this->_addFailure('version', 'version ' .
$versioncomponents[0] . '.0.0 cannot be alpha or beta');
+ // version 2.*.0
+ $this->_addFailure('version', 'version ' .
+ $versioncomponents[0] . '.0.0 cannot be alpha or beta');
return false;
}
- } else {
- $this->_addFailure('version', 'versions greater than ' .
$versioncomponents[0] .
- '.0.0 cannot be alpha or beta');
- return false;
}
}
case 'stable' :
+ if ($versioncomponents[0] == '0') {
+ $this->_addFailure('version', 'versions less than 1.0 cannot
' .
+ 'be stable');
+ return false;
+ }
return true;
break;
default :