diff --git a/lib/Twig/Loader/Array.php b/lib/Twig/Loader/Array.php index 436edd816..854afd1ec 100644 --- a/lib/Twig/Loader/Array.php +++ b/lib/Twig/Loader/Array.php @@ -45,7 +45,7 @@ class Twig_Loader_Array implements Twig_LoaderInterface, Twig_ExistsLoaderInterf */ public function setTemplate($name, $template) { - $this->templates[(string) $name] = $template; + $this->templates[$name] = $template; } /** @@ -53,7 +53,6 @@ class Twig_Loader_Array implements Twig_LoaderInterface, Twig_ExistsLoaderInterf */ public function getSource($name) { - $name = (string) $name; if (!isset($this->templates[$name])) { throw new Twig_Error_Loader(sprintf('Template "%s" is not defined.', $name)); } @@ -66,7 +65,7 @@ class Twig_Loader_Array implements Twig_LoaderInterface, Twig_ExistsLoaderInterf */ public function exists($name) { - return isset($this->templates[(string) $name]); + return isset($this->templates[$name]); } /** @@ -74,7 +73,6 @@ class Twig_Loader_Array implements Twig_LoaderInterface, Twig_ExistsLoaderInterf */ public function getCacheKey($name) { - $name = (string) $name; if (!isset($this->templates[$name])) { throw new Twig_Error_Loader(sprintf('Template "%s" is not defined.', $name)); } @@ -87,7 +85,6 @@ class Twig_Loader_Array implements Twig_LoaderInterface, Twig_ExistsLoaderInterf */ public function isFresh($name, $time) { - $name = (string) $name; if (!isset($this->templates[$name])) { throw new Twig_Error_Loader(sprintf('Template "%s" is not defined.', $name)); } diff --git a/lib/Twig/Loader/Chain.php b/lib/Twig/Loader/Chain.php index 2445259e8..fe76c2fb0 100644 --- a/lib/Twig/Loader/Chain.php +++ b/lib/Twig/Loader/Chain.php @@ -68,8 +68,6 @@ 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 dc8a1dca4..9c048cbbc 100644 --- a/lib/Twig/Loader/Filesystem.php +++ b/lib/Twig/Loader/Filesystem.php @@ -212,6 +212,11 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI return false; } + protected function normalizeName($name) + { + return preg_replace('#/{2,}#', '/', strtr($name, '\\', '/')); + } + protected function parseName($name, $default = self::MAIN_NAMESPACE) { if (isset($name[0]) && '@' == $name[0]) { @@ -228,11 +233,6 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI return array($default, $name); } - protected function normalizeName($name) - { - return preg_replace('#/{2,}#', '/', strtr((string) $name, '\\', '/')); - } - protected function validateName($name) { if (false !== strpos($name, "\0")) { diff --git a/test/Twig/Tests/Loader/ArrayTest.php b/test/Twig/Tests/Loader/ArrayTest.php index 1369a6bd0..ae7648ffd 100644 --- a/test/Twig/Tests/Loader/ArrayTest.php +++ b/test/Twig/Tests/Loader/ArrayTest.php @@ -68,30 +68,4 @@ class Twig_Tests_Loader_ArrayTest extends PHPUnit_Framework_TestCase $loader->isFresh('foo', time()); } - - public function testTemplateReference() - { - $name = new Twig_Test_Loader_TemplateReference('foo'); - $loader = new Twig_Loader_Array(array('foo' => 'bar')); - - $loader->getCacheKey($name); - $loader->getSource($name); - $loader->isFresh($name, time()); - $loader->setTemplate($name, 'foobar'); - } -} - -class Twig_Test_Loader_TemplateReference -{ - private $name; - - public function __construct($name) - { - $this->name = $name; - } - - public function __toString() - { - return $this->name; - } }