Merge pull request #233 from keradus/cs-fixes-fix-multiarray

Fix multiline array CS
This commit is contained in:
Justin Hileman
2014-09-15 16:13:37 -04:00
21 changed files with 119 additions and 119 deletions
+2 -2
View File
@@ -155,7 +155,7 @@ class Mustache_Tokenizer
self::OTAG => $this->otag, self::OTAG => $this->otag,
self::CTAG => $this->ctag, self::CTAG => $this->ctag,
self::LINE => $this->line, self::LINE => $this->line,
self::INDEX => ($this->tagType === self::T_END_SECTION) ? $this->seenTag - $this->otagLen : $i + $this->ctagLen self::INDEX => ($this->tagType === self::T_END_SECTION) ? $this->seenTag - $this->otagLen : $i + $this->ctagLen,
); );
if ($this->tagType === self::T_UNESCAPED) { if ($this->tagType === self::T_UNESCAPED) {
@@ -235,7 +235,7 @@ class Mustache_Tokenizer
$this->tokens[] = array( $this->tokens[] = array(
self::TYPE => self::T_TEXT, self::TYPE => self::T_TEXT,
self::LINE => $this->line, self::LINE => $this->line,
self::VALUE => $this->buffer self::VALUE => $this->buffer,
); );
$this->buffer = ''; $this->buffer = '';
} }
+7 -7
View File
@@ -47,7 +47,7 @@ class Mustache_Test_CompilerTest extends PHPUnit_Framework_TestCase
array( array(
Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_ESCAPED, Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_ESCAPED,
Mustache_Tokenizer::NAME => 'name', Mustache_Tokenizer::NAME => 'name',
) ),
), ),
'Monkey', 'Monkey',
true, true,
@@ -58,7 +58,7 @@ class Mustache_Test_CompilerTest extends PHPUnit_Framework_TestCase
'$value = $this->resolveValue($context->find(\'name\'), $context, $indent);', '$value = $this->resolveValue($context->find(\'name\'), $context, $indent);',
'$buffer .= $indent . call_user_func($this->mustache->getEscape(), $value);', '$buffer .= $indent . call_user_func($this->mustache->getEscape(), $value);',
'return $buffer;', 'return $buffer;',
) ),
), ),
array( array(
@@ -67,7 +67,7 @@ class Mustache_Test_CompilerTest extends PHPUnit_Framework_TestCase
array( array(
Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_ESCAPED, Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_ESCAPED,
Mustache_Tokenizer::NAME => 'name', Mustache_Tokenizer::NAME => 'name',
) ),
), ),
'Monkey', 'Monkey',
false, false,
@@ -78,7 +78,7 @@ class Mustache_Test_CompilerTest extends PHPUnit_Framework_TestCase
'$value = $this->resolveValue($context->find(\'name\'), $context, $indent);', '$value = $this->resolveValue($context->find(\'name\'), $context, $indent);',
'$buffer .= $indent . htmlspecialchars($value, ' . ENT_COMPAT . ', \'ISO-8859-1\');', '$buffer .= $indent . htmlspecialchars($value, ' . ENT_COMPAT . ', \'ISO-8859-1\');',
'return $buffer;', 'return $buffer;',
) ),
), ),
array( array(
@@ -87,7 +87,7 @@ class Mustache_Test_CompilerTest extends PHPUnit_Framework_TestCase
array( array(
Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_ESCAPED, Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_ESCAPED,
Mustache_Tokenizer::NAME => 'name', Mustache_Tokenizer::NAME => 'name',
) ),
), ),
'Monkey', 'Monkey',
false, false,
@@ -98,7 +98,7 @@ class Mustache_Test_CompilerTest extends PHPUnit_Framework_TestCase
'$value = $this->resolveValue($context->find(\'name\'), $context, $indent);', '$value = $this->resolveValue($context->find(\'name\'), $context, $indent);',
'$buffer .= $indent . htmlspecialchars($value, ' . ENT_QUOTES . ', \'ISO-8859-1\');', '$buffer .= $indent . htmlspecialchars($value, ' . ENT_QUOTES . ', \'ISO-8859-1\');',
'return $buffer;', 'return $buffer;',
) ),
), ),
array( array(
@@ -127,7 +127,7 @@ class Mustache_Test_CompilerTest extends PHPUnit_Framework_TestCase
'$value = $this->resolveValue($context->last(), $context, $indent);', '$value = $this->resolveValue($context->last(), $context, $indent);',
'$buffer .= \'\\\'bar\\\'\';', '$buffer .= \'\\\'bar\\\'\';',
'return $buffer;', 'return $buffer;',
) ),
), ),
); );
} }
+1 -1
View File
@@ -22,7 +22,7 @@ class Mustache_Test_ContextTest extends PHPUnit_Framework_TestCase
$two = new Mustache_Context(array( $two = new Mustache_Context(array(
'foo' => 'FOO', 'foo' => 'FOO',
'bar' => '<BAR>' 'bar' => '<BAR>',
)); ));
$this->assertEquals('FOO', $two->find('foo')); $this->assertEquals('FOO', $two->find('foo'));
$this->assertEquals('<BAR>', $two->find('bar')); $this->assertEquals('<BAR>', $two->find('bar'));
+4 -4
View File
@@ -151,7 +151,7 @@ class Mustache_Test_EngineTest extends Mustache_Test_FunctionalTestCase
public function testWithoutLambdaCache() public function testWithoutLambdaCache()
{ {
$mustache = new MustacheStub(array( $mustache = new MustacheStub(array(
'cache' => self::$tempDir 'cache' => self::$tempDir,
)); ));
$this->assertInstanceOf('Mustache_Cache_NoopCache', $mustache->getProtectedLambdaCache()); $this->assertInstanceOf('Mustache_Cache_NoopCache', $mustache->getProtectedLambdaCache());
@@ -193,7 +193,7 @@ class Mustache_Test_EngineTest extends Mustache_Test_FunctionalTestCase
'partials_loader' => new Mustache_Loader_ArrayLoader(array( 'partials_loader' => new Mustache_Loader_ArrayLoader(array(
'foo' => 'FOO', 'foo' => 'FOO',
'baz' => 'BAZ', 'baz' => 'BAZ',
)) )),
)); ));
$this->assertEquals('FOOBAZ', $mustache->render('{{>foo}}{{>bar}}{{>baz}}', array())); $this->assertEquals('FOOBAZ', $mustache->render('{{>foo}}{{>bar}}{{>baz}}', array()));
@@ -327,7 +327,7 @@ class Mustache_Test_EngineTest extends Mustache_Test_FunctionalTestCase
public function testUnknownPragmaThrowsException() public function testUnknownPragmaThrowsException()
{ {
new Mustache_Engine(array( new Mustache_Engine(array(
'pragmas' => array('UNKNOWN') 'pragmas' => array('UNKNOWN'),
)); ));
} }
@@ -335,7 +335,7 @@ class Mustache_Test_EngineTest extends Mustache_Test_FunctionalTestCase
{ {
$name = tempnam(sys_get_temp_dir(), 'mustache-test'); $name = tempnam(sys_get_temp_dir(), 'mustache-test');
$mustache = new Mustache_Engine(array( $mustache = new Mustache_Engine(array(
'logger' => new Mustache_Logger_StreamLogger($name, $level) 'logger' => new Mustache_Logger_StreamLogger($name, $level),
)); ));
return array($name, $mustache); return array($name, $mustache);
@@ -33,7 +33,7 @@ class Mustache_Test_FiveThree_Functional_EngineTest extends PHPUnit_Framework_Te
$helpers = array( $helpers = array(
'longdate' => function (\DateTime $value) { 'longdate' => function (\DateTime $value) {
return $value->format('Y-m-d h:m:s'); return $value->format('Y-m-d h:m:s');
} },
); );
$data = array( $data = array(
@@ -47,14 +47,14 @@ class Mustache_Test_FiveThree_Functional_FiltersTest extends PHPUnit_Framework_T
'{{% FILTERS }}{{ date | longdate }}', '{{% FILTERS }}{{ date | longdate }}',
$helpers, $helpers,
(object) array('date' => new DateTime('1/1/2000', new DateTimeZone("UTC"))), (object) array('date' => new DateTime('1/1/2000', new DateTimeZone("UTC"))),
'2000-01-01 12:01:00' '2000-01-01 12:01:00',
), ),
array( array(
'{{% FILTERS }}{{# word | echo }}{{ . }}!{{/ word | echo }}', '{{% FILTERS }}{{# word | echo }}{{ . }}!{{/ word | echo }}',
$helpers, $helpers,
array('word' => 'bacon'), array('word' => 'bacon'),
'bacon!bacon!bacon!' 'bacon!bacon!bacon!',
), ),
); );
} }
@@ -55,7 +55,7 @@ class Mustache_Test_FiveThree_Functional_HigherOrderSectionsTest extends PHPUnit
'name' => 'Bob', 'name' => 'Bob',
'wrap' => function ($text) { 'wrap' => function ($text) {
return sprintf('[[%s]]', $text); return sprintf('[[%s]]', $text);
} },
); );
$this->assertEquals(sprintf('[[%s]]', $data['name']), $tpl->render($data)); $this->assertEquals(sprintf('[[%s]]', $data['name']), $tpl->render($data));
@@ -36,7 +36,7 @@ EOS;
EOS; EOS;
$m = new Mustache_Engine(array( $m = new Mustache_Engine(array(
'partials' => array('input' => $partial) 'partials' => array('input' => $partial),
)); ));
$tpl = $m->loadTemplate($src); $tpl = $m->loadTemplate($src);
@@ -28,7 +28,7 @@ class Mustache_Test_Functional_ExamplesTest extends PHPUnit_Framework_TestCase
public function testExamples($context, $source, $partials, $expected) public function testExamples($context, $source, $partials, $expected)
{ {
$mustache = new Mustache_Engine(array( $mustache = new Mustache_Engine(array(
'partials' => $partials 'partials' => $partials,
)); ));
$this->assertEquals($expected, $mustache->loadTemplate($source)->render($context)); $this->assertEquals($expected, $mustache->loadTemplate($source)->render($context));
} }
@@ -24,13 +24,13 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas
'foo' => '{{$baz}}default content{{/baz}}', 'foo' => '{{$baz}}default content{{/baz}}',
), ),
array( array(
'bar' => 'set by user' 'bar' => 'set by user',
), ),
'{{< foo }}{{# bar }}{{$ baz }}{{/ baz }}{{/ bar }}{{/ foo }}', '{{< foo }}{{# bar }}{{$ baz }}{{/ baz }}{{/ bar }}{{/ foo }}',
), ),
array( array(
array( array(
'foo' => '{{$baz}}default content{{/baz}}' 'foo' => '{{$baz}}default content{{/baz}}',
), ),
array( array(
), ),
@@ -39,19 +39,19 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas
array( array(
array( array(
'foo' => '{{$baz}}default content{{/baz}}', 'foo' => '{{$baz}}default content{{/baz}}',
'qux' => 'I am a partial' 'qux' => 'I am a partial',
), ),
array( array(
), ),
'{{<foo}}{{>qux}}{{$baz}}set by template{{/baz}}{{/foo}}' '{{<foo}}{{>qux}}{{$baz}}set by template{{/baz}}{{/foo}}',
), ),
array( array(
array( array(
'foo' => '{{$baz}}default content{{/baz}}' 'foo' => '{{$baz}}default content{{/baz}}',
), ),
array(), array(),
'{{<foo}}{{=<% %>=}}<%={{ }}=%>{{/foo}}' '{{<foo}}{{=<% %>=}}<%={{ }}=%>{{/foo}}',
) ),
); );
} }
@@ -63,28 +63,28 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas
'foo' => '{{$baz}}default content{{/baz}}', 'foo' => '{{$baz}}default content{{/baz}}',
), ),
array( array(
'bar' => 'set by user' 'bar' => 'set by user',
), ),
'{{<foo}}{{bar}}{{$baz}}override{{/baz}}{{/foo}}', '{{<foo}}{{bar}}{{$baz}}override{{/baz}}{{/foo}}',
'override' 'override',
), ),
array( array(
array( array(
'foo' => '{{$baz}}default content{{/baz}}' 'foo' => '{{$baz}}default content{{/baz}}',
), ),
array( array(
), ),
'{{<foo}}{{! ignore me }}{{$baz}}set by template{{/baz}}{{/foo}}', '{{<foo}}{{! ignore me }}{{$baz}}set by template{{/baz}}{{/foo}}',
'set by template' 'set by template',
), ),
array( array(
array( array(
'foo' => '{{$baz}}defualt content{{/baz}}' 'foo' => '{{$baz}}defualt content{{/baz}}',
), ),
array(), array(),
'{{<foo}}set by template{{$baz}}also set by template{{/baz}}{{/foo}}', '{{<foo}}set by template{{$baz}}also set by template{{/baz}}{{/foo}}',
'also set by template' 'also set by template',
) ),
); );
} }
@@ -102,7 +102,7 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas
$tpl = $this->mustache->loadTemplate('{{$foo}}default {{bar}} content{{/foo}}'); $tpl = $this->mustache->loadTemplate('{{$foo}}default {{bar}} content{{/foo}}');
$data = array( $data = array(
'bar' => 'baz' 'bar' => 'baz',
); );
$this->assertEquals('default baz content', $tpl->render($data)); $this->assertEquals('default baz content', $tpl->render($data));
@@ -113,7 +113,7 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas
$tpl = $this->mustache->loadTemplate('{{$foo}}default {{{bar}}} content{{/foo}}'); $tpl = $this->mustache->loadTemplate('{{$foo}}default {{{bar}}} content{{/foo}}');
$data = array( $data = array(
'bar' => '<baz>' 'bar' => '<baz>',
); );
$this->assertEquals('default <baz> content', $tpl->render($data)); $this->assertEquals('default <baz> content', $tpl->render($data));
@@ -126,7 +126,7 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas
); );
$data = array( $data = array(
'bar' => array('baz' => 'qux') 'bar' => array('baz' => 'qux'),
); );
$this->assertEquals('default qux content', $tpl->render($data)); $this->assertEquals('default qux content', $tpl->render($data));
@@ -140,7 +140,7 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas
$data = array( $data = array(
'foo' => array('bar' => 'qux'), 'foo' => array('bar' => 'qux'),
'baz' => 'three' 'baz' => 'three',
); );
$this->assertEquals('default three content', $tpl->render($data)); $this->assertEquals('default three content', $tpl->render($data));
@@ -153,7 +153,7 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas
); );
$data = array( $data = array(
'bar' => array('baz' => '{{qux}}') 'bar' => array('baz' => '{{qux}}'),
); );
$this->assertEquals('default {{qux}} content', $tpl->render($data)); $this->assertEquals('default {{qux}} content', $tpl->render($data));
@@ -162,7 +162,7 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas
public function testDefaultContentRenderedInsideIncludedTemplates() public function testDefaultContentRenderedInsideIncludedTemplates()
{ {
$partials = array( $partials = array(
'include' => '{{$foo}}default content{{/foo}}' 'include' => '{{$foo}}default content{{/foo}}',
); );
$this->mustache->setPartials($partials); $this->mustache->setPartials($partials);
@@ -179,7 +179,7 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas
public function testOverriddenContent() public function testOverriddenContent()
{ {
$partials = array( $partials = array(
'super' => '...{{$title}}Default title{{/title}}...' 'super' => '...{{$title}}Default title{{/title}}...',
); );
$this->mustache->setPartials($partials); $this->mustache->setPartials($partials);
@@ -196,7 +196,7 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas
public function testOverriddenPartial() public function testOverriddenPartial()
{ {
$partials = array( $partials = array(
'partial' => '|{{$stuff}}...{{/stuff}}{{$default}} default{{/default}}|' 'partial' => '|{{$stuff}}...{{/stuff}}{{$default}} default{{/default}}|',
); );
$this->mustache->setPartials($partials); $this->mustache->setPartials($partials);
@@ -213,7 +213,7 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas
public function testDataDoesNotOverrideBlock() public function testDataDoesNotOverrideBlock()
{ {
$partials = array( $partials = array(
'include' => '{{$var}}var in include{{/var}}' 'include' => '{{$var}}var in include{{/var}}',
); );
$this->mustache->setPartials($partials); $this->mustache->setPartials($partials);
@@ -223,7 +223,7 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas
); );
$data = array( $data = array(
'var' => 'var in data' 'var' => 'var in data',
); );
$this->assertEquals('var in template', $tpl->render($data)); $this->assertEquals('var in template', $tpl->render($data));
@@ -232,7 +232,7 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas
public function testDataDoesNotOverrideDefaultBlockValue() public function testDataDoesNotOverrideDefaultBlockValue()
{ {
$partials = array( $partials = array(
'include' => '{{$var}}var in include{{/var}}' 'include' => '{{$var}}var in include{{/var}}',
); );
$this->mustache->setPartials($partials); $this->mustache->setPartials($partials);
@@ -242,7 +242,7 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas
); );
$data = array( $data = array(
'var' => 'var in data' 'var' => 'var in data',
); );
$this->assertEquals('var in include', $tpl->render($data)); $this->assertEquals('var in include', $tpl->render($data));
@@ -251,7 +251,7 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas
public function testOverridePartialWithNewlines() public function testOverridePartialWithNewlines()
{ {
$partials = array( $partials = array(
'partial' => '{{$ballmer}}peaking{{/ballmer}}' 'partial' => '{{$ballmer}}peaking{{/ballmer}}',
); );
$this->mustache->setPartials($partials); $this->mustache->setPartials($partials);
@@ -270,7 +270,7 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas
$partials = array( $partials = array(
'partial' => 'partial' =>
'stop: 'stop:
{{$nineties}}collaborate and listen{{/nineties}}' {{$nineties}}collaborate and listen{{/nineties}}',
); );
$this->mustache->setPartials($partials); $this->mustache->setPartials($partials);
@@ -291,7 +291,7 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas
public function testOverrideOneSubstitutionButNotTheOther() public function testOverrideOneSubstitutionButNotTheOther()
{ {
$partials = array( $partials = array(
'partial' => '{{$stuff}}default one{{/stuff}}, {{$stuff2}}default two{{/stuff2}}' 'partial' => '{{$stuff}}default one{{/stuff}}, {{$stuff2}}default two{{/stuff2}}',
); );
$this->mustache->setPartials($partials); $this->mustache->setPartials($partials);
@@ -308,7 +308,7 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas
public function testSuperTemplatesWithNoParameters() public function testSuperTemplatesWithNoParameters()
{ {
$partials = array( $partials = array(
'include' => '{{$foo}}default content{{/foo}}' 'include' => '{{$foo}}default content{{/foo}}',
); );
$this->mustache->setPartials($partials); $this->mustache->setPartials($partials);
@@ -326,7 +326,7 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas
{ {
$partials = array( $partials = array(
'include' => '{{$foo}}default content{{/foo}} {{$bar}}{{<include2}}{{/include2}}{{/bar}}', 'include' => '{{$foo}}default content{{/foo}} {{$bar}}{{<include2}}{{/include2}}{{/bar}}',
'include2' => '{{$foo}}include2 default content{{/foo}} {{<include}}{{$bar}}don\'t recurse{{/bar}}{{/include}}' 'include2' => '{{$foo}}include2 default content{{/foo}} {{<include}}{{$bar}}don\'t recurse{{/bar}}{{/include}}',
); );
$this->mustache->setPartials($partials); $this->mustache->setPartials($partials);
@@ -345,7 +345,7 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas
$partials = array( $partials = array(
'parent' => '{{<older}}{{$a}}p{{/a}}{{/older}}', 'parent' => '{{<older}}{{$a}}p{{/a}}{{/older}}',
'older' => '{{<grandParent}}{{$a}}o{{/a}}{{/grandParent}}', 'older' => '{{<grandParent}}{{$a}}o{{/a}}{{/grandParent}}',
'grandParent' => '{{$a}}g{{/a}}' 'grandParent' => '{{$a}}g{{/a}}',
); );
$this->mustache->setPartials($partials); $this->mustache->setPartials($partials);
@@ -364,7 +364,7 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas
$partials = array( $partials = array(
'parent' => '{{<older}}{{$a}}p{{/a}}{{/older}}', 'parent' => '{{<older}}{{$a}}p{{/a}}{{/older}}',
'older' => '{{<grandParent}}{{$a}}o{{/a}}{{/grandParent}}', 'older' => '{{<grandParent}}{{$a}}o{{/a}}{{/grandParent}}',
'grandParent' => '{{$a}}g{{/a}}' 'grandParent' => '{{$a}}g{{/a}}',
); );
$this->mustache->setPartials($partials); $this->mustache->setPartials($partials);
@@ -381,7 +381,7 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas
public function testIgnoreTextInsideSuperTemplatesButParseArgs() public function testIgnoreTextInsideSuperTemplatesButParseArgs()
{ {
$partials = array( $partials = array(
'include' => '{{$foo}}default content{{/foo}}' 'include' => '{{$foo}}default content{{/foo}}',
); );
$this->mustache->setPartials($partials); $this->mustache->setPartials($partials);
@@ -398,7 +398,7 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas
public function testIgnoreTextInsideSuperTemplates() public function testIgnoreTextInsideSuperTemplates()
{ {
$partials = array( $partials = array(
'include' => '{{$foo}}default content{{/foo}}' 'include' => '{{$foo}}default content{{/foo}}',
); );
$this->mustache->setPartials($partials); $this->mustache->setPartials($partials);
@@ -35,25 +35,25 @@ class Mustache_Test_Functional_MustacheInjectionTest extends PHPUnit_Framework_T
{ {
$interpolationData = array( $interpolationData = array(
'a' => '{{ b }}', 'a' => '{{ b }}',
'b' => 'FAIL' 'b' => 'FAIL',
); );
$sectionData = array( $sectionData = array(
'a' => true, 'a' => true,
'b' => '{{ c }}', 'b' => '{{ c }}',
'c' => 'FAIL' 'c' => 'FAIL',
); );
$lambdaInterpolationData = array( $lambdaInterpolationData = array(
'a' => array($this, 'lambdaInterpolationCallback'), 'a' => array($this, 'lambdaInterpolationCallback'),
'b' => '{{ c }}', 'b' => '{{ c }}',
'c' => 'FAIL' 'c' => 'FAIL',
); );
$lambdaSectionData = array( $lambdaSectionData = array(
'a' => array($this, 'lambdaSectionCallback'), 'a' => array($this, 'lambdaSectionCallback'),
'b' => '{{ c }}', 'b' => '{{ c }}',
'c' => 'FAIL' 'c' => 'FAIL',
); );
return array( return array(
@@ -21,7 +21,7 @@ class Mustache_Test_Functional_NestedPartialIndentTest extends PHPUnit_Framework
public function testNestedPartialsAreIndentedProperly($src, array $partials, $expected) public function testNestedPartialsAreIndentedProperly($src, array $partials, $expected)
{ {
$m = new Mustache_Engine(array( $m = new Mustache_Engine(array(
'partials' => $partials 'partials' => $partials,
)); ));
$tpl = $m->loadTemplate($src); $tpl = $m->loadTemplate($src);
$this->assertEquals($expected, $tpl->render()); $this->assertEquals($expected, $tpl->render());
@@ -17,7 +17,7 @@ class Mustache_Test_Loader_ArrayLoaderTest extends PHPUnit_Framework_TestCase
public function testConstructor() public function testConstructor()
{ {
$loader = new Mustache_Loader_ArrayLoader(array( $loader = new Mustache_Loader_ArrayLoader(array(
'foo' => 'bar' 'foo' => 'bar',
)); ));
$this->assertEquals('bar', $loader->load('foo')); $this->assertEquals('bar', $loader->load('foo'));
@@ -26,7 +26,7 @@ class Mustache_Test_Loader_ArrayLoaderTest extends PHPUnit_Framework_TestCase
public function testSetAndLoadTemplates() public function testSetAndLoadTemplates()
{ {
$loader = new Mustache_Loader_ArrayLoader(array( $loader = new Mustache_Loader_ArrayLoader(array(
'foo' => 'bar' 'foo' => 'bar',
)); ));
$this->assertEquals('bar', $loader->load('foo')); $this->assertEquals('bar', $loader->load('foo'));
@@ -134,7 +134,7 @@ class Mustache_Test_Logger_StreamLoggerTest extends PHPUnit_Framework_TestCase
Mustache_Logger::ERROR, Mustache_Logger::ERROR,
'error message', 'error message',
array('name' => 'foo', 'number' => 42), array('name' => 'foo', 'number' => 42),
"ERROR: error message\n" "ERROR: error message\n",
), ),
// with interpolation // with interpolation
@@ -142,7 +142,7 @@ class Mustache_Test_Logger_StreamLoggerTest extends PHPUnit_Framework_TestCase
Mustache_Logger::ERROR, Mustache_Logger::ERROR,
'error {name}-{number}', 'error {name}-{number}',
array('name' => 'foo', 'number' => 42), array('name' => 'foo', 'number' => 42),
"ERROR: error foo-42\n" "ERROR: error foo-42\n",
), ),
// with iterpolation false positive // with iterpolation false positive
@@ -150,7 +150,7 @@ class Mustache_Test_Logger_StreamLoggerTest extends PHPUnit_Framework_TestCase
Mustache_Logger::ERROR, Mustache_Logger::ERROR,
'error {nothing}', 'error {nothing}',
array('name' => 'foo', 'number' => 42), array('name' => 'foo', 'number' => 42),
"ERROR: error {nothing}\n" "ERROR: error {nothing}\n",
), ),
// with interpolation injection // with interpolation injection
@@ -158,7 +158,7 @@ class Mustache_Test_Logger_StreamLoggerTest extends PHPUnit_Framework_TestCase
Mustache_Logger::ERROR, Mustache_Logger::ERROR,
'{foo}', '{foo}',
array('foo' => '{bar}', 'bar' => 'FAIL'), array('foo' => '{bar}', 'bar' => 'FAIL'),
"ERROR: {bar}\n" "ERROR: {bar}\n",
), ),
); );
} }
+33 -33
View File
@@ -28,7 +28,7 @@ class Mustache_Test_ParserTest extends PHPUnit_Framework_TestCase
return array( return array(
array( array(
array(), array(),
array() array(),
), ),
array( array(
@@ -48,12 +48,12 @@ class Mustache_Test_ParserTest extends PHPUnit_Framework_TestCase
array(array( array(array(
Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_ESCAPED, Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_ESCAPED,
Mustache_Tokenizer::LINE => 0, Mustache_Tokenizer::LINE => 0,
Mustache_Tokenizer::NAME => 'name' Mustache_Tokenizer::NAME => 'name',
)), )),
array(array( array(array(
Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_ESCAPED, Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_ESCAPED,
Mustache_Tokenizer::LINE => 0, Mustache_Tokenizer::LINE => 0,
Mustache_Tokenizer::NAME => 'name' Mustache_Tokenizer::NAME => 'name',
)), )),
), ),
@@ -62,29 +62,29 @@ class Mustache_Test_ParserTest extends PHPUnit_Framework_TestCase
array( array(
Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT, Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT,
Mustache_Tokenizer::LINE => 0, Mustache_Tokenizer::LINE => 0,
Mustache_Tokenizer::VALUE => 'foo' Mustache_Tokenizer::VALUE => 'foo',
), ),
array( array(
Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_INVERTED, Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_INVERTED,
Mustache_Tokenizer::LINE => 0, Mustache_Tokenizer::LINE => 0,
Mustache_Tokenizer::INDEX => 123, Mustache_Tokenizer::INDEX => 123,
Mustache_Tokenizer::NAME => 'parent' Mustache_Tokenizer::NAME => 'parent',
), ),
array( array(
Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_ESCAPED, Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_ESCAPED,
Mustache_Tokenizer::LINE => 0, Mustache_Tokenizer::LINE => 0,
Mustache_Tokenizer::NAME => 'name' Mustache_Tokenizer::NAME => 'name',
), ),
array( array(
Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_END_SECTION, Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_END_SECTION,
Mustache_Tokenizer::LINE => 0, Mustache_Tokenizer::LINE => 0,
Mustache_Tokenizer::INDEX => 456, Mustache_Tokenizer::INDEX => 456,
Mustache_Tokenizer::NAME => 'parent' Mustache_Tokenizer::NAME => 'parent',
), ),
array( array(
Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT, Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT,
Mustache_Tokenizer::LINE => 0, Mustache_Tokenizer::LINE => 0,
Mustache_Tokenizer::VALUE => 'bar' Mustache_Tokenizer::VALUE => 'bar',
), ),
), ),
@@ -92,7 +92,7 @@ class Mustache_Test_ParserTest extends PHPUnit_Framework_TestCase
array( array(
Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT, Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT,
Mustache_Tokenizer::LINE => 0, Mustache_Tokenizer::LINE => 0,
Mustache_Tokenizer::VALUE => 'foo' Mustache_Tokenizer::VALUE => 'foo',
), ),
array( array(
Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_INVERTED, Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_INVERTED,
@@ -104,14 +104,14 @@ class Mustache_Test_ParserTest extends PHPUnit_Framework_TestCase
array( array(
Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_ESCAPED, Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_ESCAPED,
Mustache_Tokenizer::LINE => 0, Mustache_Tokenizer::LINE => 0,
Mustache_Tokenizer::NAME => 'name' Mustache_Tokenizer::NAME => 'name',
), ),
), ),
), ),
array( array(
Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT, Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT,
Mustache_Tokenizer::LINE => 0, Mustache_Tokenizer::LINE => 0,
Mustache_Tokenizer::VALUE => 'bar' Mustache_Tokenizer::VALUE => 'bar',
), ),
), ),
), ),
@@ -130,7 +130,7 @@ class Mustache_Test_ParserTest extends PHPUnit_Framework_TestCase
array( array(
Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT, Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT,
Mustache_Tokenizer::LINE => 0, Mustache_Tokenizer::LINE => 0,
Mustache_Tokenizer::VALUE => 'bar' Mustache_Tokenizer::VALUE => 'bar',
), ),
), ),
array( array(
@@ -144,7 +144,7 @@ class Mustache_Test_ParserTest extends PHPUnit_Framework_TestCase
array( array(
Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT, Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT,
Mustache_Tokenizer::LINE => 0, Mustache_Tokenizer::LINE => 0,
Mustache_Tokenizer::VALUE => 'bar' Mustache_Tokenizer::VALUE => 'bar',
), ),
), ),
), ),
@@ -208,7 +208,7 @@ class Mustache_Test_ParserTest extends PHPUnit_Framework_TestCase
Mustache_Tokenizer::OTAG => '{{', Mustache_Tokenizer::OTAG => '{{',
Mustache_Tokenizer::CTAG => '}}', Mustache_Tokenizer::CTAG => '}}',
Mustache_Tokenizer::LINE => 0, Mustache_Tokenizer::LINE => 0,
Mustache_Tokenizer::INDEX => 8 Mustache_Tokenizer::INDEX => 8,
), ),
array( array(
Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_BLOCK_VAR, Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_BLOCK_VAR,
@@ -216,12 +216,12 @@ class Mustache_Test_ParserTest extends PHPUnit_Framework_TestCase
Mustache_Tokenizer::OTAG => '{{', Mustache_Tokenizer::OTAG => '{{',
Mustache_Tokenizer::CTAG => '}}', Mustache_Tokenizer::CTAG => '}}',
Mustache_Tokenizer::LINE => 0, Mustache_Tokenizer::LINE => 0,
Mustache_Tokenizer::INDEX => 16 Mustache_Tokenizer::INDEX => 16,
), ),
array( array(
Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT, Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT,
Mustache_Tokenizer::LINE => 0, Mustache_Tokenizer::LINE => 0,
Mustache_Tokenizer::VALUE => 'baz' Mustache_Tokenizer::VALUE => 'baz',
), ),
array( array(
Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_END_SECTION, Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_END_SECTION,
@@ -229,7 +229,7 @@ class Mustache_Test_ParserTest extends PHPUnit_Framework_TestCase
Mustache_Tokenizer::OTAG => '{{', Mustache_Tokenizer::OTAG => '{{',
Mustache_Tokenizer::CTAG => '}}', Mustache_Tokenizer::CTAG => '}}',
Mustache_Tokenizer::LINE => 0, Mustache_Tokenizer::LINE => 0,
Mustache_Tokenizer::INDEX => 19 Mustache_Tokenizer::INDEX => 19,
), ),
array( array(
Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_END_SECTION, Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_END_SECTION,
@@ -237,8 +237,8 @@ class Mustache_Test_ParserTest extends PHPUnit_Framework_TestCase
Mustache_Tokenizer::OTAG => '{{', Mustache_Tokenizer::OTAG => '{{',
Mustache_Tokenizer::CTAG => '}}', Mustache_Tokenizer::CTAG => '}}',
Mustache_Tokenizer::LINE => 0, Mustache_Tokenizer::LINE => 0,
Mustache_Tokenizer::INDEX => 27 Mustache_Tokenizer::INDEX => 27,
) ),
), ),
array( array(
array( array(
@@ -262,13 +262,13 @@ class Mustache_Test_ParserTest extends PHPUnit_Framework_TestCase
array( array(
Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT, Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT,
Mustache_Tokenizer::LINE => 0, Mustache_Tokenizer::LINE => 0,
Mustache_Tokenizer::VALUE => 'baz' Mustache_Tokenizer::VALUE => 'baz',
) ),
) ),
) ),
) ),
) ),
) ),
), ),
array( array(
@@ -283,7 +283,7 @@ class Mustache_Test_ParserTest extends PHPUnit_Framework_TestCase
array( array(
Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT, Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT,
Mustache_Tokenizer::LINE => 0, Mustache_Tokenizer::LINE => 0,
Mustache_Tokenizer::VALUE => 'bar' Mustache_Tokenizer::VALUE => 'bar',
), ),
array( array(
Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_END_SECTION, Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_END_SECTION,
@@ -306,11 +306,11 @@ class Mustache_Test_ParserTest extends PHPUnit_Framework_TestCase
array( array(
Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT, Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT,
Mustache_Tokenizer::LINE => 0, Mustache_Tokenizer::LINE => 0,
Mustache_Tokenizer::VALUE => 'bar' Mustache_Tokenizer::VALUE => 'bar',
) ),
) ),
) ),
) ),
), ),
); );
} }
@@ -408,7 +408,7 @@ class Mustache_Test_ParserTest extends PHPUnit_Framework_TestCase
array( array(
Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT, Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT,
Mustache_Tokenizer::LINE => 0, Mustache_Tokenizer::LINE => 0,
Mustache_Tokenizer::VALUE => 'bar' Mustache_Tokenizer::VALUE => 'bar',
), ),
array( array(
Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_END_SECTION, Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_END_SECTION,
+12 -12
View File
@@ -83,8 +83,8 @@ class Mustache_Test_TokenizerTest extends PHPUnit_Framework_TestCase
Mustache_Tokenizer::CTAG => '}}', Mustache_Tokenizer::CTAG => '}}',
Mustache_Tokenizer::LINE => 0, Mustache_Tokenizer::LINE => 0,
Mustache_Tokenizer::INDEX => 10, Mustache_Tokenizer::INDEX => 10,
) ),
) ),
), ),
array( array(
@@ -110,8 +110,8 @@ class Mustache_Test_TokenizerTest extends PHPUnit_Framework_TestCase
Mustache_Tokenizer::CTAG => '>>>', Mustache_Tokenizer::CTAG => '>>>',
Mustache_Tokenizer::LINE => 0, Mustache_Tokenizer::LINE => 0,
Mustache_Tokenizer::INDEX => 12, Mustache_Tokenizer::INDEX => 12,
) ),
) ),
), ),
array( array(
@@ -178,7 +178,7 @@ class Mustache_Test_TokenizerTest extends PHPUnit_Framework_TestCase
Mustache_Tokenizer::INDEX => 51, Mustache_Tokenizer::INDEX => 51,
), ),
) ),
), ),
// See https://github.com/bobthecow/mustache.php/issues/183 // See https://github.com/bobthecow/mustache.php/issues/183
@@ -207,7 +207,7 @@ class Mustache_Test_TokenizerTest extends PHPUnit_Framework_TestCase
Mustache_Tokenizer::LINE => 0, Mustache_Tokenizer::LINE => 0,
Mustache_Tokenizer::INDEX => 9, Mustache_Tokenizer::INDEX => 9,
), ),
) ),
), ),
// custom delimiters don't swallow the next character, even if it is a }, }}}, or the same delimiter // custom delimiters don't swallow the next character, even if it is a }, }}}, or the same delimiter
@@ -254,7 +254,7 @@ class Mustache_Test_TokenizerTest extends PHPUnit_Framework_TestCase
Mustache_Tokenizer::LINE => 0, Mustache_Tokenizer::LINE => 0,
Mustache_Tokenizer::VALUE => "}}}", Mustache_Tokenizer::VALUE => "}}}",
), ),
) ),
), ),
// unescaped custom delimiters are properly parsed // unescaped custom delimiters are properly parsed
@@ -269,8 +269,8 @@ class Mustache_Test_TokenizerTest extends PHPUnit_Framework_TestCase
Mustache_Tokenizer::CTAG => '%>', Mustache_Tokenizer::CTAG => '%>',
Mustache_Tokenizer::LINE => 0, Mustache_Tokenizer::LINE => 0,
Mustache_Tokenizer::INDEX => 9, Mustache_Tokenizer::INDEX => 9,
) ),
) ),
), ),
// Ensure that $arg token is not picked up during tokenization // Ensure that $arg token is not picked up during tokenization
@@ -284,7 +284,7 @@ class Mustache_Test_TokenizerTest extends PHPUnit_Framework_TestCase
Mustache_Tokenizer::OTAG => '{{', Mustache_Tokenizer::OTAG => '{{',
Mustache_Tokenizer::CTAG => '}}', Mustache_Tokenizer::CTAG => '}}',
Mustache_Tokenizer::LINE => 0, Mustache_Tokenizer::LINE => 0,
Mustache_Tokenizer::INDEX => 8 Mustache_Tokenizer::INDEX => 8,
), ),
array( array(
Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT, Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT,
@@ -298,8 +298,8 @@ class Mustache_Test_TokenizerTest extends PHPUnit_Framework_TestCase
Mustache_Tokenizer::CTAG => '}}', Mustache_Tokenizer::CTAG => '}}',
Mustache_Tokenizer::LINE => 0, Mustache_Tokenizer::LINE => 0,
Mustache_Tokenizer::INDEX => 15, Mustache_Tokenizer::INDEX => 15,
) ),
) ),
), ),
); );
} }
+1 -1
View File
@@ -8,7 +8,7 @@ class DotNotation
'hometown' => array( 'hometown' => array(
'city' => 'Cincinnati', 'city' => 'Cincinnati',
'state' => 'OH', 'state' => 'OH',
) ),
); );
public $normal = 'Normal'; public $normal = 'Normal';
@@ -9,14 +9,14 @@ class GrandParentContext
{ {
$this->parent_contexts[] = array('parent_id' => 'parent1', 'child_contexts' => array( $this->parent_contexts[] = array('parent_id' => 'parent1', 'child_contexts' => array(
array('child_id' => 'parent1-child1'), array('child_id' => 'parent1-child1'),
array('child_id' => 'parent1-child2') array('child_id' => 'parent1-child2'),
)); ));
$parent2 = new stdClass(); $parent2 = new stdClass();
$parent2->parent_id = 'parent2'; $parent2->parent_id = 'parent2';
$parent2->child_contexts = array( $parent2->child_contexts = array(
array('child_id' => 'parent2-child1'), array('child_id' => 'parent2-child1'),
array('child_id' => 'parent2-child2') array('child_id' => 'parent2-child2'),
); );
$this->parent_contexts[] = $parent2; $this->parent_contexts[] = $parent2;
@@ -8,6 +8,6 @@ class RecursivePartials
'child' => array( 'child' => array(
'name' => 'Justin', 'name' => 'Justin',
'child' => false, 'child' => false,
) ),
); );
} }
@@ -16,7 +16,7 @@ class MagicObject
{ {
protected $_data = array( protected $_data = array(
'foo' => 'And it worked the second time.', 'foo' => 'And it worked the second time.',
'bar' => 'As well as the third.' 'bar' => 'As well as the third.',
); );
public function __get($key) public function __get($key)
+3 -3
View File
@@ -13,7 +13,7 @@ class SectionsNested
array('name' => 'Super Macho Man'), array('name' => 'Super Macho Man'),
array('name' => 'Piston Honda'), array('name' => 'Piston Honda'),
array('name' => 'Mr. Sandman'), array('name' => 'Mr. Sandman'),
) ),
), ),
array( array(
'name' => 'Mike Tyson', 'name' => 'Mike Tyson',
@@ -22,13 +22,13 @@ class SectionsNested
array('name' => 'King Hippo'), array('name' => 'King Hippo'),
array('name' => 'Great Tiger'), array('name' => 'Great Tiger'),
array('name' => 'Glass Joe'), array('name' => 'Glass Joe'),
) ),
), ),
array( array(
'name' => 'Don Flamenco', 'name' => 'Don Flamenco',
'enemies' => array( 'enemies' => array(
array('name' => 'Bald Bull'), array('name' => 'Bald Bull'),
) ),
), ),
); );
} }