From: Miha Vrhovnik Date: Tue, 17 Jan 2012 18:22:20 +0000 (+0100) Subject: cast $name to a string as $name can in fact be an object implementing __toString... X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=95f8af773e533f98ae085a6c7cc78a7db28770ec;p=web%2Fkonrad%2Ftwig.git cast $name to a string as $name can in fact be an object implementing __toString function as true in my case. --- diff --git a/lib/Twig/Template.php b/lib/Twig/Template.php index 86ca5c6..d824d08 100644 --- a/lib/Twig/Template.php +++ b/lib/Twig/Template.php @@ -98,6 +98,8 @@ abstract class Twig_Template implements Twig_TemplateInterface */ public function displayParentBlock($name, array $context, array $blocks = array()) { + $name = (string) $name; + if (isset($this->traits[$name])) { $this->traits[$name][0]->displayBlock($name, $context, $blocks); } elseif (false !== $parent = $this->getParent($context)) { @@ -119,6 +121,8 @@ abstract class Twig_Template implements Twig_TemplateInterface */ public function displayBlock($name, array $context, array $blocks = array()) { + $name = (string) $name; + if (isset($blocks[$name])) { $b = $blocks; unset($b[$name]); @@ -189,7 +193,7 @@ abstract class Twig_Template implements Twig_TemplateInterface */ public function hasBlock($name) { - return isset($this->blocks[$name]); + return isset($this->blocks[(string) $name]); } /**