cvs: pear /Validate Validate.php
| From: | Helgi �ormar �orbj�rnsson | Date: | Thu, 13 Apr 2006 23:29:28 +0000 |
| Subject: | cvs: pear /Validate Validate.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-39606@lists.php.net to get a copy of this message | ||
dufuz Thu Apr 13 23:29:28 2006 UTC
Modified files:
/pear/Validate Validate.php
Log:
class_exists fix now works with PHP 4
http://cvs.php.net/viewcvs.cgi/pear/Validate/Validate.php?r1=1.77&r2=1.78&diff_format=u
Index: pear/Validate/Validate.php
diff -u pear/Validate/Validate.php:1.77 pear/Validate/Validate.php:1.78
--- pear/Validate/Validate.php:1.77 Thu Apr 13 22:55:33 2006
+++ pear/Validate/Validate.php Thu Apr 13 23:29:28 2006
@@ -32,14 +32,14 @@
* @author Pierre-Alain Joye <pajoye@php.net>
* @copyright 1997-2005 Pierre-Alain Joye,Tomas V.V.Cox
* @license http://www.opensource.org/licenses/bsd-license.php
New BSD License
- * @version CVS: $Id: Validate.php,v 1.77 2006/04/13 22:55:33 dufuz Exp $
+ * @version CVS: $Id: Validate.php,v 1.78 2006/04/13 23:29:28 dufuz Exp $
* @link http://pear.php.net/package/Validate
*/
/**
* Methods for common data validations
*/
-define('VALIDATE_NUM', '0-9');
+efine('VALIDATE_NUM', '0-9');
define('VALIDATE_SPACE', '\s');
define('VALIDATE_ALPHA_LOWER', 'a-z');
define('VALIDATE_ALPHA_UPPER', 'A-Z');
@@ -583,21 +583,23 @@
$method = array_pop($validateType);
$class = implode('_', $validateType);
$classPath = str_replace('_', DIRECTORY_SEPARATOR, $class);
+ $class = 'Validate_' . $class;
if (!@include_once "Validate/$classPath.php") {
- trigger_error("Validate_$class isn't installed or you may have some
permissoin issues", E_USER_ERROR);
+ trigger_error("$class isn't installed or you may have some permissoin
issues", E_USER_ERROR);
}
- if (!class_exists('Validate_' . $class, false) ||
- !in_array($method, get_class_methods("Validate_$class")))
+ $ce = substr(phpversion(), 0, 1) > 4 ? class_exists($class, false) :
class_exists($class);
+ if (!$ce ||
+ !in_array($method, get_class_methods($class)))
{
- trigger_error("Invalid validation type Validate_$class::$method",
E_USER_WARNING);
+ trigger_error("Invalid validation type $class::$method",
E_USER_WARNING);
continue;
}
unset($opt['type']);
if (sizeof($opt) == 1) {
$opt = array_pop($opt);
}
- $valid[$var_name] = call_user_func(array("Validate_$class", $method),
$data[$var_name], $opt);
+ $valid[$var_name] = call_user_func(array($class, $method), $data[$var_name], $opt);
} else {
trigger_error("Invalid validation type {$opt['type']}",
E_USER_WARNING);
}