Skip to content

Commit

Permalink
array_map Variable to Variable::getValue in getTemplateVars.
Browse files Browse the repository at this point in the history
Fixes #994
  • Loading branch information
wisskid committed Apr 13, 2024
1 parent 177a3f4 commit d95c9b4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions 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)
5 changes: 4 additions & 1 deletion src/Data.php
Expand Up @@ -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)
);
}

/**
Expand Down

0 comments on commit d95c9b4

Please sign in to comment.