forked from Wavyzz/dolibarr
Complete #33605 by adding phpunit tests
This commit is contained in:
@@ -11973,23 +11973,34 @@ function dolExplodeKeepIfQuotes($input)
|
||||
preg_match_all('/"([^"]*)"|\'([^\']*)\'|(\S+)/', $input, $matches);
|
||||
|
||||
// Merge result and delete empty values
|
||||
return array_filter(array_map(
|
||||
|
||||
$result = array_map(
|
||||
/**
|
||||
* Return first non-empty item, or empty string
|
||||
*
|
||||
* @param string $a Possibly empty item - match ""
|
||||
* @param string $b Possibly empty item - match ''
|
||||
* @param string $c Non empty string if $a and $b are empty
|
||||
*
|
||||
* @param string $a Matched value in double quotes
|
||||
* @param string $b Matched value in single quotes
|
||||
* @param string $c Unquoted value
|
||||
* @return string
|
||||
*/
|
||||
static function ($a, $b, $c) {
|
||||
return $a ?: ($b ?: $c);
|
||||
if ($a !== '') return $a;
|
||||
if ($b !== '') return $b;
|
||||
if ($c !== '') return $c;
|
||||
return '';
|
||||
},
|
||||
$matches[1],
|
||||
$matches[2],
|
||||
$matches[3]
|
||||
));
|
||||
);
|
||||
return array_values(array_filter($result,
|
||||
/**
|
||||
* Filter out empty strings from the result array.
|
||||
*
|
||||
* @param string $val The value to check.
|
||||
* @return bool True if the value is not an empty string.
|
||||
*/
|
||||
static function ($val) {
|
||||
return $val !== '';
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user