cast $name to string ($name can be an object implementing __toString function)
authorJeremy Marc <jeremy.marc@me.com>
Fri, 26 Oct 2012 22:30:04 +0000 (15:30 -0700)
committerJeremy Marc <jeremy.marc@me.com>
Fri, 26 Oct 2012 22:30:04 +0000 (15:30 -0700)
lib/Twig/Loader/Chain.php
lib/Twig/Loader/Filesystem.php

index 1ab1853..da61aca 100644 (file)
@@ -70,6 +70,8 @@ class Twig_Loader_Chain implements Twig_LoaderInterface, Twig_ExistsLoaderInterf
      */
     public function exists($name)
     {
+        $name = (string) $name;
+
         if (isset($this->hasSourceCache[$name])) {
             return $this->hasSourceCache[$name];
         }
index b201428..8748e3d 100644 (file)
@@ -139,6 +139,7 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI
      */
     public function exists($name)
     {
+        $name = (string) $name;
         if (isset($this->cache[$name])) {
             return true;
         }
@@ -162,6 +163,8 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI
 
     protected function findTemplate($name)
     {
+        $name = (string) $name;
+
         // normalize name
         $name = preg_replace('#/{2,}#', '/', strtr($name, '\\', '/'));