Skip to content
Permalink
Browse files

Fix #54: Prevent scope collisions when rendering a view template

  • Loading branch information...
samdark committed Sep 20, 2019
1 parent d13ea0e commit 8d9f5ea2770835c05b49281a6ee53bbf24428a1d
Showing with 4 additions and 4 deletions.
  1. +4 −4 src/View/PhpTemplateRenderer.php
@@ -5,16 +5,16 @@ class PhpTemplateRenderer implements TemplateRendererInterface
{
public function render(View $view, string $template, array $params): string
{
$renderer = function () use ($template, $params) {
extract($params, EXTR_OVERWRITE);
require $template;
$renderer = function () {
extract(func_get_arg(1), EXTR_OVERWRITE);
require func_get_arg(0);
};
$obInitialLevel = ob_get_level();
ob_start();
ob_implicit_flush(0);
try {
$renderer->bindTo($view)();
$renderer->bindTo($view)($template, $params);
return ob_get_clean();
} catch (\Throwable $e) {
while (ob_get_level() > $obInitialLevel) {

0 comments on commit 8d9f5ea

Please sign in to comment.
You can’t perform that action at this time.