From d95c9b48508226ba61c322f0d8ad35068b793d11 Mon Sep 17 00:00:00 2001 From: Simon Wisselink Date: Sat, 13 Apr 2024 10:43:21 +0200 Subject: [PATCH] array_map Variable to Variable::getValue in getTemplateVars. Fixes #994 --- changelog/994.md | 1 + src/Data.php | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 changelog/994.md diff --git a/changelog/994.md b/changelog/994.md new file mode 100644 index 000000000..16c58c517 --- /dev/null +++ b/changelog/994.md @@ -0,0 +1 @@ +- Fix that getTemplateVars would return an array of objects instead of the assigned variables values [#994](https://github.com/smarty-php/smarty/issues/994) \ No newline at end of file diff --git a/src/Data.php b/src/Data.php index 64a4770ec..f8abe0f6d 100644 --- a/src/Data.php +++ b/src/Data.php @@ -224,7 +224,10 @@ public function getTemplateVars($varName = null, $searchParents = true) return $this->getValue($varName, $searchParents); } - return array_merge($this->parent && $searchParents ? $this->parent->getTemplateVars() : [], $this->tpl_vars); + return array_merge( + $this->parent && $searchParents ? $this->parent->getTemplateVars() : [], + array_map(function(Variable $var) { return $var->getValue(); }, $this->tpl_vars) + ); } /**