From c5d351dcd27867db1b6d7f995b081eb0b61110ca Mon Sep 17 00:00:00 2001 From: Jeremy Marc Date: Fri, 26 Oct 2012 15:30:04 -0700 Subject: [PATCH] cast $name to string ($name can be an object implementing __toString function) --- lib/Twig/Loader/Chain.php | 2 ++ lib/Twig/Loader/Filesystem.php | 3 +++ 2 files changed, 5 insertions(+), 0 deletions(-) diff --git a/lib/Twig/Loader/Chain.php b/lib/Twig/Loader/Chain.php index 1ab1853..da61aca 100644 --- a/lib/Twig/Loader/Chain.php +++ b/lib/Twig/Loader/Chain.php @@ -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]; } diff --git a/lib/Twig/Loader/Filesystem.php b/lib/Twig/Loader/Filesystem.php index b201428..8748e3d 100644 --- a/lib/Twig/Loader/Filesystem.php +++ b/lib/Twig/Loader/Filesystem.php @@ -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, '\\', '/')); -- 1.7.2.5