Clean up comments, standardize whitespace.

This commit is contained in:
Justin Hileman
2013-09-18 23:49:44 -07:00
parent 0d161cc7d2
commit cb2a6b5a03
13 changed files with 98 additions and 64 deletions
+2
View File
@@ -21,6 +21,7 @@ interface Mustache_Cache
* Load a compiled Mustache_Template class from cache. * Load a compiled Mustache_Template class from cache.
* *
* @param string $key * @param string $key
*
* @return boolean indicates successfully class load * @return boolean indicates successfully class load
*/ */
public function load($key); public function load($key);
@@ -30,6 +31,7 @@ interface Mustache_Cache
* *
* @param string $key * @param string $key
* @param string $value * @param string $value
*
* @return void * @return void
*/ */
public function cache($key, $value); public function cache($key, $value);
+17
View File
@@ -20,11 +20,21 @@ abstract class Mustache_Cache_AbstractCache implements Mustache_Cache
{ {
private $logger = null; private $logger = null;
/**
* Get the current logger instance.
*
* @return Mustache_Logger|Psr\Log\LoggerInterface
*/
public function getLogger() public function getLogger()
{ {
return $this->logger; return $this->logger;
} }
/**
* Set a logger instance.
*
* @param Mustache_Logger|Psr\Log\LoggerInterface $logger
*/
public function setLogger($logger = null) public function setLogger($logger = null)
{ {
if ($logger !== null && !($logger instanceof Mustache_Logger || is_a($logger, 'Psr\\Log\\LoggerInterface'))) { 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; $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()) protected function log($level, $message, array $context = array())
{ {
if (isset($this->logger)) { if (isset($this->logger)) {
+11 -5
View File
@@ -40,6 +40,7 @@ class Mustache_Cache_FilesystemCache extends Mustache_Cache_AbstractCache
* Load the class from cache using `require_once`. * Load the class from cache using `require_once`.
* *
* @param string $key * @param string $key
*
* @return boolean * @return boolean
*/ */
public function load($key) public function load($key)
@@ -59,6 +60,7 @@ class Mustache_Cache_FilesystemCache extends Mustache_Cache_AbstractCache
* *
* @param string $key * @param string $key
* @param string $value * @param string $value
*
* @return void * @return void
*/ */
public function cache($key, $value) public function cache($key, $value)
@@ -80,6 +82,7 @@ class Mustache_Cache_FilesystemCache extends Mustache_Cache_AbstractCache
* Subclasses should override for custom cache directory structures. * Subclasses should override for custom cache directory structures.
* *
* @param string $name * @param string $name
*
* @return string * @return string
*/ */
protected function getCacheFilename($name) protected function getCacheFilename($name)
@@ -90,10 +93,11 @@ class Mustache_Cache_FilesystemCache extends Mustache_Cache_AbstractCache
/** /**
* Create cache directory * Create cache directory
* *
* @param string $fileName
* @return string
*
* @throws Mustache_Exception_RuntimeException If unable to create directory * @throws Mustache_Exception_RuntimeException If unable to create directory
*
* @param string $fileName
*
* @return string
*/ */
private function buildDirectoryForFilename($fileName) 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)); throw new Mustache_Exception_RuntimeException(sprintf('Failed to create cache directory "%s".', $dirName));
} }
} }
return $dirName; return $dirName;
} }
/** /**
* Write cache file * Write cache file
* *
* @throws Mustache_Exception_RuntimeException If unable to write file
*
* @param string $fileName * @param string $fileName
* @param string $value * @param string $value
* @return void
* *
* @throws Mustache_Exception_RuntimeException If unable to write file * @return void
*/ */
private function writeFile($fileName, $value) private function writeFile($fileName, $value)
{ {
+2
View File
@@ -21,6 +21,7 @@ class Mustache_Cache_NoopCache extends Mustache_Cache_AbstractCache
* Loads nothing. Move along. * Loads nothing. Move along.
* *
* @param string $key * @param string $key
*
* @return boolean * @return boolean
*/ */
public function load($key) public function load($key)
@@ -33,6 +34,7 @@ class Mustache_Cache_NoopCache extends Mustache_Cache_AbstractCache
* *
* @param string $key * @param string $key
* @param string $compiled * @param string $compiled
*
* @return void * @return void
*/ */
public function cache($key, $compiled) public function cache($key, $compiled)
+1 -1
View File
@@ -53,7 +53,7 @@ class Mustache_Engine
* 'template_class_prefix' => '__MyTemplates_', * 'template_class_prefix' => '__MyTemplates_',
* *
* // A Mustache cache instance or a cache directory string for compiled templates. * // 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', * 'cache' => dirname(__FILE__).'/tmp/cache/mustache',
* *
* // Override default permissions for cache files. Defaults to using the system-defined umask. It is * // Override default permissions for cache files. Defaults to using the system-defined umask. It is
+9
View File
@@ -45,6 +45,7 @@ interface Mustache_Logger
* *
* @param string $message * @param string $message
* @param array $context * @param array $context
*
* @return null * @return null
*/ */
public function emergency($message, array $context = array()); public function emergency($message, array $context = array());
@@ -57,6 +58,7 @@ interface Mustache_Logger
* *
* @param string $message * @param string $message
* @param array $context * @param array $context
*
* @return null * @return null
*/ */
public function alert($message, array $context = array()); public function alert($message, array $context = array());
@@ -68,6 +70,7 @@ interface Mustache_Logger
* *
* @param string $message * @param string $message
* @param array $context * @param array $context
*
* @return null * @return null
*/ */
public function critical($message, array $context = array()); public function critical($message, array $context = array());
@@ -78,6 +81,7 @@ interface Mustache_Logger
* *
* @param string $message * @param string $message
* @param array $context * @param array $context
*
* @return null * @return null
*/ */
public function error($message, array $context = array()); public function error($message, array $context = array());
@@ -90,6 +94,7 @@ interface Mustache_Logger
* *
* @param string $message * @param string $message
* @param array $context * @param array $context
*
* @return null * @return null
*/ */
public function warning($message, array $context = array()); public function warning($message, array $context = array());
@@ -99,6 +104,7 @@ interface Mustache_Logger
* *
* @param string $message * @param string $message
* @param array $context * @param array $context
*
* @return null * @return null
*/ */
public function notice($message, array $context = array()); public function notice($message, array $context = array());
@@ -110,6 +116,7 @@ interface Mustache_Logger
* *
* @param string $message * @param string $message
* @param array $context * @param array $context
*
* @return null * @return null
*/ */
public function info($message, array $context = array()); public function info($message, array $context = array());
@@ -119,6 +126,7 @@ interface Mustache_Logger
* *
* @param string $message * @param string $message
* @param array $context * @param array $context
*
* @return null * @return null
*/ */
public function debug($message, array $context = array()); public function debug($message, array $context = array());
@@ -129,6 +137,7 @@ interface Mustache_Logger
* @param mixed $level * @param mixed $level
* @param string $message * @param string $message
* @param array $context * @param array $context
*
* @return null * @return null
*/ */
public function log($level, $message, array $context = array()); public function log($level, $message, array $context = array());
@@ -42,7 +42,6 @@ EOS;
$tpl = $m->loadTemplate($src); $tpl = $m->loadTemplate($src);
$data = new Mustache_Test_Functional_ClassWithLambda(); $data = new Mustache_Test_Functional_ClassWithLambda();
$this->assertEquals($expected, $tpl->render($data)); $this->assertEquals($expected, $tpl->render($data));
} }
@@ -73,7 +73,6 @@ class Mustache_Test_FiveThree_Functional_StrictCallablesTest extends PHPUnit_Fra
); );
} }
/** /**
* @group wip * @group wip
* @dataProvider strictCallables * @dataProvider strictCallables