Bladeren bron

[Locale] minor cosmetical tweaks to the pre-escaped regExp

Igor Wiedler 14 jaren geleden
bovenliggende
commit
a5f8411eff

+ 3 - 1
src/Symfony/Component/Locale/Stub/DateFormat/FullTransformer.php

@@ -101,6 +101,8 @@ class FullTransformer
     {
         $that = $this;
 
+        $escapedPattern = preg_quote($pattern, '/');
+
         $reverseMatchingRegExp = preg_replace_callback($this->regExp, function($matches) use ($that) {
             $length = strlen($matches[0]);
             $transformerIndex = $matches[0][0];
@@ -112,7 +114,7 @@ class FullTransformer
                 $captureName = str_repeat($transformerIndex, $length);
                 return "(?P<$captureName>" . $transformer->getReverseMatchingRegExp($length) . ')';
             }
-        }, preg_quote($pattern, '/'));
+        }, $escapedPattern);
 
         return $reverseMatchingRegExp;
     }

+ 1 - 0
tests/Symfony/Tests/Component/Locale/Stub/StubIntlDateFormatterTest.php

@@ -532,6 +532,7 @@ class StubIntlDateFormatterTest extends LocaleTestCase
 
             // regExp metachars in the pattern string
             array('y[M-d', '1970[1-1', 0),
+            array('y[M/d', '1970[1/1', 0),
         );
     }