Skip to content

Commit

Permalink
Coding standard cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
bobthecow committed Mar 1, 2012
1 parent 0034bf6 commit 5c4fcd0
Show file tree
Hide file tree
Showing 17 changed files with 59 additions and 48 deletions.
6 changes: 3 additions & 3 deletions src/Mustache/Buffer.php
Expand Up @@ -71,7 +71,7 @@ public function writeLine() {
* @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);
Expand All @@ -81,8 +81,8 @@ public function writeText($text, $escape = false) {
* 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;
Expand Down
2 changes: 1 addition & 1 deletion src/Mustache/Compiler.php
Expand Up @@ -253,7 +253,7 @@ private function text($text, $level) {
* 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
Expand Down
2 changes: 1 addition & 1 deletion src/Mustache/Context.php
Expand Up @@ -180,7 +180,7 @@ public function findDot($id) {
*
* @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
Expand Down
2 changes: 1 addition & 1 deletion src/Mustache/Loader.php
Expand Up @@ -10,7 +10,7 @@ interface Loader {
/**
* Load a Template by name.
*
* @param string $name
* @param string $name
*
* @return string Mustache Template source
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Mustache/Loader/ArrayLoader.php
Expand Up @@ -37,7 +37,7 @@ public function __construct(array $templates = array()) {
/**
* Load a Template.
*
* @param string $name
* @param string $name
*
* @return string Mustache Template source
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Mustache/Loader/FilesystemLoader.php
Expand Up @@ -59,7 +59,7 @@ public function __construct($baseDir, array $options = array()) {
* $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
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Mustache/Loader/StringLoader.php
Expand Up @@ -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
*/
Expand Down
6 changes: 3 additions & 3 deletions src/Mustache/Mustache.php
Expand Up @@ -19,7 +19,7 @@
* @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
Expand Down Expand Up @@ -188,7 +188,7 @@ public function getTokenizer() {
/**
* Set the Mustache Parser instance.
*
* @param \Mustache\Parser $tokenizer
* @param \Mustache\Parser $parser
*/
public function setParser(Parser $parser) {
$this->parser = $parser;
Expand All @@ -212,7 +212,7 @@ public function getParser() {
/**
* Set the Mustache Compiler instance.
*
* @param \Mustache\Compiler $tokenizer
* @param \Mustache\Compiler $compiler
*/
public function setCompiler(Compiler $compiler) {
$this->compiler = $compiler;
Expand Down
4 changes: 2 additions & 2 deletions src/Mustache/Parser.php
Expand Up @@ -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
*/
Expand Down Expand Up @@ -69,7 +69,7 @@ private function buildTree(\ArrayIterator $tokens, array $parent = null) {
$nodes[] = $token;
}

} while($tokens->valid());
} while ($tokens->valid());

if (isset($parent)) {
throw new \LogicException('Missing closing tag: ' . $parent[Tokenizer::NAME]);
Expand Down
2 changes: 1 addition & 1 deletion src/Mustache/Tokenizer.php
Expand Up @@ -53,7 +53,7 @@ class Tokenizer {
private $state;
private $tagType;
private $tag;
private $buf;
private $buffer;
private $tokens;
private $seenTag;
private $lineStart;
Expand Down
11 changes: 9 additions & 2 deletions test/Mustache/Test/ContextTest.php
Expand Up @@ -45,7 +45,9 @@ public function testIsCallable() {
$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));
Expand Down Expand Up @@ -140,10 +142,15 @@ public function testFind() {

class TestDummy {
public $name = 'dummy';
public function __invoke() {}

public function __invoke() {
// nothing
}

public static function foo() {
return '<foo>';
}

public function bar() {
return '<bar>';
}
Expand Down
3 changes: 2 additions & 1 deletion test/Mustache/Test/Functional/ExamplesTest.php
Expand Up @@ -64,6 +64,7 @@ public function getExamples() {
* Helper method to load an example given the full path.
*
* @param string $path
*
* @return array arguments for testExamples
*/
private function loadExample($path) {
Expand Down Expand Up @@ -106,7 +107,7 @@ private function loadExample($path) {
/**
* Helper method to load partials given an example directory.
*
* @param string $path
* @param string $path
*
* @return array $partials
*/
Expand Down
9 changes: 3 additions & 6 deletions test/Mustache/Test/Functional/HigherOrderSectionsTest.php
Expand Up @@ -40,10 +40,10 @@ public function testSectionCallback() {
}

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));
}
Expand Down Expand Up @@ -80,10 +80,7 @@ public function testViewArrayAnonymousSectionCallback() {
}
);

$this->assertEquals(
sprintf('[[%s]]', $data['name']),
$tpl->render($data)
);
$this->assertEquals(sprintf('[[%s]]', $data['name']), $tpl->render($data));
}

public function testMonsters() {
Expand Down
8 changes: 6 additions & 2 deletions test/Mustache/Test/Functional/MustacheInjectionTest.php
Expand Up @@ -105,7 +105,9 @@ public function testLambdaInterpolationInjection() {
$tpl = $this->mustache->loadTemplate('{{ a }}');

$data = array(
'a' => function() { return '{{ b }}'; },
'a' => function() {
return '{{ b }}';
},
'b' => '{{ c }}',
'c' => 'FAIL'
);
Expand All @@ -117,7 +119,9 @@ public function testLambdaSectionInjection() {
$tpl = $this->mustache->loadTemplate('{{# a }}b{{/ a }}');

$data = array(
'a' => function ($text) { return '{{ ' . $text . ' }}'; },
'a' => function ($text) {
return '{{ ' . $text . ' }}';
},
'b' => '{{ c }}',
'c' => 'FAIL'
);
Expand Down
5 changes: 4 additions & 1 deletion test/Mustache/Test/Functional/MustacheSpecTest.php
Expand Up @@ -106,11 +106,14 @@ private function prepareLambdasSpec($data) {
}

$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;
}

Expand Down
39 changes: 19 additions & 20 deletions test/Mustache/Test/MustacheTest.php
Expand Up @@ -23,26 +23,6 @@ public static function setUpBeforeClass() {
}
}

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;
Expand Down Expand Up @@ -133,6 +113,25 @@ public function testImmutablePartialsLoadersThrowException() {

$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);
}
}


Expand Down
2 changes: 1 addition & 1 deletion test/bootstrap.php
Expand Up @@ -6,8 +6,8 @@
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';
Expand Down

0 comments on commit 5c4fcd0

Please sign in to comment.