Kaynağa Gözat

[ZF-9202] Zend_Filter:

- change options handling to allow extension (thnx Ramon for tests)

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@21085 44c647ce-9c0f-0410-b52a-842ac1e357ba
thomas 16 yıl önce
ebeveyn
işleme
cdd2f64686

+ 7 - 2
library/Zend/Filter/PregReplace.php

@@ -89,11 +89,16 @@ class Zend_Filter_PregReplace implements Zend_Filter_Interface
         if ($options instanceof Zend_Config) {
         if ($options instanceof Zend_Config) {
             $options = $options->toArray();
             $options = $options->toArray();
         } else if (!is_array($options)) {
         } else if (!is_array($options)) {
-            $options       = func_get_args();
-            $temp['match'] = array_shift($options);
+            $options = func_get_args();
+            $temp    = array();
+            if (!empty($options)) {
+                $temp['match'] = array_shift($options);
+            }
+
             if (!empty($options)) {
             if (!empty($options)) {
                 $temp['replace'] = array_shift($options);
                 $temp['replace'] = array_shift($options);
             }
             }
+
             $options = $temp;
             $options = $temp;
         }
         }
 
 

+ 18 - 0
tests/Zend/Filter/PregReplaceTest.php

@@ -130,6 +130,24 @@ class Zend_Filter_PregReplaceTest extends PHPUnit_Framework_TestCase
         } catch (Exception $e) {
         } catch (Exception $e) {
         }
         }
     }
     }
+
+    /**
+      * @group ZF-9202
+      */
+    public function testExtendsPregReplace()
+    {
+        $startMatchPattern = '~(>){3,}~i';
+        $filter = new XPregReplace();
+        $this->assertEquals($startMatchPattern, $filter->getMatchPattern());
+    }
+}
+
+/**
+ * @group ZF-9202
+ */
+class XPregReplace extends Zend_Filter_PregReplace
+{
+    protected $_matchPattern = '~(>){3,}~i';
 }
 }
 
 
 // Call Zend_Filter_PregReplaceTest::main() if this source file is executed directly.
 // Call Zend_Filter_PregReplaceTest::main() if this source file is executed directly.