From 1fe897985a4bc4af0b431ef6934f65626a5b1f5d Mon Sep 17 00:00:00 2001 From: iricketson Date: Sat, 30 Dec 2023 14:26:31 -0700 Subject: [PATCH] Fix(deprecation) preg_match_all requires string parameter (#298) --- lib/util/sfToolkit.class.php | 2 +- test/unit/util/sfToolkitTest.php | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) 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');