From: fabien Date: Sat, 10 Oct 2009 08:21:45 +0000 (+0000) Subject: added type hinting to render() and display() method X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=cdda9ab744356d40ee83d94e1b6562034f63f91a;p=konrad%2Ftwig.git added type hinting to render() and display() method git-svn-id: http://svn.twig-project.org/trunk@13 93ef8e89-cb99-4229-a87c-7fa0fa45744b --- diff --git a/lib/Twig/Node/Module.php b/lib/Twig/Node/Module.php index 90abdb4..86ba64e 100644 --- a/lib/Twig/Node/Module.php +++ b/lib/Twig/Node/Module.php @@ -116,7 +116,7 @@ class Twig_Node_Module extends Twig_Node implements Twig_NodeListInterface $compiler ->write(" extends ".$compiler->getEnvironment()->getBaseTemplateClass()."\n", "{\n") ->indent() - ->write("public function display(\$context)\n", "{\n") + ->write("public function display(array \$context)\n", "{\n") ->indent() ; diff --git a/lib/Twig/Template.php b/lib/Twig/Template.php index 6154385..43a4918 100644 --- a/lib/Twig/Template.php +++ b/lib/Twig/Template.php @@ -20,8 +20,12 @@ abstract class Twig_Template implements Twig_TemplateInterface /** * Renders the template with the given context and returns it as string. + * + * @param array $context An array of parameters to pass to the template + * + * @return string The rendered template */ - public function render($context) + public function render(array $context) { ob_start(); $this->display($context); diff --git a/lib/Twig/TemplateInterface.php b/lib/Twig/TemplateInterface.php index ac69fbd..dafe5a9 100644 --- a/lib/Twig/TemplateInterface.php +++ b/lib/Twig/TemplateInterface.php @@ -10,9 +10,26 @@ */ interface Twig_TemplateInterface { - public function render($context); + /** + * Renders the template with the given context and returns it as string. + * + * @param array $context An array of parameters to pass to the template + * + * @return string The rendered template + */ + public function render(array $context); - public function display($context); + /** + * Displays the template with the given context. + * + * @param array $context An array of parameters to pass to the template + */ + public function display(array $context); + /** + * Returns the bound environment for this template. + * + * @return Twig_Environment The current environment + */ public function getEnvironment(); }