Skip to content

Commit 5e8b369

Browse files
committed
Stop Leaking
- Wrap the include in a new scope to stop the leak of Response and this.
1 parent 2e25cde commit 5e8b369

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/PHPRenderer.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,14 @@ public function render(ResponseInterface $response, $template, array $data = [])
5858
throw new \RuntimeException("View cannot render `$template` because the template does not exist");
5959
}
6060

61-
extract($data);
61+
$render = function ($template, $data) {
62+
extract($data);
63+
include $template;
64+
}
6265

6366
ob_start();
64-
include $this->templatePath . $template;
65-
$output = ob_get_clean();
67+
$render($this->templatePath . $template, $data);
68+
$output = ob_get_clean();
6669

6770
return $response->getBody()->write($output);
6871
}

0 commit comments

Comments
 (0)