fix image text
[pear] / Validate.php
index 8d00680..f235ef3 100644 (file)
@@ -216,7 +216,7 @@ class Validate
      *
      * @access private
      */
-    function __uriRFC4151($uri)
+    static function __uriRFC4151($uri)
     {
         $datevalid = false;
         if (preg_match(
@@ -257,7 +257,7 @@ class Validate
      *
      * @access public
      */
-    function number($number, $options = array())
+    static function number($number, $options = array())
     {
         $decimal = $dec_prec = $min = $max = null;
         if (is_array($options)) {
@@ -295,7 +295,7 @@ class Validate
      *
      * @access  private
      */
-    function __stringToUtf7($string)
+    static function __stringToUtf7($string)
     {
         $return = '';
         $utf7   = array(
@@ -373,7 +373,7 @@ class Validate
      *
      * @access private
      */
-    function __emailRFC822(&$email, &$options)
+    static function __emailRFC822(&$email, &$options)
     {
         static $address   = null;
         static $uncomment = null;
@@ -442,7 +442,7 @@ class Validate
      *
      * @return bool True if validating succeeds
      */
-    function _fullTLDValidation($email, $options)
+    static function _fullTLDValidation($email, $options)
     {
         $validate = array();
         if(!empty($options["VALIDATE_ITLD_EMAILS"])) array_push($validate, 'itld');
@@ -477,7 +477,7 @@ class Validate
      *
      * @return true or false (Depending on if it validates or if it does not)
      */
-    function executeFullEmailValidation($email, $arrayOfTLDs)
+    static function executeFullEmailValidation($email, $arrayOfTLDs)
     {
         $emailEnding = explode('.', $email);
         $emailEnding = $emailEnding[count($emailEnding)-1];
@@ -512,7 +512,7 @@ class Validate
      *
      * @access public
      */
-    function email($email, $options = null)
+    static  function email($email, $options = null)
     {
         static $dom_cache = array();
         $check_domain = false;
@@ -580,7 +580,8 @@ class Validate
         if ($use_rfc822? Validate::__emailRFC822($email, $options) :
                 preg_match($regex, $email)) {
             if ($check_domain && function_exists('checkdnsrr')) {
-                $domain = preg_replace('/[^-a-z.0-9]/i', '', array_pop(explode('@', $email)));
+                $em = explode('@', $email);
+                $domain = preg_replace('/[^-a-z.0-9]/i', '', array_pop($em));
                 
                 if (isset($dom_cache[$domain])) {
                     return $dom_cache[$domain];
@@ -612,7 +613,7 @@ class Validate
      *
      * @access public
      */
-    function string($string, $options)
+    static  function string($string, $options)
     {
         $format     = null;
         $min_length = 0;
@@ -674,7 +675,7 @@ class Validate
      *
      * @access public
      */
-    function uri($url, $options = null)
+    static function uri($url, $options = null)
     {
         $strict = ';/?:@$,';
         $domain_check = false;
@@ -750,7 +751,7 @@ class Validate
      *
      * @access public
      */
-    function date($date, $options)
+    public static function date($date, $options)
     {
         $max    = false;
         $min    = false;
@@ -793,9 +794,9 @@ class Validate
         } else {
             $date_len = strlen($format);
             for ($i = 0; $i < $date_len; $i++) {
-                $c = $format{$i};
+                $c = $format[$i];
                 if ($c == '%') {
-                    $next = $format{$i + 1};
+                    $next = $format[$i + 1];
                     switch ($next) {
                     case 'j':
                     case 'd':
@@ -933,7 +934,7 @@ class Validate
      * @access private
      * @return string
      */
-    function _substr(&$date, $num, $opt = false)
+    static function _substr(&$date, $num, $opt = false)
     {
         if ($opt && strlen($date) >= $opt && preg_match('/^[0-9]{'.$opt.'}/', $date, $m)) {
             $ret = $m[0];
@@ -944,7 +945,7 @@ class Validate
         return $ret;
     }
 
-    function _modf($val, $div)
+    static function _modf($val, $div)
     {
         if (function_exists('bcmod')) {
             return bcmod($val, $div);
@@ -966,7 +967,7 @@ class Validate
      *
      * @return int returns product of number digits with weights
      */
-    function _multWeights($number, &$weights)
+    static function _multWeights($number, &$weights)
     {
         if (!is_array($weights)) {
             return -1;
@@ -997,7 +998,7 @@ class Validate
      *
      * @return  int -1 calculated control number is returned
      */
-    function _getControlNumber($number, &$weights, $modulo = 10, $subtract = 0, $allow_high = false)
+    static function _getControlNumber($number, &$weights, $modulo = 10, $subtract = 0, $allow_high = false)
     {
         // calc sum
         $sum = Validate::_multWeights($number, $weights);
@@ -1027,7 +1028,7 @@ class Validate
      *
      * @return  bool true if valid, false if not
      */
-    function _checkControlNumber($number, &$weights, $modulo = 10, $subtract = 0)
+    static function _checkControlNumber($number, &$weights, $modulo = 10, $subtract = 0)
     {
         if (strlen($number) < count($weights)) {
             return false;
@@ -1064,7 +1065,7 @@ class Validate
      *
      * @access public
      */
-    function multiple(&$data, &$val_type, $remove = false)
+    static function multiple(&$data, &$val_type, $remove = false)
     {
         $keys  = array_keys($data);
         $valid = array();
@@ -1137,15 +1138,17 @@ class Validate
      *
      * @return bool true if file exists
      */
-    function _includePathFileExists($filename)
+    static function _includePathFileExists($filename)
     {
         $paths = explode(":", ini_get("include_path"));
         $result = false;
-
-        while ((!($result)) && (list($key,$val) = each($paths))) {
+        foreach($paths as $key => $val) {
             $result = file_exists($val . "/" . $filename);
+            if ($result) {
+                return $return;
+            }
         }
-        return $result;
+        return false;
     }
 }