Преглед на файлове

[ZF-8903] Zend_Validate:

- allow locale detection on array without locale key
- performance increasement for native types

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@20530 44c647ce-9c0f-0410-b52a-842ac1e357ba
thomas преди 16 години
родител
ревизия
db85a50d38
променени са 5 файла, в които са добавени 31 реда и са изтрити 9 реда
  1. 0 1
      library/Zend/Locale.php
  2. 7 3
      library/Zend/Validate/Float.php
  3. 13 2
      library/Zend/Validate/Iban.php
  4. 10 2
      library/Zend/Validate/Int.php
  5. 1 1
      library/Zend/Validate/PostCode.php

+ 0 - 1
library/Zend/Locale.php

@@ -805,7 +805,6 @@ class Zend_Locale
             }
         }
 
-        require_once 'Zend/Locale.php';
         if ($locale === null) {
             $locale = new Zend_Locale();
         }

+ 7 - 3
library/Zend/Validate/Float.php

@@ -61,11 +61,15 @@ class Zend_Validate_Float extends Zend_Validate_Abstract
             $locale = $locale->toArray();
         }
 
-        if (is_array($locale) && array_key_exists('locale', $locale)) {
-            $locale = $locale['locale'];
+        if (is_array($locale)) {
+            if (array_key_exists('locale', $locale)) {
+                $locale = $locale['locale'];
+            } else {
+                $locale = null;
+            }
         }
 
-        if ($locale === null) {
+        if (empty($locale)) {
             require_once 'Zend/Registry.php';
             if (Zend_Registry::isRegistered('Zend_Locale')) {
                 $locale = Zend_Registry::get('Zend_Locale');

+ 13 - 2
library/Zend/Validate/Iban.php

@@ -115,8 +115,19 @@ class Zend_Validate_Iban extends Zend_Validate_Abstract
             $locale = $locale->toArray();
         }
 
-        if (is_array($locale) && array_key_exists('locale', $locale)) {
-            $locale = $locale['locale'];
+        if (is_array($locale)) {
+            if (array_key_exists('locale', $locale)) {
+                $locale = $locale['locale'];
+            } else {
+                $locale = null;
+            }
+        }
+
+        if (empty($locale)) {
+            require_once 'Zend/Registry.php';
+            if (Zend_Registry::isRegistered('Zend_Locale')) {
+                $locale = Zend_Registry::get('Zend_Locale');
+            }
         }
 
         if ($locale !== null) {

+ 10 - 2
library/Zend/Validate/Int.php

@@ -61,11 +61,15 @@ class Zend_Validate_Int extends Zend_Validate_Abstract
             $locale = $locale->toArray();
         }
 
-        if (is_array($locale) && array_key_exists('locale', $locale)) {
+        if (is_array($locale)) {
+            if (array_key_exists('locale', $locale)) {
                 $locale = $locale['locale'];
+            } else {
+                $locale = null;
+            }
         }
 
-        if ($locale === null) {
+        if (empty($locale)) {
             require_once 'Zend/Registry.php';
             if (Zend_Registry::isRegistered('Zend_Locale')) {
                 $locale = Zend_Registry::get('Zend_Locale');
@@ -112,6 +116,10 @@ class Zend_Validate_Int extends Zend_Validate_Abstract
             return false;
         }
 
+        if (is_int($value)) {
+            return true;
+        }
+
         $this->_setValue($value);
         if ($this->_locale === null) {
             $locale        = localeconv();

+ 1 - 1
library/Zend/Validate/PostCode.php

@@ -77,7 +77,7 @@ class Zend_Validate_PostCode extends Zend_Validate_Abstract
             $options = $options->toArray();
         }
 
-        if (null === $options) {
+        if (empty($options)) {
             require_once 'Zend/Registry.php';
             if (Zend_Registry::isRegistered('Zend_Locale')) {
                 $this->setLocale(Zend_Registry::get('Zend_Locale'));