diff --git a/lib/util/sfToolkit.class.php b/lib/util/sfToolkit.class.php index 543440ac0..03d17919a 100644 --- a/lib/util/sfToolkit.class.php +++ b/lib/util/sfToolkit.class.php @@ -254,7 +254,7 @@ public static function stringToArray($string) \s*(?: (?=\w+\s*=) | \s*$ # followed by another key= or the end of the string ) - /x', $string, $matches, PREG_SET_ORDER); + /x', (string) $string, $matches, PREG_SET_ORDER); $attributes = array(); foreach ($matches as $val) { diff --git a/test/unit/util/sfToolkitTest.php b/test/unit/util/sfToolkitTest.php index e40bfc308..6e9032131 100644 --- a/test/unit/util/sfToolkitTest.php +++ b/test/unit/util/sfToolkitTest.php @@ -10,7 +10,7 @@ require_once __DIR__.'/../../bootstrap/unit.php'; -$t = new lime_test(95); +$t = new lime_test(96); // ::stringToArray() $t->diag('::stringToArray()'); @@ -34,6 +34,8 @@ $t->is(sfToolkit::stringToArray($string), $attributes, '->stringToArray()'); } +$t->is(sfToolkit::stringToArray(null), array(), '->stringToArray() can accept a null value'); + // ::isUTF8() $t->diag('::isUTF8()'); $t->is(sfToolkit::isUTF8('été'), true, '::isUTF8() returns true if the parameter is an UTF-8 encoded string');