From ac23cd7ae413733da78cd1337efe8a58c990145a Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Wed, 4 Sep 2013 01:09:57 +0200 Subject: [PATCH] simplify loader constructors --- lib/Twig/Loader/Array.php | 7 ++----- lib/Twig/Loader/Chain.php | 3 +-- lib/Twig/Loader/Filesystem.php | 4 ++-- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/lib/Twig/Loader/Array.php b/lib/Twig/Loader/Array.php index 89087ae..ac56104 100644 --- a/lib/Twig/Loader/Array.php +++ b/lib/Twig/Loader/Array.php @@ -21,7 +21,7 @@ */ class Twig_Loader_Array implements Twig_LoaderInterface, Twig_ExistsLoaderInterface { - protected $templates; + protected $templates = array(); /** * Constructor. @@ -32,10 +32,7 @@ class Twig_Loader_Array implements Twig_LoaderInterface, Twig_ExistsLoaderInterf */ public function __construct(array $templates) { - $this->templates = array(); - foreach ($templates as $name => $template) { - $this->templates[$name] = $template; - } + $this->templates = $templates; } /** diff --git a/lib/Twig/Loader/Chain.php b/lib/Twig/Loader/Chain.php index 1f1cf06..7919eda 100644 --- a/lib/Twig/Loader/Chain.php +++ b/lib/Twig/Loader/Chain.php @@ -17,7 +17,7 @@ class Twig_Loader_Chain implements Twig_LoaderInterface, Twig_ExistsLoaderInterface { private $hasSourceCache = array(); - protected $loaders; + protected $loaders = array(); /** * Constructor. @@ -26,7 +26,6 @@ class Twig_Loader_Chain implements Twig_LoaderInterface, Twig_ExistsLoaderInterf */ public function __construct(array $loaders = array()) { - $this->loaders = array(); foreach ($loaders as $loader) { $this->addLoader($loader); } diff --git a/lib/Twig/Loader/Filesystem.php b/lib/Twig/Loader/Filesystem.php index 5ce13dd..23bac47 100644 --- a/lib/Twig/Loader/Filesystem.php +++ b/lib/Twig/Loader/Filesystem.php @@ -19,8 +19,8 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI /** Identifier of the main namespace. */ const MAIN_NAMESPACE = '__main__'; - protected $paths; - protected $cache; + protected $paths = array(); + protected $cache = array(); /** * Constructor. -- 1.7.2.5