cvs: php4 /pear/PEAR Dependency.php

From: Date: Sun, 21 Jul 2002 07:18:50 +0000
Subject: cvs: php4 /pear/PEAR Dependency.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-5240@lists.php.net to get a copy of this message
ssb Sun Jul 21 03:18:50 2002 EDT Modified files: /php4/pear/PEAR Dependency.php Log: * support "zend" dependency type Index: php4/pear/PEAR/Dependency.php diff -u php4/pear/PEAR/Dependency.php:1.13 php4/pear/PEAR/Dependency.php:1.14 --- php4/pear/PEAR/Dependency.php:1.13 Wed Jun 19 19:38:46 2002 +++ php4/pear/PEAR/Dependency.php Sun Jul 21 03:18:49 2002 @@ -17,7 +17,7 @@ // | Stig Bakken <ssb@fast.no> | // +----------------------------------------------------------------------+ // -// $Id: Dependency.php,v 1.13 2002/06/19 23:38:46 cox Exp $ +// $Id: Dependency.php,v 1.14 2002/07/21 07:18:49 ssb Exp $ /** * Methods for dependencies check. Based on Stig's dependencies RFC @@ -48,12 +48,7 @@ function callCheckMethod($opts) { $rel = isset($opts['rel']) ? $opts['rel'] : 'has'; - if (isset($opts['version'])) { - $req = $opts['version']; - $rel = 'v.' . $rel; - } else { - $req = null; - } + $req = isset($opts['version']) ? $opts['version'] : null; $name = isset($opts['name']) ? $opts['name'] : null; switch ($opts['type']) { case 'pkg': @@ -74,6 +69,9 @@ case 'sapi': return $this->checkSAPI($name); break; + case 'zend': + return $this->checkZend($name); + break; default: return "'{$opts['type']}' dependency type not supported"; } @@ -90,7 +88,7 @@ */ function checkPackage($name, $req = null, $relation = 'has') { - if (substr($relation, 0, 2) == "v.") { + if (substr($relation, 0, 2) == 'v.') { $relation = substr($relation, 2); } switch ($relation) { @@ -179,7 +177,7 @@ * * @return mixed bool false if no error or the error string */ - function checkPHP($req, $relation = 'v.ge') + function checkPHP($req, $relation = 'ge') { if (substr($relation, 0, 2) == 'v.') { $php_ver = phpversion(); @@ -239,10 +237,32 @@ return "'$sapi_backend' SAPI backend not supported"; } + /** - * Converts text comparing operators to them sign equivalents - * ex: 'ge' to '>=' - */ + * Zend version check method + * + * @param string $req which version to compare + * @param string $relation how to compare the version + * + * @return mixed bool false if no error or the error string + */ + function checkZend($req, $relation = 'ge') + { + if (substr($relation, 0, 2) == 'v.') { + $zend_ver = zend_version(); + $operator = substr($relation, 2); + if (!version_compare("$zend_ver", "$req", $operator)) { + return "Zend version " . $this->signOperator($operator) . + " $req is required"; + } + } + return false; + } + + /** + * Converts text comparing operators to them sign equivalents + * ex: 'ge' to '>=' + */ function signOperator($operator) { switch($operator) {

« previous php.pear.cvs (#5240) next »