From 6634f44ca625ff8a49146a334daf25f59a042ce8 Mon Sep 17 00:00:00 2001 From: Amit Snyderman Date: Thu, 5 Sep 2013 14:23:23 -0400 Subject: [PATCH 01/32] Explicitly set timezone to UTC for tests --- test/bootstrap.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/bootstrap.php b/test/bootstrap.php index 91f654a..2399f38 100644 --- a/test/bootstrap.php +++ b/test/bootstrap.php @@ -9,6 +9,8 @@ * file that was distributed with this source code. */ +date_default_timezone_set('UTC'); + require dirname(__FILE__).'/../src/Mustache/Autoloader.php'; Mustache_Autoloader::register(); From 60338e495656f3735b82dc8e44c0c2dbe23cd799 Mon Sep 17 00:00:00 2001 From: Amit Snyderman Date: Thu, 5 Sep 2013 17:07:38 -0400 Subject: [PATCH 02/32] Extract cache interface Refactoring to allow for alternative cache implementations. Includes implementations for the default noop (i.e. un-cached) behavior and a filesystem-based cache whose configuration is consistent with the existing Mustache_Engine constructor. Includes updated and new tests. --- src/Mustache/Cache.php | 7 + src/Mustache/Cache/FilesystemCache.php | 51 +++++++ src/Mustache/Cache/NoopCache.php | 7 + src/Mustache/Engine.php | 141 +++++++----------- .../Test/Cache/FilesystemCacheTest.php | 58 +++++++ test/Mustache/Test/EngineTest.php | 12 +- 6 files changed, 181 insertions(+), 95 deletions(-) create mode 100644 src/Mustache/Cache.php create mode 100644 src/Mustache/Cache/FilesystemCache.php create mode 100644 src/Mustache/Cache/NoopCache.php create mode 100644 test/Mustache/Test/Cache/FilesystemCacheTest.php diff --git a/src/Mustache/Cache.php b/src/Mustache/Cache.php new file mode 100644 index 0000000..a9ab043 --- /dev/null +++ b/src/Mustache/Cache.php @@ -0,0 +1,7 @@ +directory = $directory; + $this->fileMode = $fileMode; + } + + public function get($key) + { + $fileName = $this->getCacheFilename($key); + return (is_file($fileName)) + ? file_get_contents($fileName) + : null; + } + + public function put($key, $value) + { + $fileName = $this->getCacheFilename($key); + $dirName = dirname($fileName); + if (!is_dir($dirName)) { + @mkdir($dirName, 0777, true); + if (!is_dir($dirName)) { + throw new Mustache_Exception_RuntimeException(sprintf('Failed to create cache directory "%s".', $dirName)); + } + + } + + $tempFile = tempnam($dirName, basename($fileName)); + if (false !== @file_put_contents($tempFile, $value)) { + if (@rename($tempFile, $fileName)) { + $mode = isset($this->fileMode) ? $this->fileMode : (0666 & ~umask()); + @chmod($fileName, $mode); + + return; + } + } + + throw new Mustache_Exception_RuntimeException(sprintf('Failed to write cache file "%s".', $fileName)); + } + + protected function getCacheFilename($name) + { + return sprintf('%s/%s.php', $this->directory, md5($name)); + } +} diff --git a/src/Mustache/Cache/NoopCache.php b/src/Mustache/Cache/NoopCache.php new file mode 100644 index 0000000..3d722ab --- /dev/null +++ b/src/Mustache/Cache/NoopCache.php @@ -0,0 +1,7 @@ + '__MyTemplates_', * + * // A Mustache cache instance. Uses a NoopCache if not specified. + * 'cacher' => new Mustache_Cache_FilesystemCache(dirname(__FILE__).'/tmp/cache/mustache'), + * * // A cache directory for compiled templates. Mustache will not cache templates unless this is set * 'cache' => dirname(__FILE__).'/tmp/cache/mustache', * @@ -111,12 +113,13 @@ class Mustache_Engine $this->templateClassPrefix = $options['template_class_prefix']; } - if (isset($options['cache'])) { - $this->cache = $options['cache']; - } - - if (isset($options['cache_file_mode'])) { - $this->cacheFileMode = $options['cache_file_mode']; + if (isset($options['cacher'])) { + $this->cache = $options['cacher']; + } else if (isset($options['cache'])) { + $this->cache = new Mustache_Cache_FilesystemCache( + $options['cache'], + $options['cache_file_mode'] + ); } if (isset($options['loader'])) { @@ -479,6 +482,38 @@ class Mustache_Engine return $this->compiler; } + /** + * Set the Mustache Tokenizer instance. + * + * @param Mustache_Cache $cache + */ + public function setCache(Mustache_Cache $cache) + { + $this->cache = $cache; + } + + /** + * Get the current Mustache Cache instance. + * + * If no Cache instance has been explicitly specified, this method will instantiate and return a new one. + * + * @return Mustache_Cache + */ + public function getCache() + { + if (!isset($this->cache)) { + $this->cache = new Mustache_Cache_NoopCache(); + + $this->log( + Mustache_Logger::WARNING, + 'Template cache disabled', + array() + ); + } + + return $this->cache; + } + /** * Helper method to generate a Mustache template class. * @@ -580,27 +615,17 @@ class Mustache_Engine if (!isset($this->templates[$className])) { if (!class_exists($className, false)) { - if ($fileName = $this->getCacheFilename($source)) { - if (!is_file($fileName)) { - $this->log( - Mustache_Logger::DEBUG, - 'Writing "{className}" class to template cache: "{fileName}"', - array('className' => $className, 'fileName' => $fileName) - ); - - $this->writeCacheFile($fileName, $this->compile($source)); - } - - require_once $fileName; - } else { + $cached = $this->getCache()->get($source); + if (!$cached) { $this->log( - Mustache_Logger::WARNING, - 'Template cache disabled, evaluating "{className}" class at runtime', + Mustache_Logger::DEBUG, + 'Writing "{className}" class to template cache', array('className' => $className) ); - - eval('?>'.$this->compile($source)); + $cached = $this->compile($source); + $this->getCache()->put($source, $cached); } + eval('?>'.$cached); } $this->log( @@ -666,72 +691,6 @@ class Mustache_Engine return $this->getCompiler()->compile($source, $tree, $name, isset($this->escape), $this->charset, $this->strictCallables, $this->entityFlags); } - /** - * Helper method to generate a Mustache Template class cache filename. - * - * @param string $source - * - * @return string Mustache Template class cache filename - */ - private function getCacheFilename($source) - { - if ($this->cache) { - return sprintf('%s/%s.php', $this->cache, $this->getTemplateClassName($source)); - } - } - - /** - * Helper method to dump a generated Mustache Template subclass to the file cache. - * - * @throws Mustache_Exception_RuntimeException if unable to create the cache directory or write to $fileName. - * - * @param string $fileName - * @param string $source - * - * @codeCoverageIgnore - */ - private function writeCacheFile($fileName, $source) - { - $dirName = dirname($fileName); - if (!is_dir($dirName)) { - $this->log( - Mustache_Logger::INFO, - 'Creating Mustache template cache directory: "{dirName}"', - array('dirName' => $dirName) - ); - - @mkdir($dirName, 0777, true); - if (!is_dir($dirName)) { - throw new Mustache_Exception_RuntimeException(sprintf('Failed to create cache directory "%s".', $dirName)); - } - - } - - $this->log( - Mustache_Logger::DEBUG, - 'Caching compiled template to "{fileName}"', - array('fileName' => $fileName) - ); - - $tempFile = tempnam($dirName, basename($fileName)); - if (false !== @file_put_contents($tempFile, $source)) { - if (@rename($tempFile, $fileName)) { - $mode = isset($this->cacheFileMode) ? $this->cacheFileMode : (0666 & ~umask()); - @chmod($fileName, $mode); - - return; - } - - $this->log( - Mustache_Logger::ERROR, - 'Unable to rename Mustache temp cache file: "{tempName}" -> "{fileName}"', - array('tempName' => $tempFile, 'fileName' => $fileName) - ); - } - - throw new Mustache_Exception_RuntimeException(sprintf('Failed to write cache file "%s".', $fileName)); - } - /** * Add a log record if logging is enabled. * diff --git a/test/Mustache/Test/Cache/FilesystemCacheTest.php b/test/Mustache/Test/Cache/FilesystemCacheTest.php new file mode 100644 index 0000000..ae70e73 --- /dev/null +++ b/test/Mustache/Test/Cache/FilesystemCacheTest.php @@ -0,0 +1,58 @@ +get($key); + + $this->assertNull($cached); + } + + public function testCachePut() + { + $key = 'some key'; + $value = 'some value'; + $cache = new Mustache_Cache_FilesystemCache(self::$tempDir);; + $cache->put($key, $value); + $cached = $cache->get($key); + + $this->assertEquals($cached, $value); + } + + private static function rmdir($path) + { + $path = rtrim($path, '/').'/'; + $handle = opendir($path); + while (($file = readdir($handle)) !== false) { + if ($file == '.' || $file == '..') { + continue; + } + + $fullpath = $path.$file; + if (is_dir($fullpath)) { + self::rmdir($fullpath); + } else { + unlink($fullpath); + } + } + + closedir($handle); + rmdir($path); + } +} diff --git a/test/Mustache/Test/EngineTest.php b/test/Mustache/Test/EngineTest.php index 5c00821..5b5402b 100644 --- a/test/Mustache/Test/EngineTest.php +++ b/test/Mustache/Test/EngineTest.php @@ -58,6 +58,7 @@ class Mustache_Test_EngineTest extends PHPUnit_Framework_TestCase $this->assertTrue($mustache->hasHelper('foo')); $this->assertTrue($mustache->hasHelper('bar')); $this->assertFalse($mustache->hasHelper('baz')); + $this->assertInstanceOf('Mustache_Cache_FilesystemCache', $mustache->getCache()); } public static function getFoo() @@ -95,6 +96,7 @@ class Mustache_Test_EngineTest extends PHPUnit_Framework_TestCase $parser = new Mustache_Parser; $compiler = new Mustache_Compiler; $mustache = new Mustache_Engine; + $cache = new Mustache_Cache_FilesystemCache(sys_get_temp_dir()); $this->assertNotSame($logger, $mustache->getLogger()); $mustache->setLogger($logger); @@ -119,6 +121,10 @@ class Mustache_Test_EngineTest extends PHPUnit_Framework_TestCase $this->assertNotSame($compiler, $mustache->getCompiler()); $mustache->setCompiler($compiler); $this->assertSame($compiler, $mustache->getCompiler()); + + $this->assertNotSame($cache, $mustache->getCache()); + $mustache->setCache($cache); + $this->assertSame($cache, $mustache->getCache()); } /** @@ -134,10 +140,8 @@ class Mustache_Test_EngineTest extends PHPUnit_Framework_TestCase $source = '{{ foo }}'; $template = $mustache->loadTemplate($source); $className = $mustache->getTemplateClassName($source); - $fileName = self::$tempDir . '/' . $className . '.php'; + $this->assertInstanceOf($className, $template); - $this->assertFileExists($fileName); - $this->assertContains("\nclass $className extends Mustache_Template", file_get_contents($fileName)); } /** @@ -290,7 +294,7 @@ class Mustache_Test_EngineTest extends PHPUnit_Framework_TestCase $result = $mustache->render('{{ foo }}', array('foo' => 'FOO')); $this->assertEquals('FOO', $result); - $this->assertContains('WARNING: Template cache disabled, evaluating', file_get_contents($name)); + $this->assertContains('WARNING: Template cache disabled', file_get_contents($name)); } public function testLoggingIsNotTooAnnoying() From 3e876fd9846a911d981621909a546042b7ded164 Mon Sep 17 00:00:00 2001 From: Amit Snyderman Date: Thu, 5 Sep 2013 17:30:28 -0400 Subject: [PATCH 03/32] Fix build - explicit config key check --- src/Mustache/Engine.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Mustache/Engine.php b/src/Mustache/Engine.php index 1becac9..90ffddc 100644 --- a/src/Mustache/Engine.php +++ b/src/Mustache/Engine.php @@ -116,9 +116,12 @@ class Mustache_Engine if (isset($options['cacher'])) { $this->cache = $options['cacher']; } else if (isset($options['cache'])) { + $cacheFileMode = isset($options['cache_file_mode']) + ? $options['cache_file_mode'] + : null; $this->cache = new Mustache_Cache_FilesystemCache( $options['cache'], - $options['cache_file_mode'] + $cacheFileMode ); } From 71eaed27783cfdaa962a85268fb0a0b048e14064 Mon Sep 17 00:00:00 2001 From: Amit Snyderman Date: Thu, 5 Sep 2013 18:16:00 -0400 Subject: [PATCH 04/32] Cleanup cache initialization from options --- src/Mustache/Engine.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Mustache/Engine.php b/src/Mustache/Engine.php index 90ffddc..10cbaf8 100644 --- a/src/Mustache/Engine.php +++ b/src/Mustache/Engine.php @@ -55,7 +55,8 @@ class Mustache_Engine * // A Mustache cache instance. Uses a NoopCache if not specified. * 'cacher' => new Mustache_Cache_FilesystemCache(dirname(__FILE__).'/tmp/cache/mustache'), * - * // A cache directory for compiled templates. Mustache will not cache templates unless this is set + * // A Mustache cache instance or a cache directory string for compiled templates. + * // Mustache will not cache templates unless this is set * 'cache' => dirname(__FILE__).'/tmp/cache/mustache', * * // Override default permissions for cache files. Defaults to using the system-defined umask. It is @@ -113,16 +114,15 @@ class Mustache_Engine $this->templateClassPrefix = $options['template_class_prefix']; } - if (isset($options['cacher'])) { - $this->cache = $options['cacher']; - } else if (isset($options['cache'])) { - $cacheFileMode = isset($options['cache_file_mode']) - ? $options['cache_file_mode'] - : null; - $this->cache = new Mustache_Cache_FilesystemCache( - $options['cache'], - $cacheFileMode - ); + if (isset($options['cache'])) { + $cache = $options['cache']; + + if (is_string($cache)) { + $mode = isset($options['cache_file_mode']) ? $options['cache_file_mode'] : null; + $cache = new Mustache_Cache_FilesystemCache($cache, $mode); + } + + $this->setCache($cache); } if (isset($options['loader'])) { From 94cd72bfd4b970b21f528525bba3c21bf388ecad Mon Sep 17 00:00:00 2001 From: Amit Snyderman Date: Thu, 5 Sep 2013 18:56:43 -0400 Subject: [PATCH 05/32] Restore original eval vs. require class loading Pushing the responsibility of class loading onto the `Mustache_Cache` implementation and changing the semantics of get/put to load/cache. --- src/Mustache/Cache.php | 4 +- src/Mustache/Cache/FilesystemCache.php | 64 +++++++++++-------- src/Mustache/Cache/NoopCache.php | 11 +++- src/Mustache/Engine.php | 13 +--- .../Test/Cache/FilesystemCacheTest.php | 12 ++-- 5 files changed, 59 insertions(+), 45 deletions(-) diff --git a/src/Mustache/Cache.php b/src/Mustache/Cache.php index a9ab043..4797cdf 100644 --- a/src/Mustache/Cache.php +++ b/src/Mustache/Cache.php @@ -2,6 +2,6 @@ interface Mustache_Cache { - public function get($key); - public function put($key, $value); + public function load($key); + public function cache($key, $value); } diff --git a/src/Mustache/Cache/FilesystemCache.php b/src/Mustache/Cache/FilesystemCache.php index 0b3e82c..a79a081 100644 --- a/src/Mustache/Cache/FilesystemCache.php +++ b/src/Mustache/Cache/FilesystemCache.php @@ -11,41 +11,55 @@ class Mustache_Cache_FilesystemCache implements Mustache_Cache $this->fileMode = $fileMode; } - public function get($key) + public function load($key) { $fileName = $this->getCacheFilename($key); - return (is_file($fileName)) - ? file_get_contents($fileName) - : null; + if (!is_file($fileName)) { + return false; + } + + require_once $fileName; + + return true; } - public function put($key, $value) + public function cache($key, $value) { $fileName = $this->getCacheFilename($key); - $dirName = dirname($fileName); - if (!is_dir($dirName)) { - @mkdir($dirName, 0777, true); - if (!is_dir($dirName)) { - throw new Mustache_Exception_RuntimeException(sprintf('Failed to create cache directory "%s".', $dirName)); - } - - } - - $tempFile = tempnam($dirName, basename($fileName)); - if (false !== @file_put_contents($tempFile, $value)) { - if (@rename($tempFile, $fileName)) { - $mode = isset($this->fileMode) ? $this->fileMode : (0666 & ~umask()); - @chmod($fileName, $mode); - - return; - } - } - - throw new Mustache_Exception_RuntimeException(sprintf('Failed to write cache file "%s".', $fileName)); + $this->writeFile($fileName, $value); + $this->load($key); } protected function getCacheFilename($name) { return sprintf('%s/%s.php', $this->directory, md5($name)); } + + private function buildDirectoryForFilename($fileName) + { + $dirName = dirname($fileName); + if (!is_dir($dirName)) { + @mkdir($dirName, 0777, true); + if (!is_dir($dirName)) { + throw new Mustache_Exception_RuntimeException(sprintf('Failed to create cache directory "%s".', $dirName)); + } + } + return $dirName; + } + + private function writeFile($fileName, $value) + { + $dirName = $this->buildDirectoryForFilename($fileName); + $tempFile = tempnam($dirName, basename($fileName)); + if (false !== @file_put_contents($tempFile, $value)) { + if (@rename($tempFile, $fileName)) { + $mode = isset($this->fileMode) ? $this->fileMode : (0666 & ~umask()); + @chmod($fileName, $mode); + + return $fileName; + } + } + + throw new Mustache_Exception_RuntimeException(sprintf('Failed to write cache file "%s".', $fileName)); + } } diff --git a/src/Mustache/Cache/NoopCache.php b/src/Mustache/Cache/NoopCache.php index 3d722ab..95fd2d9 100644 --- a/src/Mustache/Cache/NoopCache.php +++ b/src/Mustache/Cache/NoopCache.php @@ -2,6 +2,13 @@ class Mustache_Cache_NoopCache implements Mustache_Cache { - public function get($key) { return null; } - public function put($key, $value) {} + public function load($key) + { + return false; + } + + public function cache($key, $compiled) + { + eval("?>".$compiled); + } } diff --git a/src/Mustache/Engine.php b/src/Mustache/Engine.php index 10cbaf8..1a2fee7 100644 --- a/src/Mustache/Engine.php +++ b/src/Mustache/Engine.php @@ -618,17 +618,10 @@ class Mustache_Engine if (!isset($this->templates[$className])) { if (!class_exists($className, false)) { - $cached = $this->getCache()->get($source); - if (!$cached) { - $this->log( - Mustache_Logger::DEBUG, - 'Writing "{className}" class to template cache', - array('className' => $className) - ); - $cached = $this->compile($source); - $this->getCache()->put($source, $cached); + if (!$this->getCache()->load($source)) { + $compiled = $this->compile($source); + $this->getCache()->cache($source, $compiled); } - eval('?>'.$cached); } $this->log( diff --git a/test/Mustache/Test/Cache/FilesystemCacheTest.php b/test/Mustache/Test/Cache/FilesystemCacheTest.php index ae70e73..f5ff91f 100644 --- a/test/Mustache/Test/Cache/FilesystemCacheTest.php +++ b/test/Mustache/Test/Cache/FilesystemCacheTest.php @@ -19,20 +19,20 @@ class Mustache_Test_Cache_FilesystemCacheTest extends PHPUnit_Framework_TestCase { $key = 'some key'; $cache = new Mustache_Cache_FilesystemCache(self::$tempDir);; - $cached = $cache->get($key); + $loaded = $cache->load($key); - $this->assertNull($cached); + $this->assertFalse($loaded); } public function testCachePut() { $key = 'some key'; - $value = 'some value'; + $value = 'put($key, $value); - $cached = $cache->get($key); + $cache->cache($key, $value); + $loaded = $cache->load($key); - $this->assertEquals($cached, $value); + $this->assertTrue($loaded); } private static function rmdir($path) From 724cd60cacd02f8ffc2d7cd9c1966d7e71d9bb5c Mon Sep 17 00:00:00 2001 From: Amit Snyderman Date: Thu, 5 Sep 2013 19:22:13 -0400 Subject: [PATCH 06/32] Restore logging for cache operations `AbstractCache` exposes the ability to set a logger. Default behavior automatically passes the logger reference down to the cache, unless a specific cache instance was provided. --- src/Mustache/Cache/AbstractCache.php | 27 +++++++++++++++++++++++++ src/Mustache/Cache/FilesystemCache.php | 28 +++++++++++++++++++++++++- src/Mustache/Cache/NoopCache.php | 7 ++++++- src/Mustache/Engine.php | 10 ++++----- test/Mustache/Test/EngineTest.php | 2 +- 5 files changed, 65 insertions(+), 9 deletions(-) create mode 100644 src/Mustache/Cache/AbstractCache.php diff --git a/src/Mustache/Cache/AbstractCache.php b/src/Mustache/Cache/AbstractCache.php new file mode 100644 index 0000000..7120536 --- /dev/null +++ b/src/Mustache/Cache/AbstractCache.php @@ -0,0 +1,27 @@ +logger; + } + + public function setLogger($logger = null) + { + if ($logger !== null && !($logger instanceof Mustache_Logger || is_a($logger, 'Psr\\Log\\LoggerInterface'))) { + throw new Mustache_Exception_InvalidArgumentException('Expected an instance of Mustache_Logger or Psr\\Log\\LoggerInterface.'); + } + + $this->logger = $logger; + } + + protected function log($level, $message, array $context = array()) + { + if (isset($this->logger)) { + $this->logger->log($level, $message, $context); + } + } +} diff --git a/src/Mustache/Cache/FilesystemCache.php b/src/Mustache/Cache/FilesystemCache.php index a79a081..c6af6ae 100644 --- a/src/Mustache/Cache/FilesystemCache.php +++ b/src/Mustache/Cache/FilesystemCache.php @@ -1,6 +1,6 @@ getCacheFilename($key); + + $this->log( + Mustache_Logger::DEBUG, + 'Writing to template cache: "{fileName}"', + array('fileName' => $fileName) + ); + $this->writeFile($fileName, $value); $this->load($key); } @@ -39,6 +46,12 @@ class Mustache_Cache_FilesystemCache implements Mustache_Cache { $dirName = dirname($fileName); if (!is_dir($dirName)) { + $this->log( + Mustache_Logger::INFO, + 'Creating Mustache template cache directory: "{dirName}"', + array('dirName' => $dirName) + ); + @mkdir($dirName, 0777, true); if (!is_dir($dirName)) { throw new Mustache_Exception_RuntimeException(sprintf('Failed to create cache directory "%s".', $dirName)); @@ -50,6 +63,13 @@ class Mustache_Cache_FilesystemCache implements Mustache_Cache private function writeFile($fileName, $value) { $dirName = $this->buildDirectoryForFilename($fileName); + + $this->log( + Mustache_Logger::DEBUG, + 'Caching compiled template to "{fileName}"', + array('fileName' => $fileName) + ); + $tempFile = tempnam($dirName, basename($fileName)); if (false !== @file_put_contents($tempFile, $value)) { if (@rename($tempFile, $fileName)) { @@ -58,6 +78,12 @@ class Mustache_Cache_FilesystemCache implements Mustache_Cache return $fileName; } + + $this->log( + Mustache_Logger::ERROR, + 'Unable to rename Mustache temp cache file: "{tempName}" -> "{fileName}"', + array('tempName' => $tempFile, 'fileName' => $fileName) + ); } throw new Mustache_Exception_RuntimeException(sprintf('Failed to write cache file "%s".', $fileName)); diff --git a/src/Mustache/Cache/NoopCache.php b/src/Mustache/Cache/NoopCache.php index 95fd2d9..d717149 100644 --- a/src/Mustache/Cache/NoopCache.php +++ b/src/Mustache/Cache/NoopCache.php @@ -1,6 +1,6 @@ log( + Mustache_Logger::WARNING, + 'Template cache disabled, evaluating class at runtime', + array() + ); eval("?>".$compiled); } } diff --git a/src/Mustache/Engine.php b/src/Mustache/Engine.php index 1a2fee7..ef3e752 100644 --- a/src/Mustache/Engine.php +++ b/src/Mustache/Engine.php @@ -164,6 +164,10 @@ class Mustache_Engine if (isset($options['strict_callables'])) { $this->strictCallables = $options['strict_callables']; } + + if (!isset($options['cache']) || is_string($options['cache'])) { + $this->getCache()->setLogger($this->getLogger()); + } } /** @@ -506,12 +510,6 @@ class Mustache_Engine { if (!isset($this->cache)) { $this->cache = new Mustache_Cache_NoopCache(); - - $this->log( - Mustache_Logger::WARNING, - 'Template cache disabled', - array() - ); } return $this->cache; diff --git a/test/Mustache/Test/EngineTest.php b/test/Mustache/Test/EngineTest.php index 5b5402b..b63698e 100644 --- a/test/Mustache/Test/EngineTest.php +++ b/test/Mustache/Test/EngineTest.php @@ -294,7 +294,7 @@ class Mustache_Test_EngineTest extends PHPUnit_Framework_TestCase $result = $mustache->render('{{ foo }}', array('foo' => 'FOO')); $this->assertEquals('FOO', $result); - $this->assertContains('WARNING: Template cache disabled', file_get_contents($name)); + $this->assertContains('WARNING: Template cache disabled, evaluating', file_get_contents($name)); } public function testLoggingIsNotTooAnnoying() From 689be14d0f15634d2da0f031e0a353af658a319c Mon Sep 17 00:00:00 2001 From: Amit Snyderman Date: Fri, 6 Sep 2013 09:06:26 -0400 Subject: [PATCH 07/32] Invalid documentation --- src/Mustache/Engine.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Mustache/Engine.php b/src/Mustache/Engine.php index ef3e752..bf7f1c5 100644 --- a/src/Mustache/Engine.php +++ b/src/Mustache/Engine.php @@ -52,9 +52,6 @@ class Mustache_Engine * // The class prefix for compiled templates. Defaults to '__Mustache_'. * 'template_class_prefix' => '__MyTemplates_', * - * // A Mustache cache instance. Uses a NoopCache if not specified. - * 'cacher' => new Mustache_Cache_FilesystemCache(dirname(__FILE__).'/tmp/cache/mustache'), - * * // A Mustache cache instance or a cache directory string for compiled templates. * // Mustache will not cache templates unless this is set * 'cache' => dirname(__FILE__).'/tmp/cache/mustache', From 8894d68482511e3b603ef885cee63cabb04a0c42 Mon Sep 17 00:00:00 2001 From: Amit Snyderman Date: Fri, 6 Sep 2013 09:16:15 -0400 Subject: [PATCH 08/32] Use existing temp directory for test --- test/Mustache/Test/EngineTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Mustache/Test/EngineTest.php b/test/Mustache/Test/EngineTest.php index b63698e..f4d102d 100644 --- a/test/Mustache/Test/EngineTest.php +++ b/test/Mustache/Test/EngineTest.php @@ -96,7 +96,7 @@ class Mustache_Test_EngineTest extends PHPUnit_Framework_TestCase $parser = new Mustache_Parser; $compiler = new Mustache_Compiler; $mustache = new Mustache_Engine; - $cache = new Mustache_Cache_FilesystemCache(sys_get_temp_dir()); + $cache = new Mustache_Cache_FilesystemCache(self::$tempDir); $this->assertNotSame($logger, $mustache->getLogger()); $mustache->setLogger($logger); From 1937752519e54509d748d7618058c0380a632d78 Mon Sep 17 00:00:00 2001 From: Amit Snyderman Date: Fri, 6 Sep 2013 09:16:40 -0400 Subject: [PATCH 09/32] Use class name as cache key --- src/Mustache/Cache/FilesystemCache.php | 10 +++++----- src/Mustache/Cache/NoopCache.php | 4 ++-- src/Mustache/Engine.php | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Mustache/Cache/FilesystemCache.php b/src/Mustache/Cache/FilesystemCache.php index c6af6ae..28e6c0c 100644 --- a/src/Mustache/Cache/FilesystemCache.php +++ b/src/Mustache/Cache/FilesystemCache.php @@ -2,12 +2,12 @@ class Mustache_Cache_FilesystemCache extends Mustache_Cache_AbstractCache { - private $directory; + private $baseDir; private $fileMode; - public function __construct($directory, $fileMode = null) + public function __construct($baseDir, $fileMode = null) { - $this->directory = $directory; + $this->baseDir = $baseDir; $this->fileMode = $fileMode; } @@ -39,7 +39,7 @@ class Mustache_Cache_FilesystemCache extends Mustache_Cache_AbstractCache protected function getCacheFilename($name) { - return sprintf('%s/%s.php', $this->directory, md5($name)); + return sprintf('%s/%s.php', $this->baseDir, $name); } private function buildDirectoryForFilename($fileName) @@ -76,7 +76,7 @@ class Mustache_Cache_FilesystemCache extends Mustache_Cache_AbstractCache $mode = isset($this->fileMode) ? $this->fileMode : (0666 & ~umask()); @chmod($fileName, $mode); - return $fileName; + return; } $this->log( diff --git a/src/Mustache/Cache/NoopCache.php b/src/Mustache/Cache/NoopCache.php index d717149..47ed17d 100644 --- a/src/Mustache/Cache/NoopCache.php +++ b/src/Mustache/Cache/NoopCache.php @@ -11,8 +11,8 @@ class Mustache_Cache_NoopCache extends Mustache_Cache_AbstractCache { $this->log( Mustache_Logger::WARNING, - 'Template cache disabled, evaluating class at runtime', - array() + 'Template cache disabled, evaluating "{className}" class at runtime', + array('className' => $className) ); eval("?>".$compiled); } diff --git a/src/Mustache/Engine.php b/src/Mustache/Engine.php index bf7f1c5..84d870b 100644 --- a/src/Mustache/Engine.php +++ b/src/Mustache/Engine.php @@ -506,7 +506,7 @@ class Mustache_Engine public function getCache() { if (!isset($this->cache)) { - $this->cache = new Mustache_Cache_NoopCache(); + $this->setCache(new Mustache_Cache_NoopCache()); } return $this->cache; @@ -613,9 +613,9 @@ class Mustache_Engine if (!isset($this->templates[$className])) { if (!class_exists($className, false)) { - if (!$this->getCache()->load($source)) { + if (!$this->getCache()->load($className)) { $compiled = $this->compile($source); - $this->getCache()->cache($source, $compiled); + $this->getCache()->cache($className, $compiled); } } From a83ecd70aa960450eba7790dee14ffb2a71767e0 Mon Sep 17 00:00:00 2001 From: Amit Snyderman Date: Fri, 6 Sep 2013 11:50:04 -0400 Subject: [PATCH 10/32] Set logger for cache if not explicitly set --- src/Mustache/Engine.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Mustache/Engine.php b/src/Mustache/Engine.php index 84d870b..f66594f 100644 --- a/src/Mustache/Engine.php +++ b/src/Mustache/Engine.php @@ -161,10 +161,6 @@ class Mustache_Engine if (isset($options['strict_callables'])) { $this->strictCallables = $options['strict_callables']; } - - if (!isset($options['cache']) || is_string($options['cache'])) { - $this->getCache()->setLogger($this->getLogger()); - } } /** @@ -395,6 +391,10 @@ class Mustache_Engine throw new Mustache_Exception_InvalidArgumentException('Expected an instance of Mustache_Logger or Psr\\Log\\LoggerInterface.'); } + if ($this->getCache()->getLogger() === null) { + $this->getCache()->setLogger($logger); + } + $this->logger = $logger; } @@ -493,6 +493,10 @@ class Mustache_Engine */ public function setCache(Mustache_Cache $cache) { + if (isset($this->logger) && $cache->getLogger() === null) { + $cache->setLogger($this->getLogger()); + } + $this->cache = $cache; } From ae138efb47528c2a8d3a528e7e7a1e8ae4a8bfae Mon Sep 17 00:00:00 2001 From: Amit Snyderman Date: Fri, 6 Sep 2013 13:34:01 -0400 Subject: [PATCH 11/32] Fix broken build --- src/Mustache/Cache/NoopCache.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mustache/Cache/NoopCache.php b/src/Mustache/Cache/NoopCache.php index 47ed17d..1452c64 100644 --- a/src/Mustache/Cache/NoopCache.php +++ b/src/Mustache/Cache/NoopCache.php @@ -12,7 +12,7 @@ class Mustache_Cache_NoopCache extends Mustache_Cache_AbstractCache $this->log( Mustache_Logger::WARNING, 'Template cache disabled, evaluating "{className}" class at runtime', - array('className' => $className) + array('className' => $key) ); eval("?>".$compiled); } From 37e60df12cdd1f2a5f9bbc386df982a8b6c69fc2 Mon Sep 17 00:00:00 2001 From: Amit Snyderman Date: Mon, 16 Sep 2013 20:14:44 -0400 Subject: [PATCH 12/32] Revert timezone edit --- test/bootstrap.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/bootstrap.php b/test/bootstrap.php index 2399f38..91f654a 100644 --- a/test/bootstrap.php +++ b/test/bootstrap.php @@ -9,8 +9,6 @@ * file that was distributed with this source code. */ -date_default_timezone_set('UTC'); - require dirname(__FILE__).'/../src/Mustache/Autoloader.php'; Mustache_Autoloader::register(); From d6e1b4505377d5c803fb90eb1e87355262541a6f Mon Sep 17 00:00:00 2001 From: Amit Snyderman Date: Mon, 16 Sep 2013 20:17:39 -0400 Subject: [PATCH 13/32] Add copyright/license header --- src/Mustache/Cache.php | 9 +++++++++ src/Mustache/Cache/AbstractCache.php | 9 +++++++++ src/Mustache/Cache/FilesystemCache.php | 9 +++++++++ src/Mustache/Cache/NoopCache.php | 9 +++++++++ test/Mustache/Test/Cache/FilesystemCacheTest.php | 9 +++++++++ 5 files changed, 45 insertions(+) diff --git a/src/Mustache/Cache.php b/src/Mustache/Cache.php index 4797cdf..1561efc 100644 --- a/src/Mustache/Cache.php +++ b/src/Mustache/Cache.php @@ -1,5 +1,14 @@ Date: Mon, 16 Sep 2013 20:50:47 -0400 Subject: [PATCH 14/32] Docs --- src/Mustache/Cache.php | 20 ++++++++++ src/Mustache/Cache/AbstractCache.php | 7 ++++ src/Mustache/Cache/FilesystemCache.php | 53 ++++++++++++++++++++++++++ src/Mustache/Cache/NoopCache.php | 19 +++++++++ 4 files changed, 99 insertions(+) diff --git a/src/Mustache/Cache.php b/src/Mustache/Cache.php index 1561efc..1ca7438 100644 --- a/src/Mustache/Cache.php +++ b/src/Mustache/Cache.php @@ -9,8 +9,28 @@ * file that was distributed with this source code. */ +/** + * Mustache Cache interface. + * + * Interface for caching and loading Mustache_Template classes + * generated by the Mustache_Compiler. + */ interface Mustache_Cache { + /** + * Load a compiled Mustache_Template class from cache. + * + * @param string $key + * @return boolean indicates successfully class load + */ public function load($key); + + /** + * Cache and load a compiled Mustache_Template class. + * + * @param string $key + * @param string $value + * @return void + */ public function cache($key, $value); } diff --git a/src/Mustache/Cache/AbstractCache.php b/src/Mustache/Cache/AbstractCache.php index dc67387..4a5ab90 100644 --- a/src/Mustache/Cache/AbstractCache.php +++ b/src/Mustache/Cache/AbstractCache.php @@ -9,6 +9,13 @@ * file that was distributed with this source code. */ +/** + * Abstract Mustache Cache class. + * + * Provides logging support to child implementations. + * + * @abstract + */ abstract class Mustache_Cache_AbstractCache implements Mustache_Cache { private $logger = null; diff --git a/src/Mustache/Cache/FilesystemCache.php b/src/Mustache/Cache/FilesystemCache.php index 8b100ef..ade547d 100644 --- a/src/Mustache/Cache/FilesystemCache.php +++ b/src/Mustache/Cache/FilesystemCache.php @@ -9,17 +9,39 @@ * file that was distributed with this source code. */ +/** + * Mustache Cache filesystem implementation. + * + * A FilesystemCache instance caches Mustache Template classes from the filesystem by name: + * + * $cache = new Mustache_Cache_FilesystemCache(dirname(__FILE__).'/cache'); + * $cache->cache($className, $compiledSource); + * + * Benefits from any opcode caching that may be setup in your environment. + */ class Mustache_Cache_FilesystemCache extends Mustache_Cache_AbstractCache { private $baseDir; private $fileMode; + /** + * Filesystem cache constructor. + * + * @param string $baseDir Directory for compiled templates. + * @param int $fileMode Override default permissions for cache files. Defaults to using the system-defined umask. + */ public function __construct($baseDir, $fileMode = null) { $this->baseDir = $baseDir; $this->fileMode = $fileMode; } + /** + * Load the class from cache using `require_once`. + * + * @param string $key + * @return boolean + */ public function load($key) { $fileName = $this->getCacheFilename($key); @@ -32,6 +54,13 @@ class Mustache_Cache_FilesystemCache extends Mustache_Cache_AbstractCache return true; } + /** + * Cache and load the compiled class + * + * @param string $key + * @param string $value + * @return void + */ public function cache($key, $value) { $fileName = $this->getCacheFilename($key); @@ -46,11 +75,26 @@ class Mustache_Cache_FilesystemCache extends Mustache_Cache_AbstractCache $this->load($key); } + /** + * Build the cache filename. + * Subclasses should override for custom cache directory structures. + * + * @param string $name + * @return string + */ protected function getCacheFilename($name) { return sprintf('%s/%s.php', $this->baseDir, $name); } + /** + * Create cache directory + * + * @param string $fileName + * @return string + * + * @throws Mustache_Exception_RuntimeException If unable to create directory + */ private function buildDirectoryForFilename($fileName) { $dirName = dirname($fileName); @@ -69,6 +113,15 @@ class Mustache_Cache_FilesystemCache extends Mustache_Cache_AbstractCache return $dirName; } + /** + * Write cache file + * + * @param string $fileName + * @param string $value + * @return void + * + * @throws Mustache_Exception_RuntimeException If unable to write file + */ private function writeFile($fileName, $value) { $dirName = $this->buildDirectoryForFilename($fileName); diff --git a/src/Mustache/Cache/NoopCache.php b/src/Mustache/Cache/NoopCache.php index df3fbf0..bd54362 100644 --- a/src/Mustache/Cache/NoopCache.php +++ b/src/Mustache/Cache/NoopCache.php @@ -9,13 +9,32 @@ * file that was distributed with this source code. */ +/** + * Mustache Cache in-memory implementation. + * + * In-memory implementation useful during development. + * Not recommended for production use. + */ class Mustache_Cache_NoopCache extends Mustache_Cache_AbstractCache { + /** + * Loads nothing. Move along. + * + * @param string $key + * @return boolean + */ public function load($key) { return false; } + /** + * Loads the compiled Mustache Template class without caching. + * + * @param string $key + * @param string $compiled + * @return void + */ public function cache($key, $compiled) { $this->log( From e07c9422902d895e51107254f6cc738f1cf923f8 Mon Sep 17 00:00:00 2001 From: Amit Snyderman Date: Tue, 17 Sep 2013 14:24:28 -0400 Subject: [PATCH 15/32] Fix docblock --- src/Mustache/Engine.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mustache/Engine.php b/src/Mustache/Engine.php index f66594f..488dd84 100644 --- a/src/Mustache/Engine.php +++ b/src/Mustache/Engine.php @@ -487,7 +487,7 @@ class Mustache_Engine } /** - * Set the Mustache Tokenizer instance. + * Set the Mustache Cache instance. * * @param Mustache_Cache $cache */ From 0d161cc7d28aac9573141f0f37f6b2d0cc9b4fd9 Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Wed, 18 Sep 2013 12:10:17 -0700 Subject: [PATCH 16/32] Bump copyright dates. --- bin/build_bootstrap.php | 2 +- src/Mustache/Autoloader.php | 2 +- src/Mustache/Cache.php | 2 +- src/Mustache/Cache/AbstractCache.php | 2 +- src/Mustache/Cache/FilesystemCache.php | 2 +- src/Mustache/Cache/NoopCache.php | 2 +- src/Mustache/Compiler.php | 2 +- src/Mustache/Context.php | 2 +- src/Mustache/Engine.php | 2 +- src/Mustache/HelperCollection.php | 2 +- src/Mustache/LambdaHelper.php | 2 +- src/Mustache/Loader.php | 2 +- src/Mustache/Loader/ArrayLoader.php | 2 +- src/Mustache/Loader/FilesystemLoader.php | 2 +- src/Mustache/Loader/MutableLoader.php | 2 +- src/Mustache/Loader/StringLoader.php | 2 +- src/Mustache/Logger.php | 2 +- src/Mustache/Logger/AbstractLogger.php | 2 +- src/Mustache/Logger/StreamLogger.php | 2 +- src/Mustache/Parser.php | 2 +- src/Mustache/Template.php | 2 +- src/Mustache/Tokenizer.php | 2 +- test/Mustache/Test/AutoloaderTest.php | 2 +- test/Mustache/Test/Cache/FilesystemCacheTest.php | 2 +- test/Mustache/Test/CompilerTest.php | 2 +- test/Mustache/Test/ContextTest.php | 2 +- test/Mustache/Test/EngineTest.php | 2 +- test/Mustache/Test/FiveThree/Functional/ClosureQuirksTest.php | 2 +- test/Mustache/Test/FiveThree/Functional/FiltersTest.php | 2 +- .../Test/FiveThree/Functional/HigherOrderSectionsTest.php | 2 +- test/Mustache/Test/FiveThree/Functional/LambdaHelperTest.php | 2 +- test/Mustache/Test/FiveThree/Functional/MustacheSpecTest.php | 2 +- test/Mustache/Test/Functional/CallTest.php | 2 +- test/Mustache/Test/Functional/ExamplesTest.php | 2 +- test/Mustache/Test/Functional/HigherOrderSectionsTest.php | 2 +- test/Mustache/Test/Functional/MustacheInjectionTest.php | 2 +- test/Mustache/Test/Functional/MustacheSpecTest.php | 2 +- test/Mustache/Test/Functional/ObjectSectionTest.php | 2 +- test/Mustache/Test/HelperCollectionTest.php | 2 +- test/Mustache/Test/Loader/ArrayLoaderTest.php | 2 +- test/Mustache/Test/Loader/CascadingLoaderTest.php | 2 +- test/Mustache/Test/Loader/FilesystemLoaderTest.php | 2 +- test/Mustache/Test/Loader/InlineLoaderTest.php | 2 +- test/Mustache/Test/Loader/StringLoaderTest.php | 2 +- test/Mustache/Test/Logger/AbstractLoggerTest.php | 2 +- test/Mustache/Test/Logger/StreamLoggerTest.php | 2 +- test/Mustache/Test/ParserTest.php | 2 +- test/Mustache/Test/TemplateTest.php | 2 +- test/Mustache/Test/TokenizerTest.php | 2 +- test/bootstrap.php | 2 +- test/fixtures/autoloader/Mustache/Bar.php | 2 +- test/fixtures/autoloader/Mustache/Foo.php | 2 +- test/fixtures/autoloader/NonMustacheClass.php | 2 +- 53 files changed, 53 insertions(+), 53 deletions(-) diff --git a/bin/build_bootstrap.php b/bin/build_bootstrap.php index 19ef0f4..834f3f7 100755 --- a/bin/build_bootstrap.php +++ b/bin/build_bootstrap.php @@ -4,7 +4,7 @@ /* * This file is part of Mustache.php. * - * (c) 2012 Justin Hileman + * (c) 2013 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/src/Mustache/Autoloader.php b/src/Mustache/Autoloader.php index 2a209dd..6936b06 100644 --- a/src/Mustache/Autoloader.php +++ b/src/Mustache/Autoloader.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2012 Justin Hileman + * (c) 2013 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/src/Mustache/Cache.php b/src/Mustache/Cache.php index 1ca7438..f1c3347 100644 --- a/src/Mustache/Cache.php +++ b/src/Mustache/Cache.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2012 Justin Hileman + * (c) 2013 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/src/Mustache/Cache/AbstractCache.php b/src/Mustache/Cache/AbstractCache.php index 4a5ab90..23977c0 100644 --- a/src/Mustache/Cache/AbstractCache.php +++ b/src/Mustache/Cache/AbstractCache.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2012 Justin Hileman + * (c) 2013 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/src/Mustache/Cache/FilesystemCache.php b/src/Mustache/Cache/FilesystemCache.php index ade547d..e2b353b 100644 --- a/src/Mustache/Cache/FilesystemCache.php +++ b/src/Mustache/Cache/FilesystemCache.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2012 Justin Hileman + * (c) 2013 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/src/Mustache/Cache/NoopCache.php b/src/Mustache/Cache/NoopCache.php index bd54362..87b5649 100644 --- a/src/Mustache/Cache/NoopCache.php +++ b/src/Mustache/Cache/NoopCache.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2012 Justin Hileman + * (c) 2013 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/src/Mustache/Compiler.php b/src/Mustache/Compiler.php index a30e6f5..d003609 100644 --- a/src/Mustache/Compiler.php +++ b/src/Mustache/Compiler.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2012 Justin Hileman + * (c) 2013 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/src/Mustache/Context.php b/src/Mustache/Context.php index e7783b4..67e4083 100644 --- a/src/Mustache/Context.php +++ b/src/Mustache/Context.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2012 Justin Hileman + * (c) 2013 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/src/Mustache/Engine.php b/src/Mustache/Engine.php index 488dd84..b8b4db3 100644 --- a/src/Mustache/Engine.php +++ b/src/Mustache/Engine.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2012 Justin Hileman + * (c) 2013 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/src/Mustache/HelperCollection.php b/src/Mustache/HelperCollection.php index e991137..4fee762 100644 --- a/src/Mustache/HelperCollection.php +++ b/src/Mustache/HelperCollection.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2012 Justin Hileman + * (c) 2013 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/src/Mustache/LambdaHelper.php b/src/Mustache/LambdaHelper.php index dfd4659..0ae0b64 100644 --- a/src/Mustache/LambdaHelper.php +++ b/src/Mustache/LambdaHelper.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2012 Justin Hileman + * (c) 2013 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/src/Mustache/Loader.php b/src/Mustache/Loader.php index f659a1d..9fa82db 100644 --- a/src/Mustache/Loader.php +++ b/src/Mustache/Loader.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2012 Justin Hileman + * (c) 2013 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/src/Mustache/Loader/ArrayLoader.php b/src/Mustache/Loader/ArrayLoader.php index ec35774..dfd9e02 100644 --- a/src/Mustache/Loader/ArrayLoader.php +++ b/src/Mustache/Loader/ArrayLoader.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2012 Justin Hileman + * (c) 2013 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/src/Mustache/Loader/FilesystemLoader.php b/src/Mustache/Loader/FilesystemLoader.php index c30149c..8abe6c6 100644 --- a/src/Mustache/Loader/FilesystemLoader.php +++ b/src/Mustache/Loader/FilesystemLoader.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2012 Justin Hileman + * (c) 2013 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/src/Mustache/Loader/MutableLoader.php b/src/Mustache/Loader/MutableLoader.php index 02bb207..f606edb 100644 --- a/src/Mustache/Loader/MutableLoader.php +++ b/src/Mustache/Loader/MutableLoader.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2012 Justin Hileman + * (c) 2013 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/src/Mustache/Loader/StringLoader.php b/src/Mustache/Loader/StringLoader.php index e73b3cd..295ace4 100644 --- a/src/Mustache/Loader/StringLoader.php +++ b/src/Mustache/Loader/StringLoader.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2012 Justin Hileman + * (c) 2013 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/src/Mustache/Logger.php b/src/Mustache/Logger.php index e08359a..d0ed1da 100644 --- a/src/Mustache/Logger.php +++ b/src/Mustache/Logger.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2012 Justin Hileman + * (c) 2013 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/src/Mustache/Logger/AbstractLogger.php b/src/Mustache/Logger/AbstractLogger.php index bb057d6..e0872bf 100644 --- a/src/Mustache/Logger/AbstractLogger.php +++ b/src/Mustache/Logger/AbstractLogger.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2012 Justin Hileman + * (c) 2013 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/src/Mustache/Logger/StreamLogger.php b/src/Mustache/Logger/StreamLogger.php index da771f9..8955108 100644 --- a/src/Mustache/Logger/StreamLogger.php +++ b/src/Mustache/Logger/StreamLogger.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2012 Justin Hileman + * (c) 2013 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/src/Mustache/Parser.php b/src/Mustache/Parser.php index 697ce7f..c624f9e 100644 --- a/src/Mustache/Parser.php +++ b/src/Mustache/Parser.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2012 Justin Hileman + * (c) 2013 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/src/Mustache/Template.php b/src/Mustache/Template.php index aeee42d..4ca3e27 100644 --- a/src/Mustache/Template.php +++ b/src/Mustache/Template.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2012 Justin Hileman + * (c) 2013 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/src/Mustache/Tokenizer.php b/src/Mustache/Tokenizer.php index e065622..a5da185 100644 --- a/src/Mustache/Tokenizer.php +++ b/src/Mustache/Tokenizer.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2012 Justin Hileman + * (c) 2013 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/test/Mustache/Test/AutoloaderTest.php b/test/Mustache/Test/AutoloaderTest.php index 2c35ba2..7ab45ca 100644 --- a/test/Mustache/Test/AutoloaderTest.php +++ b/test/Mustache/Test/AutoloaderTest.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2012 Justin Hileman + * (c) 2013 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/test/Mustache/Test/Cache/FilesystemCacheTest.php b/test/Mustache/Test/Cache/FilesystemCacheTest.php index 07e4a12..87b33f3 100644 --- a/test/Mustache/Test/Cache/FilesystemCacheTest.php +++ b/test/Mustache/Test/Cache/FilesystemCacheTest.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2012 Justin Hileman + * (c) 2013 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/test/Mustache/Test/CompilerTest.php b/test/Mustache/Test/CompilerTest.php index a5a2bdf..8f8ec4c 100644 --- a/test/Mustache/Test/CompilerTest.php +++ b/test/Mustache/Test/CompilerTest.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2012 Justin Hileman + * (c) 2013 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/test/Mustache/Test/ContextTest.php b/test/Mustache/Test/ContextTest.php index 857dc0a..02f7fa9 100644 --- a/test/Mustache/Test/ContextTest.php +++ b/test/Mustache/Test/ContextTest.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2012 Justin Hileman + * (c) 2013 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/test/Mustache/Test/EngineTest.php b/test/Mustache/Test/EngineTest.php index f4d102d..81b72d1 100644 --- a/test/Mustache/Test/EngineTest.php +++ b/test/Mustache/Test/EngineTest.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2012 Justin Hileman + * (c) 2013 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/test/Mustache/Test/FiveThree/Functional/ClosureQuirksTest.php b/test/Mustache/Test/FiveThree/Functional/ClosureQuirksTest.php index 9f9f548..64651b6 100644 --- a/test/Mustache/Test/FiveThree/Functional/ClosureQuirksTest.php +++ b/test/Mustache/Test/FiveThree/Functional/ClosureQuirksTest.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2012 Justin Hileman + * (c) 2013 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/test/Mustache/Test/FiveThree/Functional/FiltersTest.php b/test/Mustache/Test/FiveThree/Functional/FiltersTest.php index bbd037e..9b8b815 100644 --- a/test/Mustache/Test/FiveThree/Functional/FiltersTest.php +++ b/test/Mustache/Test/FiveThree/Functional/FiltersTest.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2012 Justin Hileman + * (c) 2013 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/test/Mustache/Test/FiveThree/Functional/HigherOrderSectionsTest.php b/test/Mustache/Test/FiveThree/Functional/HigherOrderSectionsTest.php index f010f3c..5e3ac7c 100644 --- a/test/Mustache/Test/FiveThree/Functional/HigherOrderSectionsTest.php +++ b/test/Mustache/Test/FiveThree/Functional/HigherOrderSectionsTest.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2012 Justin Hileman + * (c) 2013 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/test/Mustache/Test/FiveThree/Functional/LambdaHelperTest.php b/test/Mustache/Test/FiveThree/Functional/LambdaHelperTest.php index e095d35..a73473e 100644 --- a/test/Mustache/Test/FiveThree/Functional/LambdaHelperTest.php +++ b/test/Mustache/Test/FiveThree/Functional/LambdaHelperTest.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2012 Justin Hileman + * (c) 2013 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/test/Mustache/Test/FiveThree/Functional/MustacheSpecTest.php b/test/Mustache/Test/FiveThree/Functional/MustacheSpecTest.php index 2414850..dcea68f 100644 --- a/test/Mustache/Test/FiveThree/Functional/MustacheSpecTest.php +++ b/test/Mustache/Test/FiveThree/Functional/MustacheSpecTest.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2012 Justin Hileman + * (c) 2013 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/test/Mustache/Test/Functional/CallTest.php b/test/Mustache/Test/Functional/CallTest.php index 53b93b7..4841ba9 100644 --- a/test/Mustache/Test/Functional/CallTest.php +++ b/test/Mustache/Test/Functional/CallTest.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2012 Justin Hileman + * (c) 2013 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/test/Mustache/Test/Functional/ExamplesTest.php b/test/Mustache/Test/Functional/ExamplesTest.php index 4dd2dae..3c7a5a5 100644 --- a/test/Mustache/Test/Functional/ExamplesTest.php +++ b/test/Mustache/Test/Functional/ExamplesTest.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2012 Justin Hileman + * (c) 2013 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/test/Mustache/Test/Functional/HigherOrderSectionsTest.php b/test/Mustache/Test/Functional/HigherOrderSectionsTest.php index 4c3cba6..0919656 100644 --- a/test/Mustache/Test/Functional/HigherOrderSectionsTest.php +++ b/test/Mustache/Test/Functional/HigherOrderSectionsTest.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2012 Justin Hileman + * (c) 2013 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/test/Mustache/Test/Functional/MustacheInjectionTest.php b/test/Mustache/Test/Functional/MustacheInjectionTest.php index 7621af8..8c95494 100644 --- a/test/Mustache/Test/Functional/MustacheInjectionTest.php +++ b/test/Mustache/Test/Functional/MustacheInjectionTest.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2012 Justin Hileman + * (c) 2013 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/test/Mustache/Test/Functional/MustacheSpecTest.php b/test/Mustache/Test/Functional/MustacheSpecTest.php index 470f7f3..312a4c9 100644 --- a/test/Mustache/Test/Functional/MustacheSpecTest.php +++ b/test/Mustache/Test/Functional/MustacheSpecTest.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2012 Justin Hileman + * (c) 2013 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/test/Mustache/Test/Functional/ObjectSectionTest.php b/test/Mustache/Test/Functional/ObjectSectionTest.php index 893b668..126a683 100644 --- a/test/Mustache/Test/Functional/ObjectSectionTest.php +++ b/test/Mustache/Test/Functional/ObjectSectionTest.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2012 Justin Hileman + * (c) 2013 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/test/Mustache/Test/HelperCollectionTest.php b/test/Mustache/Test/HelperCollectionTest.php index 8bd54f9..ab9200f 100644 --- a/test/Mustache/Test/HelperCollectionTest.php +++ b/test/Mustache/Test/HelperCollectionTest.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2012 Justin Hileman + * (c) 2013 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/test/Mustache/Test/Loader/ArrayLoaderTest.php b/test/Mustache/Test/Loader/ArrayLoaderTest.php index b1da190..1c59df9 100644 --- a/test/Mustache/Test/Loader/ArrayLoaderTest.php +++ b/test/Mustache/Test/Loader/ArrayLoaderTest.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2012 Justin Hileman + * (c) 2013 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/test/Mustache/Test/Loader/CascadingLoaderTest.php b/test/Mustache/Test/Loader/CascadingLoaderTest.php index 06e1725..41ff4b4 100644 --- a/test/Mustache/Test/Loader/CascadingLoaderTest.php +++ b/test/Mustache/Test/Loader/CascadingLoaderTest.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2012 Justin Hileman + * (c) 2013 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/test/Mustache/Test/Loader/FilesystemLoaderTest.php b/test/Mustache/Test/Loader/FilesystemLoaderTest.php index 3aa83fd..0c09593 100644 --- a/test/Mustache/Test/Loader/FilesystemLoaderTest.php +++ b/test/Mustache/Test/Loader/FilesystemLoaderTest.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2012 Justin Hileman + * (c) 2013 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/test/Mustache/Test/Loader/InlineLoaderTest.php b/test/Mustache/Test/Loader/InlineLoaderTest.php index 52a24bd..0545ad9 100644 --- a/test/Mustache/Test/Loader/InlineLoaderTest.php +++ b/test/Mustache/Test/Loader/InlineLoaderTest.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2012 Justin Hileman + * (c) 2013 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/test/Mustache/Test/Loader/StringLoaderTest.php b/test/Mustache/Test/Loader/StringLoaderTest.php index abda71a..79dfe51 100644 --- a/test/Mustache/Test/Loader/StringLoaderTest.php +++ b/test/Mustache/Test/Loader/StringLoaderTest.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2012 Justin Hileman + * (c) 2013 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/test/Mustache/Test/Logger/AbstractLoggerTest.php b/test/Mustache/Test/Logger/AbstractLoggerTest.php index 733b2eb..f45bee4 100644 --- a/test/Mustache/Test/Logger/AbstractLoggerTest.php +++ b/test/Mustache/Test/Logger/AbstractLoggerTest.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2012 Justin Hileman + * (c) 2013 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/test/Mustache/Test/Logger/StreamLoggerTest.php b/test/Mustache/Test/Logger/StreamLoggerTest.php index 4ddbcec..68cc05d 100644 --- a/test/Mustache/Test/Logger/StreamLoggerTest.php +++ b/test/Mustache/Test/Logger/StreamLoggerTest.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2012 Justin Hileman + * (c) 2013 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/test/Mustache/Test/ParserTest.php b/test/Mustache/Test/ParserTest.php index ea11510..57e418a 100644 --- a/test/Mustache/Test/ParserTest.php +++ b/test/Mustache/Test/ParserTest.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2012 Justin Hileman + * (c) 2013 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/test/Mustache/Test/TemplateTest.php b/test/Mustache/Test/TemplateTest.php index a3b14a1..bafdefb 100644 --- a/test/Mustache/Test/TemplateTest.php +++ b/test/Mustache/Test/TemplateTest.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2012 Justin Hileman + * (c) 2013 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/test/Mustache/Test/TokenizerTest.php b/test/Mustache/Test/TokenizerTest.php index fa98b84..87ace68 100644 --- a/test/Mustache/Test/TokenizerTest.php +++ b/test/Mustache/Test/TokenizerTest.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2012 Justin Hileman + * (c) 2013 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/test/bootstrap.php b/test/bootstrap.php index 91f654a..cf84d28 100644 --- a/test/bootstrap.php +++ b/test/bootstrap.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2012 Justin Hileman + * (c) 2013 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/test/fixtures/autoloader/Mustache/Bar.php b/test/fixtures/autoloader/Mustache/Bar.php index 4cad3d9..f731f5f 100644 --- a/test/fixtures/autoloader/Mustache/Bar.php +++ b/test/fixtures/autoloader/Mustache/Bar.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2012 Justin Hileman + * (c) 2013 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/test/fixtures/autoloader/Mustache/Foo.php b/test/fixtures/autoloader/Mustache/Foo.php index e7c0713..5f16022 100644 --- a/test/fixtures/autoloader/Mustache/Foo.php +++ b/test/fixtures/autoloader/Mustache/Foo.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2012 Justin Hileman + * (c) 2013 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. diff --git a/test/fixtures/autoloader/NonMustacheClass.php b/test/fixtures/autoloader/NonMustacheClass.php index cd216a2..82febb9 100644 --- a/test/fixtures/autoloader/NonMustacheClass.php +++ b/test/fixtures/autoloader/NonMustacheClass.php @@ -3,7 +3,7 @@ /* * This file is part of Mustache.php. * - * (c) 2012 Justin Hileman + * (c) 2013 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. From cb2a6b5a03774ce968aebb567d9e22f20a2cdabb Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Wed, 18 Sep 2013 23:49:44 -0700 Subject: [PATCH 17/32] Clean up comments, standardize whitespace. --- src/Mustache/Cache.php | 8 +++-- src/Mustache/Cache/AbstractCache.php | 17 ++++++++++ src/Mustache/Cache/FilesystemCache.php | 32 +++++++++++-------- src/Mustache/Cache/NoopCache.php | 8 +++-- src/Mustache/Engine.php | 10 +++--- src/Mustache/Logger.php | 29 +++++++++++------ src/Mustache/Logger/AbstractLogger.php | 16 +++++----- src/Mustache/Logger/StreamLogger.php | 24 +++++++------- src/Mustache/Parser.php | 6 ++-- src/Mustache/Template.php | 6 ++-- .../Functional/PartialLambdaIndentTest.php | 1 - .../Functional/StrictCallablesTest.php | 1 - .../Test/Logger/AbstractLoggerTest.php | 4 +-- 13 files changed, 98 insertions(+), 64 deletions(-) diff --git a/src/Mustache/Cache.php b/src/Mustache/Cache.php index f1c3347..6387872 100644 --- a/src/Mustache/Cache.php +++ b/src/Mustache/Cache.php @@ -20,7 +20,8 @@ interface Mustache_Cache /** * Load a compiled Mustache_Template class from cache. * - * @param string $key + * @param string $key + * * @return boolean indicates successfully class load */ public function load($key); @@ -28,8 +29,9 @@ interface Mustache_Cache /** * Cache and load a compiled Mustache_Template class. * - * @param string $key - * @param string $value + * @param string $key + * @param string $value + * * @return void */ public function cache($key, $value); diff --git a/src/Mustache/Cache/AbstractCache.php b/src/Mustache/Cache/AbstractCache.php index 23977c0..9ee7157 100644 --- a/src/Mustache/Cache/AbstractCache.php +++ b/src/Mustache/Cache/AbstractCache.php @@ -20,11 +20,21 @@ abstract class Mustache_Cache_AbstractCache implements Mustache_Cache { private $logger = null; + /** + * Get the current logger instance. + * + * @return Mustache_Logger|Psr\Log\LoggerInterface + */ public function getLogger() { return $this->logger; } + /** + * Set a logger instance. + * + * @param Mustache_Logger|Psr\Log\LoggerInterface $logger + */ public function setLogger($logger = null) { if ($logger !== null && !($logger instanceof Mustache_Logger || is_a($logger, 'Psr\\Log\\LoggerInterface'))) { @@ -34,6 +44,13 @@ abstract class Mustache_Cache_AbstractCache implements Mustache_Cache $this->logger = $logger; } + /** + * Add a log record if logging is enabled. + * + * @param integer $level The logging level + * @param string $message The log message + * @param array $context The log context + */ protected function log($level, $message, array $context = array()) { if (isset($this->logger)) { diff --git a/src/Mustache/Cache/FilesystemCache.php b/src/Mustache/Cache/FilesystemCache.php index e2b353b..a15ef61 100644 --- a/src/Mustache/Cache/FilesystemCache.php +++ b/src/Mustache/Cache/FilesystemCache.php @@ -27,8 +27,8 @@ class Mustache_Cache_FilesystemCache extends Mustache_Cache_AbstractCache /** * Filesystem cache constructor. * - * @param string $baseDir Directory for compiled templates. - * @param int $fileMode Override default permissions for cache files. Defaults to using the system-defined umask. + * @param string $baseDir Directory for compiled templates. + * @param int $fileMode Override default permissions for cache files. Defaults to using the system-defined umask. */ public function __construct($baseDir, $fileMode = null) { @@ -39,7 +39,8 @@ class Mustache_Cache_FilesystemCache extends Mustache_Cache_AbstractCache /** * Load the class from cache using `require_once`. * - * @param string $key + * @param string $key + * * @return boolean */ public function load($key) @@ -57,8 +58,9 @@ class Mustache_Cache_FilesystemCache extends Mustache_Cache_AbstractCache /** * Cache and load the compiled class * - * @param string $key - * @param string $value + * @param string $key + * @param string $value + * * @return void */ public function cache($key, $value) @@ -79,7 +81,8 @@ class Mustache_Cache_FilesystemCache extends Mustache_Cache_AbstractCache * Build the cache filename. * Subclasses should override for custom cache directory structures. * - * @param string $name + * @param string $name + * * @return string */ protected function getCacheFilename($name) @@ -90,10 +93,11 @@ class Mustache_Cache_FilesystemCache extends Mustache_Cache_AbstractCache /** * Create cache directory * - * @param string $fileName - * @return string - * * @throws Mustache_Exception_RuntimeException If unable to create directory + * + * @param string $fileName + * + * @return string */ private function buildDirectoryForFilename($fileName) { @@ -110,17 +114,19 @@ class Mustache_Cache_FilesystemCache extends Mustache_Cache_AbstractCache throw new Mustache_Exception_RuntimeException(sprintf('Failed to create cache directory "%s".', $dirName)); } } + return $dirName; } /** * Write cache file * - * @param string $fileName - * @param string $value - * @return void - * * @throws Mustache_Exception_RuntimeException If unable to write file + * + * @param string $fileName + * @param string $value + * + * @return void */ private function writeFile($fileName, $value) { diff --git a/src/Mustache/Cache/NoopCache.php b/src/Mustache/Cache/NoopCache.php index 87b5649..0056de0 100644 --- a/src/Mustache/Cache/NoopCache.php +++ b/src/Mustache/Cache/NoopCache.php @@ -20,7 +20,8 @@ class Mustache_Cache_NoopCache extends Mustache_Cache_AbstractCache /** * Loads nothing. Move along. * - * @param string $key + * @param string $key + * * @return boolean */ public function load($key) @@ -31,8 +32,9 @@ class Mustache_Cache_NoopCache extends Mustache_Cache_AbstractCache /** * Loads the compiled Mustache Template class without caching. * - * @param string $key - * @param string $compiled + * @param string $key + * @param string $compiled + * * @return void */ public function cache($key, $compiled) diff --git a/src/Mustache/Engine.php b/src/Mustache/Engine.php index b8b4db3..d03d479 100644 --- a/src/Mustache/Engine.php +++ b/src/Mustache/Engine.php @@ -53,7 +53,7 @@ class Mustache_Engine * 'template_class_prefix' => '__MyTemplates_', * * // A Mustache cache instance or a cache directory string for compiled templates. - * // Mustache will not cache templates unless this is set + * // Mustache will not cache templates unless this is set. * 'cache' => dirname(__FILE__).'/tmp/cache/mustache', * * // Override default permissions for cache files. Defaults to using the system-defined umask. It is @@ -172,7 +172,7 @@ class Mustache_Engine * @see Mustache_Template::render * * @param string $template - * @param mixed $context (default: array()) + * @param mixed $context (default: array()) * * @return string Rendered template */ @@ -689,9 +689,9 @@ class Mustache_Engine /** * Add a log record if logging is enabled. * - * @param integer $level The logging level - * @param string $message The log message - * @param array $context The log context + * @param integer $level The logging level + * @param string $message The log message + * @param array $context The log context */ private function log($level, $message, array $context = array()) { diff --git a/src/Mustache/Logger.php b/src/Mustache/Logger.php index d0ed1da..3874bba 100644 --- a/src/Mustache/Logger.php +++ b/src/Mustache/Logger.php @@ -44,7 +44,8 @@ interface Mustache_Logger * System is unusable. * * @param string $message - * @param array $context + * @param array $context + * * @return null */ public function emergency($message, array $context = array()); @@ -56,7 +57,8 @@ interface Mustache_Logger * trigger the SMS alerts and wake you up. * * @param string $message - * @param array $context + * @param array $context + * * @return null */ public function alert($message, array $context = array()); @@ -67,7 +69,8 @@ interface Mustache_Logger * Example: Application component unavailable, unexpected exception. * * @param string $message - * @param array $context + * @param array $context + * * @return null */ public function critical($message, array $context = array()); @@ -77,7 +80,8 @@ interface Mustache_Logger * be logged and monitored. * * @param string $message - * @param array $context + * @param array $context + * * @return null */ public function error($message, array $context = array()); @@ -89,7 +93,8 @@ interface Mustache_Logger * that are not necessarily wrong. * * @param string $message - * @param array $context + * @param array $context + * * @return null */ public function warning($message, array $context = array()); @@ -98,7 +103,8 @@ interface Mustache_Logger * Normal but significant events. * * @param string $message - * @param array $context + * @param array $context + * * @return null */ public function notice($message, array $context = array()); @@ -109,7 +115,8 @@ interface Mustache_Logger * Example: User logs in, SQL logs. * * @param string $message - * @param array $context + * @param array $context + * * @return null */ public function info($message, array $context = array()); @@ -118,7 +125,8 @@ interface Mustache_Logger * Detailed debug information. * * @param string $message - * @param array $context + * @param array $context + * * @return null */ public function debug($message, array $context = array()); @@ -126,9 +134,10 @@ interface Mustache_Logger /** * Logs with an arbitrary level. * - * @param mixed $level + * @param mixed $level * @param string $message - * @param array $context + * @param array $context + * * @return null */ public function log($level, $message, array $context = array()); diff --git a/src/Mustache/Logger/AbstractLogger.php b/src/Mustache/Logger/AbstractLogger.php index e0872bf..44f99d3 100644 --- a/src/Mustache/Logger/AbstractLogger.php +++ b/src/Mustache/Logger/AbstractLogger.php @@ -24,7 +24,7 @@ abstract class Mustache_Logger_AbstractLogger implements Mustache_Logger * System is unusable. * * @param string $message - * @param array $context + * @param array $context */ public function emergency($message, array $context = array()) { @@ -38,7 +38,7 @@ abstract class Mustache_Logger_AbstractLogger implements Mustache_Logger * trigger the SMS alerts and wake you up. * * @param string $message - * @param array $context + * @param array $context */ public function alert($message, array $context = array()) { @@ -51,7 +51,7 @@ abstract class Mustache_Logger_AbstractLogger implements Mustache_Logger * Example: Application component unavailable, unexpected exception. * * @param string $message - * @param array $context + * @param array $context */ public function critical($message, array $context = array()) { @@ -63,7 +63,7 @@ abstract class Mustache_Logger_AbstractLogger implements Mustache_Logger * be logged and monitored. * * @param string $message - * @param array $context + * @param array $context */ public function error($message, array $context = array()) { @@ -77,7 +77,7 @@ abstract class Mustache_Logger_AbstractLogger implements Mustache_Logger * that are not necessarily wrong. * * @param string $message - * @param array $context + * @param array $context */ public function warning($message, array $context = array()) { @@ -88,7 +88,7 @@ abstract class Mustache_Logger_AbstractLogger implements Mustache_Logger * Normal but significant events. * * @param string $message - * @param array $context + * @param array $context */ public function notice($message, array $context = array()) { @@ -101,7 +101,7 @@ abstract class Mustache_Logger_AbstractLogger implements Mustache_Logger * Example: User logs in, SQL logs. * * @param string $message - * @param array $context + * @param array $context */ public function info($message, array $context = array()) { @@ -112,7 +112,7 @@ abstract class Mustache_Logger_AbstractLogger implements Mustache_Logger * Detailed debug information. * * @param string $message - * @param array $context + * @param array $context */ public function debug($message, array $context = array()) { diff --git a/src/Mustache/Logger/StreamLogger.php b/src/Mustache/Logger/StreamLogger.php index 8955108..c79e6cb 100644 --- a/src/Mustache/Logger/StreamLogger.php +++ b/src/Mustache/Logger/StreamLogger.php @@ -66,7 +66,7 @@ class Mustache_Logger_StreamLogger extends Mustache_Logger_AbstractLogger * * @throws Mustache_Exception_InvalidArgumentException if the logging level is unknown. * - * @param integer $level The minimum logging level which will be written + * @param integer $level The minimum logging level which will be written */ public function setLevel($level) { @@ -92,9 +92,9 @@ class Mustache_Logger_StreamLogger extends Mustache_Logger_AbstractLogger * * @throws Mustache_Exception_InvalidArgumentException if the logging level is unknown. * - * @param mixed $level + * @param mixed $level * @param string $message - * @param array $context + * @param array $context */ public function log($level, $message, array $context = array()) { @@ -113,9 +113,9 @@ class Mustache_Logger_StreamLogger extends Mustache_Logger_AbstractLogger * @throws Mustache_Exception_LogicException If neither a stream resource nor url is present. * @throws Mustache_Exception_RuntimeException If the stream url cannot be opened. * - * @param integer $level The logging level - * @param string $message The log message - * @param array $context The log context + * @param integer $level The logging level + * @param string $message The log message + * @param array $context The log context */ protected function writeLog($level, $message, array $context = array()) { @@ -140,7 +140,7 @@ class Mustache_Logger_StreamLogger extends Mustache_Logger_AbstractLogger * * @throws InvalidArgumentException if the logging level is unknown. * - * @param integer $level + * @param integer $level * * @return string */ @@ -152,9 +152,9 @@ class Mustache_Logger_StreamLogger extends Mustache_Logger_AbstractLogger /** * Format a log line for output. * - * @param integer $level The logging level - * @param string $message The log message - * @param array $context The log context + * @param integer $level The logging level + * @param string $message The log message + * @param array $context The log context * * @return string */ @@ -170,8 +170,8 @@ class Mustache_Logger_StreamLogger extends Mustache_Logger_AbstractLogger /** * Interpolate context values into the message placeholders. * - * @param string $message - * @param array $context + * @param string $message + * @param array $context * * @return string */ diff --git a/src/Mustache/Parser.php b/src/Mustache/Parser.php index c624f9e..227e00b 100644 --- a/src/Mustache/Parser.php +++ b/src/Mustache/Parser.php @@ -40,7 +40,7 @@ class Mustache_Parser * @throws Mustache_Exception_SyntaxException when nesting errors or mismatched section tags are encountered. * * @param array &$tokens Set of Mustache tokens - * @param array $parent Parent token (default: null) + * @param array $parent Parent token (default: null) * * @return array Mustache Token parse tree */ @@ -121,8 +121,8 @@ class Mustache_Parser * * Returns a whitespace token for indenting partials, if applicable. * - * @param array $nodes Parsed nodes. - * @param array $tokens Tokens to be parsed. + * @param array $nodes Parsed nodes. + * @param array $tokens Tokens to be parsed. * * @return array Resulting indent token, if any. */ diff --git a/src/Mustache/Template.php b/src/Mustache/Template.php index 4ca3e27..8c76916 100644 --- a/src/Mustache/Template.php +++ b/src/Mustache/Template.php @@ -158,9 +158,9 @@ abstract class Mustache_Template * * Invoke the value if it is callable, otherwise return the value. * - * @param mixed $value - * @param Mustache_Context $context - * @param string $indent + * @param mixed $value + * @param Mustache_Context $context + * @param string $indent * * @return string */ diff --git a/test/Mustache/Test/FiveThree/Functional/PartialLambdaIndentTest.php b/test/Mustache/Test/FiveThree/Functional/PartialLambdaIndentTest.php index 647905f..5d9e4d1 100644 --- a/test/Mustache/Test/FiveThree/Functional/PartialLambdaIndentTest.php +++ b/test/Mustache/Test/FiveThree/Functional/PartialLambdaIndentTest.php @@ -42,7 +42,6 @@ EOS; $tpl = $m->loadTemplate($src); - $data = new Mustache_Test_Functional_ClassWithLambda(); $this->assertEquals($expected, $tpl->render($data)); } diff --git a/test/Mustache/Test/FiveThree/Functional/StrictCallablesTest.php b/test/Mustache/Test/FiveThree/Functional/StrictCallablesTest.php index 87edf0d..39b5dd9 100644 --- a/test/Mustache/Test/FiveThree/Functional/StrictCallablesTest.php +++ b/test/Mustache/Test/FiveThree/Functional/StrictCallablesTest.php @@ -73,7 +73,6 @@ class Mustache_Test_FiveThree_Functional_StrictCallablesTest extends PHPUnit_Fra ); } - /** * @group wip * @dataProvider strictCallables diff --git a/test/Mustache/Test/Logger/AbstractLoggerTest.php b/test/Mustache/Test/Logger/AbstractLoggerTest.php index f45bee4..2b66948 100644 --- a/test/Mustache/Test/Logger/AbstractLoggerTest.php +++ b/test/Mustache/Test/Logger/AbstractLoggerTest.php @@ -49,9 +49,9 @@ class Mustache_Test_Logger_TestLogger extends Mustache_Logger_AbstractLogger /** * Logs with an arbitrary level. * - * @param mixed $level + * @param mixed $level * @param string $message - * @param array $context + * @param array $context */ public function log($level, $message, array $context = array()) { From 44b60e1bb8d8dfe79d0f09a3e3c0633b0eb57b18 Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Thu, 26 Sep 2013 09:48:29 -0700 Subject: [PATCH 18/32] Add a failing test for #167 Multiple levels of nested partials are only indented to the level of the first partial. --- test/fixtures/examples/nested_partials/NestedPartials.php | 6 ++++++ .../examples/nested_partials/nested_partials.mustache | 3 +++ test/fixtures/examples/nested_partials/nested_partials.txt | 7 +++++++ .../examples/nested_partials/partials/fourth.mustache | 1 + .../examples/nested_partials/partials/second.mustache | 3 +++ .../examples/nested_partials/partials/third.mustache | 3 +++ 6 files changed, 23 insertions(+) create mode 100644 test/fixtures/examples/nested_partials/NestedPartials.php create mode 100644 test/fixtures/examples/nested_partials/nested_partials.mustache create mode 100644 test/fixtures/examples/nested_partials/nested_partials.txt create mode 100644 test/fixtures/examples/nested_partials/partials/fourth.mustache create mode 100644 test/fixtures/examples/nested_partials/partials/second.mustache create mode 100644 test/fixtures/examples/nested_partials/partials/third.mustache diff --git a/test/fixtures/examples/nested_partials/NestedPartials.php b/test/fixtures/examples/nested_partials/NestedPartials.php new file mode 100644 index 0000000..632639e --- /dev/null +++ b/test/fixtures/examples/nested_partials/NestedPartials.php @@ -0,0 +1,6 @@ + + {{> second }} + \ No newline at end of file diff --git a/test/fixtures/examples/nested_partials/nested_partials.txt b/test/fixtures/examples/nested_partials/nested_partials.txt new file mode 100644 index 0000000..62776f9 --- /dev/null +++ b/test/fixtures/examples/nested_partials/nested_partials.txt @@ -0,0 +1,7 @@ + + + + FOURTH! + + + \ No newline at end of file diff --git a/test/fixtures/examples/nested_partials/partials/fourth.mustache b/test/fixtures/examples/nested_partials/partials/fourth.mustache new file mode 100644 index 0000000..727676f --- /dev/null +++ b/test/fixtures/examples/nested_partials/partials/fourth.mustache @@ -0,0 +1 @@ +{{ val }} diff --git a/test/fixtures/examples/nested_partials/partials/second.mustache b/test/fixtures/examples/nested_partials/partials/second.mustache new file mode 100644 index 0000000..83f33cf --- /dev/null +++ b/test/fixtures/examples/nested_partials/partials/second.mustache @@ -0,0 +1,3 @@ + + {{> third }} + diff --git a/test/fixtures/examples/nested_partials/partials/third.mustache b/test/fixtures/examples/nested_partials/partials/third.mustache new file mode 100644 index 0000000..f33301a --- /dev/null +++ b/test/fixtures/examples/nested_partials/partials/third.mustache @@ -0,0 +1,3 @@ + + {{> fourth }} + From e388a3ca7fce5ecf29395a5e7d73cd50df2662cf Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Thu, 26 Sep 2013 09:48:56 -0700 Subject: [PATCH 19/32] Fix for nested partials indenting. Fixes #167 --- src/Mustache/Compiler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mustache/Compiler.php b/src/Mustache/Compiler.php index d003609..d3d6940 100644 --- a/src/Mustache/Compiler.php +++ b/src/Mustache/Compiler.php @@ -262,7 +262,7 @@ class Mustache_Compiler const PARTIAL = ' if ($partial = $this->mustache->loadPartial(%s)) { - $buffer .= $partial->renderInternal($context, %s); + $buffer .= $partial->renderInternal($context, $indent . %s); } '; From b6d6a720a0d59162fa77f167bf0f15692dfa430b Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Thu, 5 Dec 2013 07:04:22 -0800 Subject: [PATCH 20/32] Fix docblock param order. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It’s been backwards since #148. Whoops :) --- src/Mustache/Compiler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mustache/Compiler.php b/src/Mustache/Compiler.php index d3d6940..8bac251 100644 --- a/src/Mustache/Compiler.php +++ b/src/Mustache/Compiler.php @@ -33,9 +33,9 @@ class Mustache_Compiler * @param string $tree Parse tree of Mustache tokens * @param string $name Mustache Template class name * @param bool $customEscape (default: false) - * @param int $entityFlags (default: ENT_COMPAT) * @param string $charset (default: 'UTF-8') * @param bool $strictCallables (default: false) + * @param int $entityFlags (default: ENT_COMPAT) * * @return string Generated PHP source code */ From 0e1d5a678fc99168543bf376f35559782d7431bf Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Thu, 5 Dec 2013 08:04:51 -0800 Subject: [PATCH 21/32] Add PHP 5.5 to Travis config --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 1284d21..47022c5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,3 +3,4 @@ php: - 5.2 - 5.3 - 5.4 + - 5.5 From 0c85d195090d9c9f475e7218f856fa016f622d0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20W=C3=BCrker?= Date: Thu, 5 Dec 2013 15:01:57 +0100 Subject: [PATCH 22/32] Allow use of ArrayAccess objects in context. --- src/Mustache/Context.php | 17 ++++++++++------ test/Mustache/Test/ContextTest.php | 32 ++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 6 deletions(-) diff --git a/src/Mustache/Context.php b/src/Mustache/Context.php index 67e4083..09160e2 100644 --- a/src/Mustache/Context.php +++ b/src/Mustache/Context.php @@ -133,17 +133,22 @@ class Mustache_Context private function findVariableInStack($id, array $stack) { for ($i = count($stack) - 1; $i >= 0; $i--) { - if (is_object($stack[$i]) && !$stack[$i] instanceof Closure) { - if (method_exists($stack[$i], $id)) { - return $stack[$i]->$id(); - } elseif (isset($stack[$i]->$id)) { - return $stack[$i]->$id; + if (is_object($stack[$i])) { + if( $stack[$i] instanceof ArrayAccess) { + if (isset($stack[$i][$id])) { + return $stack[$i][$id]; + } + } elseif (!($stack[$i] instanceof Closure)) { + if (method_exists($stack[$i], $id)) { + return $stack[$i]->$id(); + } elseif (isset($stack[$i]->$id)) { + return $stack[$i]->$id; + } } } elseif (is_array($stack[$i]) && array_key_exists($id, $stack[$i])) { return $stack[$i][$id]; } } - return ''; } } diff --git a/test/Mustache/Test/ContextTest.php b/test/Mustache/Test/ContextTest.php index 02f7fa9..a901bd3 100644 --- a/test/Mustache/Test/ContextTest.php +++ b/test/Mustache/Test/ContextTest.php @@ -71,6 +71,8 @@ class Mustache_Test_ContextTest extends PHPUnit_Framework_TestCase $string = 'some arbitrary string'; + $access = new Mustache_Test_TestArrayAccess($arr); + $context->push($dummy); $this->assertEquals('dummy', $context->find('name')); @@ -95,6 +97,11 @@ class Mustache_Test_ContextTest extends PHPUnit_Framework_TestCase $this->assertEquals('see', $context->findDot('a.b.c')); $this->assertEquals('', $context->find('foo')); $this->assertEquals('', $context->findDot('bar')); + + $context = new Mustache_Context($arr); + $this->assertEquals('bee', $context->find('b')); + $this->assertEquals('see', $context->findDot('a.b.c')); + $this->assertEquals(null, $context->findDot('a.b.c.d')); } } @@ -117,3 +124,28 @@ class Mustache_Test_TestDummy return ''; } } + +class Mustache_Test_TestArrayAccess implements arrayaccess { + private $container = array(); + public function __construct($array) { + foreach($array as $key => $value) { + $this->container[$key] = $value; + } + } + public function offsetSet($offset, $value) { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + public function offsetExists($offset) { + return isset($this->container[$offset]); + } + public function offsetUnset($offset) { + unset($this->container[$offset]); + } + public function offsetGet($offset) { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } +} From 04b016016e4e024b497e00b15ea83cb3642df696 Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Fri, 6 Dec 2013 19:10:45 -0800 Subject: [PATCH 23/32] Clean up code style, ArrayAccess test. See #178 --- src/Mustache/Context.php | 3 ++- test/Mustache/Test/ContextTest.php | 37 ++++++++++++++++++++++-------- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/src/Mustache/Context.php b/src/Mustache/Context.php index 09160e2..657f552 100644 --- a/src/Mustache/Context.php +++ b/src/Mustache/Context.php @@ -134,7 +134,7 @@ class Mustache_Context { for ($i = count($stack) - 1; $i >= 0; $i--) { if (is_object($stack[$i])) { - if( $stack[$i] instanceof ArrayAccess) { + if ($stack[$i] instanceof ArrayAccess) { if (isset($stack[$i][$id])) { return $stack[$i][$id]; } @@ -149,6 +149,7 @@ class Mustache_Context return $stack[$i][$id]; } } + return ''; } } diff --git a/test/Mustache/Test/ContextTest.php b/test/Mustache/Test/ContextTest.php index a901bd3..a12df50 100644 --- a/test/Mustache/Test/ContextTest.php +++ b/test/Mustache/Test/ContextTest.php @@ -71,8 +71,6 @@ class Mustache_Test_ContextTest extends PHPUnit_Framework_TestCase $string = 'some arbitrary string'; - $access = new Mustache_Test_TestArrayAccess($arr); - $context->push($dummy); $this->assertEquals('dummy', $context->find('name')); @@ -97,8 +95,16 @@ class Mustache_Test_ContextTest extends PHPUnit_Framework_TestCase $this->assertEquals('see', $context->findDot('a.b.c')); $this->assertEquals('', $context->find('foo')); $this->assertEquals('', $context->findDot('bar')); + } - $context = new Mustache_Context($arr); + public function testArrayAccessFind() + { + $access = new Mustache_Test_TestArrayAccess(array( + 'a' => array('b' => array('c' => 'see')), + 'b' => 'bee', + )); + + $context = new Mustache_Context($access); $this->assertEquals('bee', $context->find('b')); $this->assertEquals('see', $context->findDot('a.b.c')); $this->assertEquals(null, $context->findDot('a.b.c.d')); @@ -125,27 +131,38 @@ class Mustache_Test_TestDummy } } -class Mustache_Test_TestArrayAccess implements arrayaccess { +class Mustache_Test_TestArrayAccess implements ArrayAccess +{ private $container = array(); - public function __construct($array) { - foreach($array as $key => $value) { + + public function __construct($array) + { + foreach ($array as $key => $value) { $this->container[$key] = $value; } } - public function offsetSet($offset, $value) { + + public function offsetSet($offset, $value) + { if (is_null($offset)) { $this->container[] = $value; } else { $this->container[$offset] = $value; } } - public function offsetExists($offset) { + + public function offsetExists($offset) + { return isset($this->container[$offset]); } - public function offsetUnset($offset) { + + public function offsetUnset($offset) + { unset($this->container[$offset]); } - public function offsetGet($offset) { + + public function offsetGet($offset) + { return isset($this->container[$offset]) ? $this->container[$offset] : null; } } From 38b6b245b172d7c33de384a6ea2eb4e4c76e3f62 Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Fri, 6 Dec 2013 19:44:52 -0800 Subject: [PATCH 24/32] Fix ArrayAccess priority: * Methods brump properties and ArrayAccess * Properties beat ArrayAccess * ArrayAccess beats nothing at all * ArrayAccess also beats private properties Add a test case to verify. See #178 --- src/Mustache/Context.php | 18 ++++------ test/Mustache/Test/ContextTest.php | 53 ++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 11 deletions(-) diff --git a/src/Mustache/Context.php b/src/Mustache/Context.php index 657f552..c6900d7 100644 --- a/src/Mustache/Context.php +++ b/src/Mustache/Context.php @@ -133,17 +133,13 @@ class Mustache_Context private function findVariableInStack($id, array $stack) { for ($i = count($stack) - 1; $i >= 0; $i--) { - if (is_object($stack[$i])) { - if ($stack[$i] instanceof ArrayAccess) { - if (isset($stack[$i][$id])) { - return $stack[$i][$id]; - } - } elseif (!($stack[$i] instanceof Closure)) { - if (method_exists($stack[$i], $id)) { - return $stack[$i]->$id(); - } elseif (isset($stack[$i]->$id)) { - return $stack[$i]->$id; - } + if (is_object($stack[$i]) && !($stack[$i] instanceof Closure)) { + if (method_exists($stack[$i], $id)) { + return $stack[$i]->$id(); + } elseif (isset($stack[$i]->$id)) { + return $stack[$i]->$id; + } elseif ($stack[$i] instanceof ArrayAccess && isset($stack[$i][$id])) { + return $stack[$i][$id]; } } elseif (is_array($stack[$i]) && array_key_exists($id, $stack[$i])) { return $stack[$i][$id]; diff --git a/test/Mustache/Test/ContextTest.php b/test/Mustache/Test/ContextTest.php index a12df50..b4f36a7 100644 --- a/test/Mustache/Test/ContextTest.php +++ b/test/Mustache/Test/ContextTest.php @@ -109,6 +109,16 @@ class Mustache_Test_ContextTest extends PHPUnit_Framework_TestCase $this->assertEquals('see', $context->findDot('a.b.c')); $this->assertEquals(null, $context->findDot('a.b.c.d')); } + + public function testAccessorPriority() + { + $context = new Mustache_Context(new Mustache_Test_AllTheThings); + + $this->assertEquals('win', $context->find('foo'), 'method beats property'); + $this->assertEquals('win', $context->find('bar'), 'property beats ArrayAccess'); + $this->assertEquals('win', $context->find('baz'), 'ArrayAccess stands alone'); + $this->assertEquals('win', $context->find('qux'), 'ArrayAccess beats private property'); + } } class Mustache_Test_TestDummy @@ -166,3 +176,46 @@ class Mustache_Test_TestArrayAccess implements ArrayAccess return isset($this->container[$offset]) ? $this->container[$offset] : null; } } + +class Mustache_Test_AllTheThings implements ArrayAccess +{ + public $foo = 'fail'; + public $bar = 'win'; + private $qux = 'fail'; + + public function foo() + { + return 'win'; + } + + public function offsetExists($offset) + { + return true; + } + + public function offsetGet($offset) + { + switch ($offset) { + case 'foo': + case 'bar': + return 'fail'; + + case 'baz': + case 'qux': + return 'win'; + + default: + return 'lolwhut'; + } + } + + public function offsetSet($offset, $value) + { + // nada + } + + public function offsetUnset($offset) + { + // nada + } +} From e739e216a69f46e8d1721f4ed0334394fa9aa2e3 Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Sun, 27 Jan 2013 02:35:37 -0800 Subject: [PATCH 25/32] Implement section (and inverted section) filters. This is a super powerful construct. It's also prolly a violation of the "logic-less-ness" of Mustache templates :( --- src/Mustache/Compiler.php | 21 +++- .../Functional/SectionFiltersTest.php | 101 ++++++++++++++++++ 2 files changed, 118 insertions(+), 4 deletions(-) create mode 100644 test/Mustache/Test/FiveThree/Functional/SectionFiltersTest.php diff --git a/src/Mustache/Compiler.php b/src/Mustache/Compiler.php index 8bac251..c38ca43 100644 --- a/src/Mustache/Compiler.php +++ b/src/Mustache/Compiler.php @@ -178,7 +178,8 @@ class Mustache_Compiler const SECTION_CALL = ' // %s section - $buffer .= $this->section%s($context, $indent, $context->%s(%s)); + $value = $context->%s(%s);%s + $buffer .= $this->section%s($context, $indent, $value); '; const SECTION = ' @@ -216,6 +217,12 @@ class Mustache_Compiler */ private function section($nodes, $id, $start, $end, $otag, $ctag, $level) { + $filters = ''; + + if (isset($this->pragmas[Mustache_Engine::PRAGMA_FILTERS])) { + list($id, $filters) = $this->getFilters($id, $level); + } + $method = $this->getFindMethod($id); $id = var_export($id, true); $source = var_export(substr($this->source, $start, $end - $start), true); @@ -233,12 +240,12 @@ class Mustache_Compiler $this->sections[$key] = sprintf($this->prepare(self::SECTION), $key, $callable, $source, $delims, $this->walk($nodes, 2)); } - return sprintf($this->prepare(self::SECTION_CALL, $level), $id, $key, $method, $id); + return sprintf($this->prepare(self::SECTION_CALL, $level), $id, $method, $id, $filters, $key); } const INVERTED_SECTION = ' // %s inverted section - $value = $context->%s(%s); + $value = $context->%s(%s);%s if (empty($value)) { %s }'; @@ -254,10 +261,16 @@ class Mustache_Compiler */ private function invertedSection($nodes, $id, $level) { + $filters = ''; + + if (isset($this->pragmas[Mustache_Engine::PRAGMA_FILTERS])) { + list($id, $filters) = $this->getFilters($id, $level); + } + $method = $this->getFindMethod($id); $id = var_export($id, true); - return sprintf($this->prepare(self::INVERTED_SECTION, $level), $id, $method, $id, $this->walk($nodes, $level)); + return sprintf($this->prepare(self::INVERTED_SECTION, $level), $id, $method, $id, $filters, $this->walk($nodes, $level)); } const PARTIAL = ' diff --git a/test/Mustache/Test/FiveThree/Functional/SectionFiltersTest.php b/test/Mustache/Test/FiveThree/Functional/SectionFiltersTest.php new file mode 100644 index 0000000..cbd6823 --- /dev/null +++ b/test/Mustache/Test/FiveThree/Functional/SectionFiltersTest.php @@ -0,0 +1,101 @@ +mustache = new Mustache_Engine; + } + + public function testSingleFilter() + { + $tpl = $this->mustache->loadTemplate('{{% FILTERS }}{{# word | echo }}{{ . }}!{{/ word | echo }}'); + + $this->mustache->addHelper('echo', function($value) { + return array($value, $value, $value); + }); + + $this->assertEquals('bacon!bacon!bacon!', $tpl->render(array('word' => 'bacon'))); + } + + const CHAINED_FILTERS_TPL = <<mustache->loadTemplate(self::CHAINED_FILTERS_TPL); + + $this->mustache->addHelper('echo', function($value) { + return array($value, $value, $value); + }); + + $this->mustache->addHelper('with_index', function($value) { + return array_map(function($k, $v) { + return array( + 'key' => $k, + 'value' => $v, + ); + }, array_keys($value), $value); + }); + + $this->assertEquals("0: bacon\n1: bacon\n2: bacon\n", $tpl->render(array('word' => 'bacon'))); + } + + public function testInterpolateFirst() + { + $tpl = $this->mustache->loadTemplate('{{% FILTERS }}{{# foo | bar }}{{ . }}{{/ foo | bar }}'); + $this->assertEquals('win!', $tpl->render(array( + 'foo' => 'FOO', + 'bar' => function($value) { + return ($value === 'FOO') ? 'win!' : 'fail :('; + }, + ))); + } + + /** + * @expectedException Mustache_Exception_UnknownFilterException + * @dataProvider getBrokenPipes + */ + public function testThrowsExceptionForBrokenPipes($tpl, $data) + { + $this->mustache + ->loadTemplate(sprintf('{{%% FILTERS }}{{# %s }}{{ . }}{{/ %s }}', $tpl, $tpl)) + ->render($data); + } + + public function getBrokenPipes() + { + return array( + array('foo | bar', array()), + array('foo | bar', array('foo' => 'FOO')), + array('foo | bar', array('foo' => 'FOO', 'bar' => 'BAR')), + array('foo | bar', array('foo' => 'FOO', 'bar' => array(1, 2))), + array('foo | bar | baz', array('foo' => 'FOO', 'bar' => function() { return 'BAR'; })), + array('foo | bar | baz', array('foo' => 'FOO', 'baz' => function() { return 'BAZ'; })), + array('foo | bar | baz', array('bar' => function() { return 'BAR'; })), + array('foo | bar | baz', array('baz' => function() { return 'BAZ'; })), + array('foo | bar.baz', array('foo' => 'FOO', 'bar' => function() { return 'BAR'; }, 'baz' => function() { return 'BAZ'; })), + ); + } + +} From 6b7f33c78df302da3048cd156d5866dab420e104 Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Sat, 14 Dec 2013 10:45:17 -0800 Subject: [PATCH 26/32] Add passthrough optimization for lambda sections. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Higher order sections which return mustache-free strings don’t need to be re-parsed, compiled and rendered. Just use the string, silly! Fixes #141 --- src/Mustache/Compiler.php | 11 +++++-- .../Functional/HigherOrderSectionsTest.php | 29 +++++++++++++++++++ 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/src/Mustache/Compiler.php b/src/Mustache/Compiler.php index c38ca43..c13e60f 100644 --- a/src/Mustache/Compiler.php +++ b/src/Mustache/Compiler.php @@ -188,9 +188,14 @@ class Mustache_Compiler $buffer = \'\'; if (%s) { $source = %s; - $buffer .= $this->mustache - ->loadLambda((string) call_user_func($value, $source, $this->lambdaHelper)%s) - ->renderInternal($context); + $result = call_user_func($value, $source, $this->lambdaHelper); + if (strpos($result, \'{{\') === false) { + $buffer .= $result; + } else { + $buffer .= $this->mustache + ->loadLambda((string) $result%s) + ->renderInternal($context); + } } elseif (!empty($value)) { $values = $this->isIterable($value) ? $value : array($value); foreach ($values as $value) { diff --git a/test/Mustache/Test/Functional/HigherOrderSectionsTest.php b/test/Mustache/Test/Functional/HigherOrderSectionsTest.php index 0919656..078988b 100644 --- a/test/Mustache/Test/Functional/HigherOrderSectionsTest.php +++ b/test/Mustache/Test/Functional/HigherOrderSectionsTest.php @@ -71,6 +71,35 @@ class Mustache_Test_Functional_HigherOrderSectionsTest extends PHPUnit_Framework $dracula->name = 'Dracula'; $this->assertEquals('Count Dracula', $tpl->render($dracula)); } + + public function testPassthroughOptimization() + { + $mustache = $this->getMock('Mustache_Engine', array('loadLambda')); + $mustache->expects($this->never()) + ->method('loadLambda'); + + $tpl = $mustache->loadTemplate('{{#wrap}}NAME{{/wrap}}'); + + $foo = new Mustache_Test_Functional_Foo; + $foo->wrap = array($foo, 'wrapWithEm'); + + $this->assertEquals('NAME', $tpl->render($foo)); + } + + public function testWithoutPassthroughOptimization() + { + $mustache = $this->getMock('Mustache_Engine', array('loadLambda')); + $mustache->expects($this->once()) + ->method('loadLambda') + ->will($this->returnValue($mustache->loadTemplate('{{ name }}'))); + + $tpl = $mustache->loadTemplate('{{#wrap}}{{name}}{{/wrap}}'); + + $foo = new Mustache_Test_Functional_Foo; + $foo->wrap = array($foo, 'wrapWithEm'); + + $this->assertEquals('' . $foo->name . '', $tpl->render($foo)); + } } class Mustache_Test_Functional_Foo From 2b5d9e5f39e72253792716d50a63a43bc29c2c94 Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Sat, 14 Dec 2013 11:50:57 -0800 Subject: [PATCH 27/32] Add 'cache_lambda_templates' config option. Stop caching lambda templates by default, as they are generally too dynamic. Make lambda template caching an explicit opt-in. This will prevent filling cache directories with unusable files, and will actually speed things up the first time any given lambda template is used. Fixes #180 --- src/Mustache/Engine.php | 46 +++++++++++++++++++++++++++++-- test/Mustache/Test/EngineTest.php | 27 ++++++++++++++++++ 2 files changed, 70 insertions(+), 3 deletions(-) diff --git a/src/Mustache/Engine.php b/src/Mustache/Engine.php index d03d479..6d7ab98 100644 --- a/src/Mustache/Engine.php +++ b/src/Mustache/Engine.php @@ -34,6 +34,8 @@ class Mustache_Engine // Environment private $templateClassPrefix = '__Mustache_'; private $cache; + private $lambdaCache; + private $cacheLambdaTemplates = false; private $loader; private $partialsLoader; private $helpers; @@ -60,6 +62,10 @@ class Mustache_Engine * // *strongly* recommended that you configure your umask properly rather than overriding permissions here. * 'cache_file_mode' => 0666, * + * // Optionally, enable caching for lambda section templates. This is generally not recommended, as lambda + * // sections are often too dynamic to benefit from caching. + * 'cache_lambda_templates' => true, + * * // A Mustache template loader instance. Uses a StringLoader if not specified. * 'loader' => new Mustache_Loader_FilesystemLoader(dirname(__FILE__).'/views'), * @@ -122,6 +128,10 @@ class Mustache_Engine $this->setCache($cache); } + if (isset($options['cache_lambda_templates'])) { + $this->cacheLambdaTemplates = (bool) $options['cache_lambda_templates']; + } + if (isset($options['loader'])) { $this->setLoader($options['loader']); } @@ -516,6 +526,28 @@ class Mustache_Engine return $this->cache; } + /** + * Get the current Lambda Cache instance. + * + * If 'cache_lambda_templates' is enabled, this is the default cache instance. Otherwise, it is a NoopCache. + * + * @see Mustache_Engine::getCache + * + * @return Mustache_Cache + */ + protected function getLambdaCache() + { + if ($this->cacheLambdaTemplates) { + return $this->getCache(); + } + + if (!isset($this->lambdaCache)) { + $this->lambdaCache = new Mustache_Cache_NoopCache(); + } + + return $this->lambdaCache; + } + /** * Helper method to generate a Mustache template class. * @@ -597,25 +629,33 @@ class Mustache_Engine $source = $delims . "\n" . $source; } - return $this->loadSource($source); + return $this->loadSource($source, $this->getLambdaCache()); } /** * Instantiate and return a Mustache Template instance by source. * + * Optionally provide a Mustache_Cache instance. This is used internally by Mustache_Engine::loadLambda to respect + * the 'cache_lambda_templates' configuration option. + * * @see Mustache_Engine::loadTemplate * @see Mustache_Engine::loadPartial * @see Mustache_Engine::loadLambda * - * @param string $source + * @param string $source + * @param Mustache_Cache $cache (default: null) * * @return Mustache_Template */ - private function loadSource($source) + private function loadSource($source, Mustache_Cache $cache = null) { $className = $this->getTemplateClassName($source); if (!isset($this->templates[$className])) { + if ($cache === null) { + $cache = $this->getCache(); + } + if (!class_exists($className, false)) { if (!$this->getCache()->load($className)) { $compiled = $this->compile($source); diff --git a/test/Mustache/Test/EngineTest.php b/test/Mustache/Test/EngineTest.php index 81b72d1..1c71158 100644 --- a/test/Mustache/Test/EngineTest.php +++ b/test/Mustache/Test/EngineTest.php @@ -144,6 +144,27 @@ class Mustache_Test_EngineTest extends PHPUnit_Framework_TestCase $this->assertInstanceOf($className, $template); } + public function testLambdaCache() + { + $mustache = new MustacheStub(array( + 'cache' => self::$tempDir, + 'cache_lambda_templates' => true, + )); + + $this->assertNotInstanceOf('Mustache_Cache_NoopCache', $mustache->getProtectedLambdaCache()); + $this->assertSame($mustache->getCache(), $mustache->getProtectedLambdaCache()); + } + + public function testWithoutLambdaCache() + { + $mustache = new MustacheStub(array( + 'cache' => self::$tempDir + )); + + $this->assertInstanceOf('Mustache_Cache_NoopCache', $mustache->getProtectedLambdaCache()); + $this->assertNotSame($mustache->getCache(), $mustache->getProtectedLambdaCache()); + } + /** * @expectedException Mustache_Exception_InvalidArgumentException * @dataProvider getBadEscapers @@ -352,10 +373,16 @@ class MustacheStub extends Mustache_Engine { public $source; public $template; + public function loadTemplate($source) { $this->source = $source; return $this->template; } + + public function getProtectedLambdaCache() + { + return $this->getLambdaCache(); + } } From 77b88cd74fd18ae4f3231cc0faef11b5173886fd Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Sat, 14 Dec 2013 12:29:56 -0800 Subject: [PATCH 28/32] Fix param names in NoopCache. --- src/Mustache/Cache/NoopCache.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Mustache/Cache/NoopCache.php b/src/Mustache/Cache/NoopCache.php index 0056de0..d742785 100644 --- a/src/Mustache/Cache/NoopCache.php +++ b/src/Mustache/Cache/NoopCache.php @@ -33,17 +33,17 @@ class Mustache_Cache_NoopCache extends Mustache_Cache_AbstractCache * Loads the compiled Mustache Template class without caching. * * @param string $key - * @param string $compiled + * @param string $value * * @return void */ - public function cache($key, $compiled) + public function cache($key, $value) { $this->log( Mustache_Logger::WARNING, 'Template cache disabled, evaluating "{className}" class at runtime', array('className' => $key) ); - eval("?>".$compiled); + eval('?>' . $value); } } From e24f5c744ad7638302a0b176417f40e981ae6e65 Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Sat, 14 Dec 2013 12:36:47 -0800 Subject: [PATCH 29/32] Minor docblock updates. --- src/Mustache/Cache/FilesystemCache.php | 2 +- src/Mustache/Cache/NoopCache.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Mustache/Cache/FilesystemCache.php b/src/Mustache/Cache/FilesystemCache.php index a15ef61..e4926bc 100644 --- a/src/Mustache/Cache/FilesystemCache.php +++ b/src/Mustache/Cache/FilesystemCache.php @@ -17,7 +17,7 @@ * $cache = new Mustache_Cache_FilesystemCache(dirname(__FILE__).'/cache'); * $cache->cache($className, $compiledSource); * - * Benefits from any opcode caching that may be setup in your environment. + * The FilesystemCache benefits from any opcode caching that may be setup in your environment. So do that, k? */ class Mustache_Cache_FilesystemCache extends Mustache_Cache_AbstractCache { diff --git a/src/Mustache/Cache/NoopCache.php b/src/Mustache/Cache/NoopCache.php index d742785..a5b9ad9 100644 --- a/src/Mustache/Cache/NoopCache.php +++ b/src/Mustache/Cache/NoopCache.php @@ -12,8 +12,8 @@ /** * Mustache Cache in-memory implementation. * - * In-memory implementation useful during development. - * Not recommended for production use. + * The in-memory cache is used for uncached lambda section templates. It's also useful during development, but is not + * recommended for production use. */ class Mustache_Cache_NoopCache extends Mustache_Cache_AbstractCache { From 3a9a8bde3643f0e5b2f0fb7ecff3e54720ca932d Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Sat, 14 Dec 2013 12:37:05 -0800 Subject: [PATCH 30/32] Update bin/build_bootstrap.php for Cache classes. --- bin/build_bootstrap.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bin/build_bootstrap.php b/bin/build_bootstrap.php index 834f3f7..061532b 100755 --- a/bin/build_bootstrap.php +++ b/bin/build_bootstrap.php @@ -34,6 +34,10 @@ if (file_exists($file)) { // and load the new one SymfonyClassCollectionLoader::load(array( 'Mustache_Engine', + 'Mustache_Cache', + 'Mustache_Cache_AbstractCache', + 'Mustache_Cache_FilesystemCache', + 'Mustache_Cache_NoopCache', 'Mustache_Compiler', 'Mustache_Context', 'Mustache_Exception', From a467124a4654eb50f6e18783ef4ab5ff35c2edaf Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Sat, 14 Dec 2013 12:50:51 -0800 Subject: [PATCH 31/32] Improve test coverage. --- .../Mustache/Test/Cache/AbstractCacheTest.php | 44 +++++++++++++++++++ test/Mustache/Test/EngineTest.php | 2 + 2 files changed, 46 insertions(+) create mode 100644 test/Mustache/Test/Cache/AbstractCacheTest.php diff --git a/test/Mustache/Test/Cache/AbstractCacheTest.php b/test/Mustache/Test/Cache/AbstractCacheTest.php new file mode 100644 index 0000000..142c12e --- /dev/null +++ b/test/Mustache/Test/Cache/AbstractCacheTest.php @@ -0,0 +1,44 @@ +setLogger($logger); + $this->assertSame($logger, $cache->getLogger()); + } + + /** + * @expectedException Mustache_Exception_InvalidArgumentException + */ + public function testSetLoggerThrowsExceptions() + { + $cache = new CacheStub(); + $logger = new StdClass(); + $cache->setLogger($logger); + } +} + +class CacheStub extends Mustache_Cache_AbstractCache +{ + public function load($key) + { + // nada + } + + public function cache($key, $value) + { + // nada + } +} diff --git a/test/Mustache/Test/EngineTest.php b/test/Mustache/Test/EngineTest.php index 1c71158..1ab3078 100644 --- a/test/Mustache/Test/EngineTest.php +++ b/test/Mustache/Test/EngineTest.php @@ -45,6 +45,7 @@ class Mustache_Test_EngineTest extends PHPUnit_Framework_TestCase 'bar' => 'BAR', ), 'escape' => 'strtoupper', + 'entity_flags' => ENT_QUOTES, 'charset' => 'ISO-8859-1', )); @@ -54,6 +55,7 @@ class Mustache_Test_EngineTest extends PHPUnit_Framework_TestCase $this->assertEquals('{{ foo }}', $partialsLoader->load('foo')); $this->assertContains('__whot__', $mustache->getTemplateClassName('{{ foo }}')); $this->assertEquals('strtoupper', $mustache->getEscape()); + $this->assertEquals(ENT_QUOTES, $mustache->getEntityFlags()); $this->assertEquals('ISO-8859-1', $mustache->getCharset()); $this->assertTrue($mustache->hasHelper('foo')); $this->assertTrue($mustache->hasHelper('bar')); From bd2a1fa492e665d74f5933d549453911bdb1492a Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Sat, 14 Dec 2013 12:57:36 -0800 Subject: [PATCH 32/32] Bump to v2.5.0 --- src/Mustache/Engine.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mustache/Engine.php b/src/Mustache/Engine.php index 6d7ab98..abe17b2 100644 --- a/src/Mustache/Engine.php +++ b/src/Mustache/Engine.php @@ -23,7 +23,7 @@ */ class Mustache_Engine { - const VERSION = '2.4.1'; + const VERSION = '2.5.0'; const SPEC_VERSION = '1.1.2'; const PRAGMA_FILTERS = 'FILTERS';