Cleanup code

This commit is contained in:
Giuseppe Criscione 2019-05-30 15:13:14 +02:00
parent e7c80c422b
commit 4ab20712a1
2 changed files with 3 additions and 16 deletions

View File

@ -6,13 +6,6 @@ use Closure;
class Renderer
{
/**
* Renderer instance
*
* @var Renderer
*/
protected static $instance;
/**
* Load a script passing variables and binding to given instance and context
*
@ -25,10 +18,7 @@ class Renderer
*/
public static function load($filename, array $vars, $instance, $context = null)
{
if (is_null(static::$instance)) {
static::$instance = new static();
}
$closure = static::$instance->getClosure($instance, $context);
$closure = static::getClosure($instance, $context);
return $closure($filename, $vars);
}
@ -40,7 +30,7 @@ class Renderer
*
* @return Closure
*/
protected function getClosure($instance, $context = null)
protected static function getClosure($instance, $context = null)
{
return Closure::bind(function ($_filename, array $_vars) {
extract($_vars);

View File

@ -36,7 +36,7 @@ class TemplateHelpers
* @param string $name
* @param callable $helper
*/
public static function add($name, $helper)
public static function add($name, callable $helper)
{
if (static::has($name)) {
throw new RuntimeException('Template helper ' . $name . ' is already defined');
@ -44,9 +44,6 @@ class TemplateHelpers
if (method_exists(Template::class, $name)) {
throw new LogicException('Template helpers must not conflict with ' . Template::class . ' methods. Invalid name ' . $name);
}
if (!is_callable($helper)) {
throw new LogicException('Template helper ' . $name . ' must be callable');
}
static::$helpers[$name] = $helper;
}