diff --git a/src/Mustache/Buffer.php b/src/Mustache/Buffer.php index f2fac5d..45421bf 100644 --- a/src/Mustache/Buffer.php +++ b/src/Mustache/Buffer.php @@ -71,7 +71,7 @@ class Buffer { * @see \Mustache\Buffer::write * * @param string $text - * @param bool $escape Escape this text with `htmlspecialchars()`? (default: false) + * @param bool $escape Escape this text with `htmlspecialchars()`? (default: false) */ public function writeText($text, $escape = false) { $this->write($text, true, $escape); @@ -81,8 +81,8 @@ class Buffer { * Add output to the Buffer. * * @param string $text - * @param bool $indent Indent this line? (default: false) - * @param bool $escape Escape this text with `htmlspecialchars()`? (default: false) + * @param bool $indent Indent this line? (default: false) + * @param bool $escape Escape this text with `htmlspecialchars()`? (default: false) */ public function write($text, $indent = false, $escape = false) { $text = (string) $text; diff --git a/src/Mustache/Compiler.php b/src/Mustache/Compiler.php index 3ca3f48..fb6213a 100644 --- a/src/Mustache/Compiler.php +++ b/src/Mustache/Compiler.php @@ -253,7 +253,7 @@ class Compiler { * Prepare PHP source code snippet for output. * * @param string $text - * @param int $bonus Additional indent level (default: 0) + * @param int $bonus Additional indent level (default: 0) * @param boolean $prependNewline Prepend a newline to the snippet? (default: true) * * @return string PHP source code snippet diff --git a/src/Mustache/Context.php b/src/Mustache/Context.php index 63ee1e8..05c9b1f 100644 --- a/src/Mustache/Context.php +++ b/src/Mustache/Context.php @@ -180,7 +180,7 @@ class Context { * * @see \Mustache\Context::find * - * @param string $id Variable name + * @param string $id Variable name * @param array $stack Context stack * * @return mixed Variable value, or '' if not found diff --git a/src/Mustache/Loader.php b/src/Mustache/Loader.php index 57991b6..06a60b1 100644 --- a/src/Mustache/Loader.php +++ b/src/Mustache/Loader.php @@ -10,7 +10,7 @@ interface Loader { /** * Load a Template by name. * - * @param string $name + * @param string $name * * @return string Mustache Template source */ diff --git a/src/Mustache/Loader/ArrayLoader.php b/src/Mustache/Loader/ArrayLoader.php index 5a62e15..0386fea 100644 --- a/src/Mustache/Loader/ArrayLoader.php +++ b/src/Mustache/Loader/ArrayLoader.php @@ -37,7 +37,7 @@ class ArrayLoader implements Loader, MutableLoader { /** * Load a Template. * - * @param string $name + * @param string $name * * @return string Mustache Template source */ diff --git a/src/Mustache/Loader/FilesystemLoader.php b/src/Mustache/Loader/FilesystemLoader.php index e510fc9..1aff730 100644 --- a/src/Mustache/Loader/FilesystemLoader.php +++ b/src/Mustache/Loader/FilesystemLoader.php @@ -59,7 +59,7 @@ class FilesystemLoader implements Loader { * $loader = new FilesystemLoader(__DIR__.'/views'); * $loader->load('admin/dashboard'); // loads "./views/admin/dashboard.mustache"; * - * @param string $name + * @param string $name * * @return string Mustache Template source */ diff --git a/src/Mustache/Loader/StringLoader.php b/src/Mustache/Loader/StringLoader.php index d27bad0..6cd85e1 100644 --- a/src/Mustache/Loader/StringLoader.php +++ b/src/Mustache/Loader/StringLoader.php @@ -25,7 +25,7 @@ class StringLoader implements Loader { /** * Load a Template by source. * - * @param string $name Mustache Template source + * @param string $name Mustache Template source * * @return string Mustache Template source */ diff --git a/src/Mustache/Mustache.php b/src/Mustache/Mustache.php index 98df8b0..57fd2e9 100644 --- a/src/Mustache/Mustache.php +++ b/src/Mustache/Mustache.php @@ -19,7 +19,7 @@ use Mustache\Loader\StringLoader; * @author Justin Hileman {@link http://justinhileman.com} */ class Mustache { - const VERSION = '2.0.0-a1'; + const VERSION = '2.0.0-dev'; const SPEC_VERSION = '1.1.2'; // Template cache @@ -188,7 +188,7 @@ class Mustache { /** * Set the Mustache Parser instance. * - * @param \Mustache\Parser $tokenizer + * @param \Mustache\Parser $parser */ public function setParser(Parser $parser) { $this->parser = $parser; @@ -212,7 +212,7 @@ class Mustache { /** * Set the Mustache Compiler instance. * - * @param \Mustache\Compiler $tokenizer + * @param \Mustache\Compiler $compiler */ public function setCompiler(Compiler $compiler) { $this->compiler = $compiler; diff --git a/src/Mustache/Parser.php b/src/Mustache/Parser.php index d330913..4b2856f 100644 --- a/src/Mustache/Parser.php +++ b/src/Mustache/Parser.php @@ -12,7 +12,7 @@ class Parser { /** * Process an array of Mustache tokens and convert them into a parse tree. * - * @param array $tree Set of Mustache tokens + * @param array $tokens Set of Mustache tokens * * @return array Mustache token parse tree */ @@ -69,7 +69,7 @@ class Parser { $nodes[] = $token; } - } while($tokens->valid()); + } while ($tokens->valid()); if (isset($parent)) { throw new \LogicException('Missing closing tag: ' . $parent[Tokenizer::NAME]); diff --git a/src/Mustache/Tokenizer.php b/src/Mustache/Tokenizer.php index 1074397..b9a84ce 100644 --- a/src/Mustache/Tokenizer.php +++ b/src/Mustache/Tokenizer.php @@ -53,7 +53,7 @@ class Tokenizer { private $state; private $tagType; private $tag; - private $buf; + private $buffer; private $tokens; private $seenTag; private $lineStart; diff --git a/test/Mustache/Test/ContextTest.php b/test/Mustache/Test/ContextTest.php index 678e976..ea6d1dc 100644 --- a/test/Mustache/Test/ContextTest.php +++ b/test/Mustache/Test/ContextTest.php @@ -45,7 +45,9 @@ class ContextTest extends \PHPUnit_Framework_TestCase { $dummy = new TestDummy; $context = new Context; - $this->assertTrue($context->isCallable(function() { return null; })); + $this->assertTrue($context->isCallable(function() { + return null; + })); $this->assertTrue($context->isCallable(array('\Mustache\Test\TestDummy', 'foo'))); $this->assertTrue($context->isCallable(array($dummy, 'bar'))); $this->assertTrue($context->isCallable($dummy)); @@ -140,10 +142,15 @@ class ContextTest extends \PHPUnit_Framework_TestCase { class TestDummy { public $name = 'dummy'; - public function __invoke() {} + + public function __invoke() { + // nothing + } + public static function foo() { return ''; } + public function bar() { return ''; } diff --git a/test/Mustache/Test/Functional/ExamplesTest.php b/test/Mustache/Test/Functional/ExamplesTest.php index 6aff929..1a25dbc 100644 --- a/test/Mustache/Test/Functional/ExamplesTest.php +++ b/test/Mustache/Test/Functional/ExamplesTest.php @@ -64,6 +64,7 @@ class ExamplesTest extends \PHPUnit_Framework_TestCase { * Helper method to load an example given the full path. * * @param string $path + * * @return array arguments for testExamples */ private function loadExample($path) { @@ -106,7 +107,7 @@ class ExamplesTest extends \PHPUnit_Framework_TestCase { /** * Helper method to load partials given an example directory. * - * @param string $path + * @param string $path * * @return array $partials */ diff --git a/test/Mustache/Test/Functional/HigherOrderSectionsTest.php b/test/Mustache/Test/Functional/HigherOrderSectionsTest.php index 680efd7..b7b4790 100644 --- a/test/Mustache/Test/Functional/HigherOrderSectionsTest.php +++ b/test/Mustache/Test/Functional/HigherOrderSectionsTest.php @@ -40,10 +40,10 @@ class HigherOrderSectionsTest extends \PHPUnit_Framework_TestCase { } public function testRuntimeSectionCallback() { - $tpl = $this->mustache->loadTemplate('{{#double_wrap}}{{name}}{{/double_wrap}}'); + $tpl = $this->mustache->loadTemplate('{{#doublewrap}}{{name}}{{/doublewrap}}'); $foo = new Foo; - $foo->double_wrap = array($foo, 'wrapWithBoth'); + $foo->doublewrap = array($foo, 'wrapWithBoth'); $this->assertEquals(sprintf('%s', $foo->name), $tpl->render($foo)); } @@ -80,10 +80,7 @@ class HigherOrderSectionsTest extends \PHPUnit_Framework_TestCase { } ); - $this->assertEquals( - sprintf('[[%s]]', $data['name']), - $tpl->render($data) - ); + $this->assertEquals(sprintf('[[%s]]', $data['name']), $tpl->render($data)); } public function testMonsters() { diff --git a/test/Mustache/Test/Functional/MustacheInjectionTest.php b/test/Mustache/Test/Functional/MustacheInjectionTest.php index eec0e1c..056f660 100644 --- a/test/Mustache/Test/Functional/MustacheInjectionTest.php +++ b/test/Mustache/Test/Functional/MustacheInjectionTest.php @@ -105,7 +105,9 @@ class MustacheInjectionTest extends \PHPUnit_Framework_TestCase { $tpl = $this->mustache->loadTemplate('{{ a }}'); $data = array( - 'a' => function() { return '{{ b }}'; }, + 'a' => function() { + return '{{ b }}'; + }, 'b' => '{{ c }}', 'c' => 'FAIL' ); @@ -117,7 +119,9 @@ class MustacheInjectionTest extends \PHPUnit_Framework_TestCase { $tpl = $this->mustache->loadTemplate('{{# a }}b{{/ a }}'); $data = array( - 'a' => function ($text) { return '{{ ' . $text . ' }}'; }, + 'a' => function ($text) { + return '{{ ' . $text . ' }}'; + }, 'b' => '{{ c }}', 'c' => 'FAIL' ); diff --git a/test/Mustache/Test/Functional/MustacheSpecTest.php b/test/Mustache/Test/Functional/MustacheSpecTest.php index 831a029..a9ece89 100644 --- a/test/Mustache/Test/Functional/MustacheSpecTest.php +++ b/test/Mustache/Test/Functional/MustacheSpecTest.php @@ -106,11 +106,14 @@ class MustacheSpecTest extends \PHPUnit_Framework_TestCase { } $func = $val['php']; - $data[$key] = function($text = null) use ($func) { return eval($func); }; + $data[$key] = function($text = null) use ($func) { + return eval($func); + }; } else if (is_array($val)) { $data[$key] = $this->prepareLambdasSpec($val); } } + return $data; } diff --git a/test/Mustache/Test/MustacheTest.php b/test/Mustache/Test/MustacheTest.php index 9883058..f343077 100644 --- a/test/Mustache/Test/MustacheTest.php +++ b/test/Mustache/Test/MustacheTest.php @@ -23,26 +23,6 @@ class MustacheTest extends \PHPUnit_Framework_TestCase { } } - 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); - } - public function testConstructor() { $loader = new StringLoader; $partialsLoader = new ArrayLoader; @@ -133,6 +113,25 @@ class MustacheTest extends \PHPUnit_Framework_TestCase { $mustache->setPartials(array('foo' => '{{ foo }}')); } + 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/bootstrap.php b/test/bootstrap.php index f022da1..ced28b8 100644 --- a/test/bootstrap.php +++ b/test/bootstrap.php @@ -6,8 +6,8 @@ require __DIR__.'/../src/Mustache/Context.php'; require __DIR__.'/../src/Mustache/Loader.php'; require __DIR__.'/../src/Mustache/Loader/MutableLoader.php'; require __DIR__.'/../src/Mustache/Loader/ArrayLoader.php'; -require __DIR__.'/../src/Mustache/Loader/StringLoader.php'; require __DIR__.'/../src/Mustache/Loader/FilesystemLoader.php'; +require __DIR__.'/../src/Mustache/Loader/StringLoader.php'; require __DIR__.'/../src/Mustache/Mustache.php'; require __DIR__.'/../src/Mustache/Parser.php'; require __DIR__.'/../src/Mustache/Template.php';