diff --git a/src/Handlebars/Helpers.php b/src/Handlebars/Helpers.php index d430038..56c5f06 100755 --- a/src/Handlebars/Helpers.php +++ b/src/Handlebars/Helpers.php @@ -583,19 +583,21 @@ private function extractSlice(string $string): array */ private function parseArgs(Context $context, string $args): array { - $args = preg_replace('/\s+/', ' ', trim($args)); - $eles = explode(' ', $args); - foreach ($eles as $key => $ele) { - if (in_array(substr($ele, 0, 1), ['\'', '"'])) { - $val = trim($ele, '\'"'); - } else if (is_numeric($ele)) { - $val = $ele; + $args = preg_split('/\s+/', trim($args)); + + foreach ($args as $idx => $el) { + if (in_array(substr($el, 0, 1), ["'", '"'])) { + $val = trim($el, '\'"'); + } elseif (is_numeric($el)) { + $val = $el; } else { - $val = $context->get($ele); + /** @var scalar|null $val */ + $val = $context->get($el); } - $eles[$key] = $val; + + $args[$idx] = $val; } - return $eles; + return $args; } }