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) + ); } /**