cvs: pear-core /PEAR Validate.php

From: Date: Wed, 03 Nov 2004 23:45:17 +0000
Subject: cvs: pear-core /PEAR Validate.php
Groups: php.pear.cvs php.pear.core 
Request: Send a blank email to pear-core+get-1226@lists.php.net to get a copy of this message
cellog Wed Nov 3 18:45:17 2004 EDT Modified files: /pear-core/PEAR Validate.php Log: fix validatePackage() http://cvs.php.net/diff.php/pear-core/PEAR/Validate.php?r1=1.24&r2=1.25&ty=u Index: pear-core/PEAR/Validate.php diff -u pear-core/PEAR/Validate.php:1.24 pear-core/PEAR/Validate.php:1.25 --- pear-core/PEAR/Validate.php:1.24 Wed Nov 3 18:00:29 2004 +++ pear-core/PEAR/Validate.php Wed Nov 3 18:45:16 2004 @@ -16,7 +16,7 @@ // | Authors: Gregory Beaver <cellog@php.net> | // +----------------------------------------------------------------------+ // -// $Id: Validate.php,v 1.24 2004/11/03 23:00:29 cellog Exp $ +// $Id: Validate.php,v 1.25 2004/11/03 23:45:16 cellog Exp $ define('PEAR_VALIDATE_INSTALLING', 1); define('PEAR_VALIDATE_UNINSTALLING', 2); // this is not bit-mapped like the others define('PEAR_VALIDATE_NORMAL', 3); @@ -128,7 +128,7 @@ */ function _addFailure($field, $reason) { - $this->_failures['error'] = array('field' => $field, 'reason' => $reason); + $this->_failures['errors'][] = array('field' => $field, 'reason' => $reason); } /** @@ -136,7 +136,7 @@ */ function _addWarning($field, $reason) { - $this->_failures['warning'] = array('field' => $field, 'reason' => $reason); + $this->_failures['warnings'][] = array('field' => $field, 'reason' => $reason); } function getFailures() @@ -178,7 +178,7 @@ //$this->validateGlobalTasks(); $this->validateChangelog(); } - return (bool) count($this->_failures['errors']); + return !((bool) count($this->_failures['errors'])); } /** @@ -190,14 +190,19 @@ $this->_state == PEAR_VALIDATE_NORMAL) { if ($this->_packagexml->getPackagexmlVersion() == '2.0' && $this->_packagexml->getExtends()) { - $vlen = strlen($version = $this->_packagexml->getVersion() . ''); + $version = $this->_packagexml->getVersion() . ''; $name = $this->_packagexml->getPackage(); - if ($name{strlen($name) - $vlen} != $version) { - $this->_addFailure('name', "package $name extends package " . + if ($name{strlen($name) - 1} != $version{0}) { + $this->_addFailure('package', "package $name extends package " . $this->_packagexml->getExtends() . ' and so the name must ' . - 'have a postfix equal to the major version like "' . $name . - $version . '"'); + 'have a postfix equal to the major version like "' . + $this->_packagexml->getExtends() . $version{0} . '"'); return false; + } elseif (substr($name, 0, strlen($name) - 1) != $this->_packagexml->getExtends()) { + $this->_addFailure('package', "package $name extends package " . + $this->_packagexml->getExtends() . ' and so the name must ' . + 'be an extension like "' . $this->_packagexml->getExtends() . + $version{0} . '"'); } } } @@ -214,7 +219,11 @@ function validateVersion() { if ($this->_state != PEAR_VALIDATE_PACKAGING) { - return $this->validVersion($this->_packagexml->getVersion()); + if (!$this->validVersion($this->_packagexml->getVersion())) { + $this->_addFailure('version', + 'Invalid version number "' . $this->_packagexml->getVersion() . '"'); + } + return; } $version = $this->_packagexml->getVersion(); $versioncomponents = explode('.', $version);

« previous php.pear.core (#1226) next »