Coding standard cleanup.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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]);
|
||||
|
||||
@@ -53,7 +53,7 @@ class Tokenizer {
|
||||
private $state;
|
||||
private $tagType;
|
||||
private $tag;
|
||||
private $buf;
|
||||
private $buffer;
|
||||
private $tokens;
|
||||
private $seenTag;
|
||||
private $lineStart;
|
||||
|
||||
@@ -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 '<foo>';
|
||||
}
|
||||
|
||||
public function bar() {
|
||||
return '<bar>';
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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('<strong><em>%s</em></strong>', $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() {
|
||||
|
||||
@@ -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'
|
||||
);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -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';
|
||||
|
||||
Reference in New Issue
Block a user