tweaked an error message
authorFabien Potencier <fabien.potencier@gmail.com>
Wed, 25 Apr 2012 05:00:14 +0000 (07:00 +0200)
committerFabien Potencier <fabien.potencier@gmail.com>
Wed, 25 Apr 2012 05:12:38 +0000 (07:12 +0200)
lib/Twig/Extension/Core.php

index 813261f..301c4bb 100644 (file)
@@ -735,11 +735,11 @@ function twig_in_filter($value, $compare)
  *
  * @param Twig_Environment $env        A Twig_Environment instance
  * @param string           $string     The value to be escaped
- * @param string           $type       The escaping strategy
+ * @param string           $strategy   The escaping strategy
  * @param string           $charset    The charset
  * @param Boolean          $autoescape Whether the function is called by the auto-escaping feature (true) or by the developer (false)
  */
-function twig_escape_filter(Twig_Environment $env, $string, $type = 'html', $charset = null, $autoescape = false)
+function twig_escape_filter(Twig_Environment $env, $string, $strategy = 'html', $charset = null, $autoescape = false)
 {
     if ($autoescape && is_object($string) && $string instanceof Twig_Markup) {
         return $string;
@@ -755,7 +755,7 @@ function twig_escape_filter(Twig_Environment $env, $string, $type = 'html', $cha
 
     $string = (string) $string;
 
-    switch ($type) {
+    switch ($strategy) {
         case 'js':
             // escape all non-alphanumeric characters
             // into their \xHH or \uHHHH representations
@@ -778,7 +778,7 @@ function twig_escape_filter(Twig_Environment $env, $string, $type = 'html', $cha
 
             // Using a static variable to avoid initializing the array
             // each time the function is called. Moving the declaration on the
-            // top of the function slow downs other escaping types.
+            // top of the function slow downs other escaping strategies.
             static $htmlspecialcharsCharsets = array(
                 'iso-8859-1' => true, 'iso8859-1' => true,
                 'iso-8859-15' => true, 'iso8859-15' => true,
@@ -806,7 +806,7 @@ function twig_escape_filter(Twig_Environment $env, $string, $type = 'html', $cha
             return twig_convert_encoding($string, $charset, 'UTF-8');
 
         default:
-            throw new Twig_Error_Runtime(sprintf('Invalid escape type "%s".', $type));
+            throw new Twig_Error_Runtime(sprintf('Invalid escaping strategy "%s" (valid ones: html, js).', $strategy));
     }
 }