From 5c5ea485784d93954b28890b908101f5aef71de6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dariusz=20Rumi=C5=84ski?= Date: Tue, 26 Aug 2014 22:16:39 +0200 Subject: [PATCH 01/31] sugar changes to travis config --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index fa13c65..59c9d31 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: php -before_script: +install: - curl http://cs.sensiolabs.org/get/php-cs-fixer.phar -o php-cs-fixer.phar script: From ff3c1b35fbbb78a4564e62e8e3e173b7151a67d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dariusz=20Rumi=C5=84ski?= Date: Sun, 31 Aug 2014 18:01:38 +0200 Subject: [PATCH 02/31] Tokenizer - remove unused property --- src/Mustache/Tokenizer.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Mustache/Tokenizer.php b/src/Mustache/Tokenizer.php index 3175a03..a774a22 100644 --- a/src/Mustache/Tokenizer.php +++ b/src/Mustache/Tokenizer.php @@ -75,7 +75,6 @@ class Mustache_Tokenizer private $state; private $tagType; - private $tag; private $buffer; private $tokens; private $seenTag; @@ -224,7 +223,6 @@ class Mustache_Tokenizer { $this->state = self::IN_TEXT; $this->tagType = null; - $this->tag = null; $this->buffer = ''; $this->tokens = array(); $this->seenTag = false; From f3287f40fe5971a28bec76eb407b2f639086485c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dariusz=20Rumi=C5=84ski?= Date: Sun, 31 Aug 2014 18:02:00 +0200 Subject: [PATCH 03/31] Tokenizer - remove unused property --- src/Mustache/Tokenizer.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/Mustache/Tokenizer.php b/src/Mustache/Tokenizer.php index a774a22..be9ca14 100644 --- a/src/Mustache/Tokenizer.php +++ b/src/Mustache/Tokenizer.php @@ -53,13 +53,6 @@ class Mustache_Tokenizer self::T_BLOCK_VAR => true, ); - // Interpolated tags - private static $interpolatedTags = array( - self::T_ESCAPED => true, - self::T_UNESCAPED => true, - self::T_UNESCAPED_2 => true, - ); - // Token properties const TYPE = 'type'; const NAME = 'name'; From 90004b12bce70552ca5ecf2f05cd805c88d830fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dariusz=20Rumi=C5=84ski?= Date: Mon, 1 Sep 2014 18:42:55 +0200 Subject: [PATCH 04/31] fix indent --- src/Mustache/Engine.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mustache/Engine.php b/src/Mustache/Engine.php index 4cac394..91469de 100644 --- a/src/Mustache/Engine.php +++ b/src/Mustache/Engine.php @@ -174,7 +174,7 @@ class Mustache_Engine } if (isset($options['entity_flags'])) { - $this->entityFlags = $options['entity_flags']; + $this->entityFlags = $options['entity_flags']; } if (isset($options['charset'])) { From 0007be44cdc232b150eba69a8423b4194651d82a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dariusz=20Rumi=C5=84ski?= Date: Thu, 4 Sep 2014 20:44:59 +0200 Subject: [PATCH 05/31] indent fixes --- src/Mustache/Compiler.php | 1 - test/Mustache/Test/Cache/AbstractCacheTest.php | 8 ++++---- test/Mustache/Test/CompilerTest.php | 1 - .../Test/FiveThree/Functional/PartialLambdaIndentTest.php | 1 - test/Mustache/Test/Functional/CallTest.php | 1 - test/Mustache/Test/Functional/ExamplesTest.php | 1 - test/Mustache/Test/Functional/InheritanceTest.php | 3 +-- test/Mustache/Test/Functional/MustacheInjectionTest.php | 1 - test/Mustache/Test/ParserTest.php | 1 - test/Mustache/Test/TokenizerTest.php | 1 - test/fixtures/examples/i18n/I18n.php | 1 - 11 files changed, 5 insertions(+), 15 deletions(-) diff --git a/src/Mustache/Compiler.php b/src/Mustache/Compiler.php index 72d3414..4b3cd8e 100644 --- a/src/Mustache/Compiler.php +++ b/src/Mustache/Compiler.php @@ -16,7 +16,6 @@ */ class Mustache_Compiler { - private $pragmas; private $defaultPragmas = array(); private $sections; diff --git a/test/Mustache/Test/Cache/AbstractCacheTest.php b/test/Mustache/Test/Cache/AbstractCacheTest.php index 1a9c629..42fa47c 100644 --- a/test/Mustache/Test/Cache/AbstractCacheTest.php +++ b/test/Mustache/Test/Cache/AbstractCacheTest.php @@ -13,10 +13,10 @@ class Mustache_Test_Cache_AbstractCacheTest extends PHPUnit_Framework_TestCase { public function testGetSetLogger() { - $cache = new CacheStub(); - $logger = new Mustache_Logger_StreamLogger('php://stdout'); - $cache->setLogger($logger); - $this->assertSame($logger, $cache->getLogger()); + $cache = new CacheStub(); + $logger = new Mustache_Logger_StreamLogger('php://stdout'); + $cache->setLogger($logger); + $this->assertSame($logger, $cache->getLogger()); } /** diff --git a/test/Mustache/Test/CompilerTest.php b/test/Mustache/Test/CompilerTest.php index 8fefec8..fe7cdde 100644 --- a/test/Mustache/Test/CompilerTest.php +++ b/test/Mustache/Test/CompilerTest.php @@ -14,7 +14,6 @@ */ class Mustache_Test_CompilerTest extends PHPUnit_Framework_TestCase { - /** * @dataProvider getCompileValues */ diff --git a/test/Mustache/Test/FiveThree/Functional/PartialLambdaIndentTest.php b/test/Mustache/Test/FiveThree/Functional/PartialLambdaIndentTest.php index 04fd56d..1ab6e4c 100644 --- a/test/Mustache/Test/FiveThree/Functional/PartialLambdaIndentTest.php +++ b/test/Mustache/Test/FiveThree/Functional/PartialLambdaIndentTest.php @@ -15,7 +15,6 @@ */ class Mustache_Test_FiveThree_Functional_PartialLambdaIndentTest extends PHPUnit_Framework_TestCase { - public function testLambdasInsidePartialsAreIndentedProperly() { $src = <<assertEquals('default three content', $tpl->render($data)); - } public function testMustacheInjectionInDefaultContent() @@ -251,7 +250,7 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas public function testOverridePartialWithNewlines() { - $partials = array( + $partials = array( 'partial' => '{{$ballmer}}peaking{{/ballmer}}' ); diff --git a/test/Mustache/Test/Functional/MustacheInjectionTest.php b/test/Mustache/Test/Functional/MustacheInjectionTest.php index 54de502..c2ff3da 100644 --- a/test/Mustache/Test/Functional/MustacheInjectionTest.php +++ b/test/Mustache/Test/Functional/MustacheInjectionTest.php @@ -15,7 +15,6 @@ */ class Mustache_Test_Functional_MustacheInjectionTest extends PHPUnit_Framework_TestCase { - private $mustache; public function setUp() diff --git a/test/Mustache/Test/ParserTest.php b/test/Mustache/Test/ParserTest.php index eccfc3d..b5ba261 100644 --- a/test/Mustache/Test/ParserTest.php +++ b/test/Mustache/Test/ParserTest.php @@ -14,7 +14,6 @@ */ class Mustache_Test_ParserTest extends PHPUnit_Framework_TestCase { - /** * @dataProvider getTokenSets */ diff --git a/test/Mustache/Test/TokenizerTest.php b/test/Mustache/Test/TokenizerTest.php index e5eeb72..5432240 100644 --- a/test/Mustache/Test/TokenizerTest.php +++ b/test/Mustache/Test/TokenizerTest.php @@ -14,7 +14,6 @@ */ class Mustache_Test_TokenizerTest extends PHPUnit_Framework_TestCase { - /** * @dataProvider getTokens */ diff --git a/test/fixtures/examples/i18n/I18n.php b/test/fixtures/examples/i18n/I18n.php index 7b7cd9f..5fc26d9 100644 --- a/test/fixtures/examples/i18n/I18n.php +++ b/test/fixtures/examples/i18n/I18n.php @@ -2,7 +2,6 @@ class I18n { - // Variable to be interpolated public $name = 'Bob'; From 1319f0486d278541dd0432937f4b3a5fac3224fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dariusz=20Rumi=C5=84ski?= Date: Sat, 6 Sep 2014 01:21:20 +0200 Subject: [PATCH 06/31] concatenation with spaces around --- src/Mustache/Autoloader.php | 2 +- src/Mustache/Compiler.php | 8 ++++---- src/Mustache/Tokenizer.php | 2 +- test/Mustache/Test/AutoloaderTest.php | 2 +- test/Mustache/Test/CompilerTest.php | 6 +++--- test/Mustache/Test/EngineTest.php | 2 +- .../Test/FiveThree/Functional/MustacheSpecTest.php | 2 +- test/Mustache/Test/Functional/ExamplesTest.php | 8 ++++---- test/Mustache/Test/Functional/MustacheSpecTest.php | 2 +- test/Mustache/Test/FunctionalTestCase.php | 4 ++-- test/Mustache/Test/Loader/FilesystemLoaderTest.php | 14 +++++++------- 11 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/Mustache/Autoloader.php b/src/Mustache/Autoloader.php index 8c8e906..d9b2935 100644 --- a/src/Mustache/Autoloader.php +++ b/src/Mustache/Autoloader.php @@ -24,7 +24,7 @@ class Mustache_Autoloader public function __construct($baseDir = null) { if ($baseDir === null) { - $baseDir = dirname(__FILE__).'/..'; + $baseDir = dirname(__FILE__) . '/..'; } // realpath doesn't always work, for example, with stream URIs diff --git a/src/Mustache/Compiler.php b/src/Mustache/Compiler.php index 4b3cd8e..c872df4 100644 --- a/src/Mustache/Compiler.php +++ b/src/Mustache/Compiler.php @@ -341,12 +341,12 @@ class Mustache_Compiler $callable = $this->getCallable(); if ($otag !== '{{' || $ctag !== '}}') { - $delims = ', '.var_export(sprintf('{{= %s %s =}}', $otag, $ctag), true); + $delims = ', ' . var_export(sprintf('{{= %s %s =}}', $otag, $ctag), true); } else { $delims = ''; } - $key = ucfirst(md5($delims."\n".$source)); + $key = ucfirst(md5($delims . "\n" . $source)); if (!isset($this->sections[$key])) { $this->sections[$key] = sprintf($this->prepare(self::SECTION), $key, $callable, $source, $delims, $this->walk($nodes, 2)); @@ -552,7 +552,7 @@ class Mustache_Compiler */ private function prepare($text, $bonus = 0, $prependNewline = true, $appendNewline = false) { - $text = ($prependNewline ? "\n" : '').trim($text); + $text = ($prependNewline ? "\n" : '') . trim($text); if ($prependNewline) { $bonus++; } @@ -560,7 +560,7 @@ class Mustache_Compiler $text .= "\n"; } - return preg_replace("/\n( {8})?/", "\n".str_repeat(" ", $bonus * 4), $text); + return preg_replace("/\n( {8})?/", "\n" . str_repeat(" ", $bonus * 4), $text); } const DEFAULT_ESCAPE = 'htmlspecialchars(%s, %s, %s)'; diff --git a/src/Mustache/Tokenizer.php b/src/Mustache/Tokenizer.php index be9ca14..467ec68 100644 --- a/src/Mustache/Tokenizer.php +++ b/src/Mustache/Tokenizer.php @@ -252,7 +252,7 @@ class Mustache_Tokenizer private function changeDelimiters($text, $index) { $startIndex = strpos($text, '=', $index) + 1; - $close = '='.$this->ctag; + $close = '=' . $this->ctag; $closeIndex = strpos($text, $close, $index); $this->setDelimiters(trim(substr($text, $startIndex, $closeIndex - $startIndex))); diff --git a/test/Mustache/Test/AutoloaderTest.php b/test/Mustache/Test/AutoloaderTest.php index 32fb0dc..01e6d28 100644 --- a/test/Mustache/Test/AutoloaderTest.php +++ b/test/Mustache/Test/AutoloaderTest.php @@ -22,7 +22,7 @@ class Mustache_Test_AutoloaderTest extends PHPUnit_Framework_TestCase public function testAutoloader() { - $loader = new Mustache_Autoloader(dirname(__FILE__).'/../../fixtures/autoloader'); + $loader = new Mustache_Autoloader(dirname(__FILE__) . '/../../fixtures/autoloader'); $this->assertNull($loader->autoload('NonMustacheClass')); $this->assertFalse(class_exists('NonMustacheClass')); diff --git a/test/Mustache/Test/CompilerTest.php b/test/Mustache/Test/CompilerTest.php index fe7cdde..b6bcbdc 100644 --- a/test/Mustache/Test/CompilerTest.php +++ b/test/Mustache/Test/CompilerTest.php @@ -76,7 +76,7 @@ class Mustache_Test_CompilerTest extends PHPUnit_Framework_TestCase array( "\nclass Monkey extends Mustache_Template", '$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;', ) ), @@ -96,7 +96,7 @@ class Mustache_Test_CompilerTest extends PHPUnit_Framework_TestCase array( "\nclass Monkey extends Mustache_Template", '$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;', ) ), @@ -123,7 +123,7 @@ class Mustache_Test_CompilerTest extends PHPUnit_Framework_TestCase "\nclass Monkey extends Mustache_Template", "\$buffer .= \$indent . 'foo\n';", '$value = $this->resolveValue($context->find(\'name\'), $context, $indent);', - '$buffer .= htmlspecialchars($value, '.ENT_COMPAT.', \'UTF-8\');', + '$buffer .= htmlspecialchars($value, ' . ENT_COMPAT . ', \'UTF-8\');', '$value = $this->resolveValue($context->last(), $context, $indent);', '$buffer .= \'\\\'bar\\\'\';', 'return $buffer;', diff --git a/test/Mustache/Test/EngineTest.php b/test/Mustache/Test/EngineTest.php index f61f876..eb5c0ff 100644 --- a/test/Mustache/Test/EngineTest.php +++ b/test/Mustache/Test/EngineTest.php @@ -237,7 +237,7 @@ class Mustache_Test_EngineTest extends Mustache_Test_FunctionalTestCase public static function wrapWithUnderscores($text) { - return '__'.$text.'__'; + return '__' . $text . '__'; } /** diff --git a/test/Mustache/Test/FiveThree/Functional/MustacheSpecTest.php b/test/Mustache/Test/FiveThree/Functional/MustacheSpecTest.php index 88094fb..9a32ba0 100644 --- a/test/Mustache/Test/FiveThree/Functional/MustacheSpecTest.php +++ b/test/Mustache/Test/FiveThree/Functional/MustacheSpecTest.php @@ -23,7 +23,7 @@ class Mustache_Test_FiveThree_Functional_MustacheSpecTest extends Mustache_Test_ */ public function testSpecInitialized() { - if (!file_exists(dirname(__FILE__).'/../../../../../vendor/spec/specs/')) { + if (!file_exists(dirname(__FILE__) . '/../../../../../vendor/spec/specs/')) { $this->markTestSkipped('Mustache spec submodule not initialized: run "git submodule update --init"'); } } diff --git a/test/Mustache/Test/Functional/ExamplesTest.php b/test/Mustache/Test/Functional/ExamplesTest.php index 9feccaf..a4a481a 100644 --- a/test/Mustache/Test/Functional/ExamplesTest.php +++ b/test/Mustache/Test/Functional/ExamplesTest.php @@ -46,7 +46,7 @@ class Mustache_Test_Functional_ExamplesTest extends PHPUnit_Framework_TestCase */ public function getExamples() { - $path = realpath(dirname(__FILE__).'/../../../fixtures/examples'); + $path = realpath(dirname(__FILE__) . '/../../../fixtures/examples'); $examples = array(); $handle = opendir($path); @@ -55,7 +55,7 @@ class Mustache_Test_Functional_ExamplesTest extends PHPUnit_Framework_TestCase continue; } - $fullpath = $path.'/'.$file; + $fullpath = $path . '/' . $file; if (is_dir($fullpath)) { $examples[$file] = $this->loadExample($fullpath); } @@ -81,7 +81,7 @@ class Mustache_Test_Functional_ExamplesTest extends PHPUnit_Framework_TestCase $handle = opendir($path); while (($file = readdir($handle)) !== false) { - $fullpath = $path.'/'.$file; + $fullpath = $path . '/' . $file; $info = pathinfo($fullpath); if (is_dir($fullpath) && $info['basename'] == 'partials') { @@ -128,7 +128,7 @@ class Mustache_Test_Functional_ExamplesTest extends PHPUnit_Framework_TestCase continue; } - $fullpath = $path.'/'.$file; + $fullpath = $path . '/' . $file; $info = pathinfo($fullpath); if ($info['extension'] === 'mustache') { diff --git a/test/Mustache/Test/Functional/MustacheSpecTest.php b/test/Mustache/Test/Functional/MustacheSpecTest.php index 96fcf40..25c73f2 100644 --- a/test/Mustache/Test/Functional/MustacheSpecTest.php +++ b/test/Mustache/Test/Functional/MustacheSpecTest.php @@ -23,7 +23,7 @@ class Mustache_Test_Functional_MustacheSpecTest extends Mustache_Test_SpecTestCa */ public function testSpecInitialized() { - if (!file_exists(dirname(__FILE__).'/../../../../vendor/spec/specs/')) { + if (!file_exists(dirname(__FILE__) . '/../../../../vendor/spec/specs/')) { $this->markTestSkipped('Mustache spec submodule not initialized: run "git submodule update --init"'); } } diff --git a/test/Mustache/Test/FunctionalTestCase.php b/test/Mustache/Test/FunctionalTestCase.php index 4d243e0..b716b87 100644 --- a/test/Mustache/Test/FunctionalTestCase.php +++ b/test/Mustache/Test/FunctionalTestCase.php @@ -26,14 +26,14 @@ abstract class Mustache_Test_FunctionalTestCase extends PHPUnit_Framework_TestCa */ protected static function rmdir($path) { - $path = rtrim($path, '/').'/'; + $path = rtrim($path, '/') . '/'; $handle = opendir($path); while (($file = readdir($handle)) !== false) { if ($file == '.' || $file == '..') { continue; } - $fullpath = $path.$file; + $fullpath = $path . $file; if (is_dir($fullpath)) { self::rmdir($fullpath); } else { diff --git a/test/Mustache/Test/Loader/FilesystemLoaderTest.php b/test/Mustache/Test/Loader/FilesystemLoaderTest.php index 17c15fa..d569961 100644 --- a/test/Mustache/Test/Loader/FilesystemLoaderTest.php +++ b/test/Mustache/Test/Loader/FilesystemLoaderTest.php @@ -16,7 +16,7 @@ class Mustache_Test_Loader_FilesystemLoaderTest extends PHPUnit_Framework_TestCa { public function testConstructor() { - $baseDir = realpath(dirname(__FILE__).'/../../../fixtures/templates'); + $baseDir = realpath(dirname(__FILE__) . '/../../../fixtures/templates'); $loader = new Mustache_Loader_FilesystemLoader($baseDir, array('extension' => '.ms')); $this->assertEquals('alpha contents', $loader->load('alpha')); $this->assertEquals('beta contents', $loader->load('beta.ms')); @@ -24,14 +24,14 @@ class Mustache_Test_Loader_FilesystemLoaderTest extends PHPUnit_Framework_TestCa public function testTrailingSlashes() { - $baseDir = dirname(__FILE__).'/../../../fixtures/templates/'; + $baseDir = dirname(__FILE__) . '/../../../fixtures/templates/'; $loader = new Mustache_Loader_FilesystemLoader($baseDir); $this->assertEquals('one contents', $loader->load('one')); } public function testConstructorWithProtocol() { - $baseDir = realpath(dirname(__FILE__).'/../../../fixtures/templates'); + $baseDir = realpath(dirname(__FILE__) . '/../../../fixtures/templates'); $loader = new Mustache_Loader_FilesystemLoader('file://' . $baseDir, array('extension' => '.ms')); $this->assertEquals('alpha contents', $loader->load('alpha')); @@ -40,7 +40,7 @@ class Mustache_Test_Loader_FilesystemLoaderTest extends PHPUnit_Framework_TestCa public function testLoadTemplates() { - $baseDir = realpath(dirname(__FILE__).'/../../../fixtures/templates'); + $baseDir = realpath(dirname(__FILE__) . '/../../../fixtures/templates'); $loader = new Mustache_Loader_FilesystemLoader($baseDir); $this->assertEquals('one contents', $loader->load('one')); $this->assertEquals('two contents', $loader->load('two.mustache')); @@ -48,7 +48,7 @@ class Mustache_Test_Loader_FilesystemLoaderTest extends PHPUnit_Framework_TestCa public function testEmptyExtensionString() { - $baseDir = realpath(dirname(__FILE__).'/../../../fixtures/templates'); + $baseDir = realpath(dirname(__FILE__) . '/../../../fixtures/templates'); $loader = new Mustache_Loader_FilesystemLoader($baseDir, array('extension' => '')); $this->assertEquals('one contents', $loader->load('one.mustache')); @@ -64,7 +64,7 @@ class Mustache_Test_Loader_FilesystemLoaderTest extends PHPUnit_Framework_TestCa */ public function testMissingBaseDirThrowsException() { - new Mustache_Loader_FilesystemLoader(dirname(__FILE__).'/not_a_directory'); + new Mustache_Loader_FilesystemLoader(dirname(__FILE__) . '/not_a_directory'); } /** @@ -72,7 +72,7 @@ class Mustache_Test_Loader_FilesystemLoaderTest extends PHPUnit_Framework_TestCa */ public function testMissingTemplateThrowsException() { - $baseDir = realpath(dirname(__FILE__).'/../../../fixtures/templates'); + $baseDir = realpath(dirname(__FILE__) . '/../../../fixtures/templates'); $loader = new Mustache_Loader_FilesystemLoader($baseDir); $loader->load('fake'); From 6b5a695e9de4f1e648f69831d305d4251ca55a6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dariusz=20Rumi=C5=84ski?= Date: Sat, 6 Sep 2014 01:23:34 +0200 Subject: [PATCH 07/31] strict comparisons --- test/Mustache/Test/Functional/ExamplesTest.php | 6 +++--- test/Mustache/Test/FunctionalTestCase.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/Mustache/Test/Functional/ExamplesTest.php b/test/Mustache/Test/Functional/ExamplesTest.php index a4a481a..68754a6 100644 --- a/test/Mustache/Test/Functional/ExamplesTest.php +++ b/test/Mustache/Test/Functional/ExamplesTest.php @@ -51,7 +51,7 @@ class Mustache_Test_Functional_ExamplesTest extends PHPUnit_Framework_TestCase $handle = opendir($path); while (($file = readdir($handle)) !== false) { - if ($file == '.' || $file == '..') { + if ($file === '.' || $file === '..') { continue; } @@ -84,7 +84,7 @@ class Mustache_Test_Functional_ExamplesTest extends PHPUnit_Framework_TestCase $fullpath = $path . '/' . $file; $info = pathinfo($fullpath); - if (is_dir($fullpath) && $info['basename'] == 'partials') { + if (is_dir($fullpath) && $info['basename'] === 'partials') { // load partials $partials = $this->loadPartials($fullpath); } elseif (is_file($fullpath)) { @@ -124,7 +124,7 @@ class Mustache_Test_Functional_ExamplesTest extends PHPUnit_Framework_TestCase $handle = opendir($path); while (($file = readdir($handle)) !== false) { - if ($file == '.' || $file == '..') { + if ($file === '.' || $file === '..') { continue; } diff --git a/test/Mustache/Test/FunctionalTestCase.php b/test/Mustache/Test/FunctionalTestCase.php index b716b87..34647fc 100644 --- a/test/Mustache/Test/FunctionalTestCase.php +++ b/test/Mustache/Test/FunctionalTestCase.php @@ -29,7 +29,7 @@ abstract class Mustache_Test_FunctionalTestCase extends PHPUnit_Framework_TestCa $path = rtrim($path, '/') . '/'; $handle = opendir($path); while (($file = readdir($handle)) !== false) { - if ($file == '.' || $file == '..') { + if ($file === '.' || $file === '..') { continue; } From 6d833738b1ff25499614db20680117807aee5e39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dariusz=20Rumi=C5=84ski?= Date: Sat, 6 Sep 2014 01:27:56 +0200 Subject: [PATCH 08/31] select fixers for PHP CS Fixer --- .php_cs | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/.php_cs b/.php_cs index 0965a1b..b748bc4 100644 --- a/.php_cs +++ b/.php_cs @@ -1,6 +1,34 @@ registerBuiltInFixers(); + +$fixers = array(); + +foreach ($fixer->getFixers() as $fixer) { + $level = $fixer->getLevel(); + + if (!isset($fixers[$level])) { + $fixers[$level] = array(); + } + + $fixers[$level][] = $fixer->getName(); +} + +$fixers = array_merge( + $fixers[FixerInterface::PSR0_LEVEL], + $fixers[FixerInterface::PSR1_LEVEL], + $fixers[FixerInterface::PSR2_LEVEL], + $fixers[FixerInterface::ALL_LEVEL], + array('concat_with_spaces', 'ordered_use', 'strict') +); + +$config = new Config(); +$config->fixers($fixers); $config->getFinder()->in(__DIR__)->exclude('bin'); return $config; From bd4ef99180478c9ff2bbe08519a2e318cbe652de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dariusz=20Rumi=C5=84ski?= Date: Sat, 6 Sep 2014 11:30:11 +0200 Subject: [PATCH 09/31] .php_cs no need for ordered_use --- .php_cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.php_cs b/.php_cs index b748bc4..1265160 100644 --- a/.php_cs +++ b/.php_cs @@ -24,7 +24,7 @@ $fixers = array_merge( $fixers[FixerInterface::PSR1_LEVEL], $fixers[FixerInterface::PSR2_LEVEL], $fixers[FixerInterface::ALL_LEVEL], - array('concat_with_spaces', 'ordered_use', 'strict') + array('concat_with_spaces', 'strict') ); $config = new Config(); From 9340b3eed10d7652314aa110abc52035af201727 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dariusz=20Rumi=C5=84ski?= Date: Sun, 14 Sep 2014 18:21:08 +0200 Subject: [PATCH 10/31] Fix multiline array CS --- src/Mustache/Tokenizer.php | 4 +- test/Mustache/Test/CompilerTest.php | 14 ++-- test/Mustache/Test/ContextTest.php | 2 +- test/Mustache/Test/EngineTest.php | 8 +-- .../Test/FiveThree/Functional/EngineTest.php | 2 +- .../Test/FiveThree/Functional/FiltersTest.php | 4 +- .../Functional/HigherOrderSectionsTest.php | 2 +- .../Functional/PartialLambdaIndentTest.php | 2 +- .../Mustache/Test/Functional/ExamplesTest.php | 2 +- .../Test/Functional/InheritanceTest.php | 70 +++++++++---------- .../Test/Functional/MustacheInjectionTest.php | 8 +-- .../Functional/NestedPartialIndentTest.php | 2 +- test/Mustache/Test/Loader/ArrayLoaderTest.php | 4 +- .../Mustache/Test/Logger/StreamLoggerTest.php | 8 +-- test/Mustache/Test/ParserTest.php | 66 ++++++++--------- test/Mustache/Test/TokenizerTest.php | 24 +++---- .../examples/dot_notation/DotNotation.php | 2 +- .../GrandParentContext.php | 4 +- .../recursive_partials/RecursivePartials.php | 2 +- .../SectionMagicObjects.php | 2 +- .../sections_nested/SectionsNested.php | 6 +- 21 files changed, 119 insertions(+), 119 deletions(-) diff --git a/src/Mustache/Tokenizer.php b/src/Mustache/Tokenizer.php index 467ec68..ec43092 100644 --- a/src/Mustache/Tokenizer.php +++ b/src/Mustache/Tokenizer.php @@ -155,7 +155,7 @@ class Mustache_Tokenizer self::OTAG => $this->otag, self::CTAG => $this->ctag, 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) { @@ -235,7 +235,7 @@ class Mustache_Tokenizer $this->tokens[] = array( self::TYPE => self::T_TEXT, self::LINE => $this->line, - self::VALUE => $this->buffer + self::VALUE => $this->buffer, ); $this->buffer = ''; } diff --git a/test/Mustache/Test/CompilerTest.php b/test/Mustache/Test/CompilerTest.php index b6bcbdc..ce0eee6 100644 --- a/test/Mustache/Test/CompilerTest.php +++ b/test/Mustache/Test/CompilerTest.php @@ -47,7 +47,7 @@ class Mustache_Test_CompilerTest extends PHPUnit_Framework_TestCase array( Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_ESCAPED, Mustache_Tokenizer::NAME => 'name', - ) + ), ), 'Monkey', true, @@ -58,7 +58,7 @@ class Mustache_Test_CompilerTest extends PHPUnit_Framework_TestCase '$value = $this->resolveValue($context->find(\'name\'), $context, $indent);', '$buffer .= $indent . call_user_func($this->mustache->getEscape(), $value);', 'return $buffer;', - ) + ), ), array( @@ -67,7 +67,7 @@ class Mustache_Test_CompilerTest extends PHPUnit_Framework_TestCase array( Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_ESCAPED, Mustache_Tokenizer::NAME => 'name', - ) + ), ), 'Monkey', false, @@ -78,7 +78,7 @@ class Mustache_Test_CompilerTest extends PHPUnit_Framework_TestCase '$value = $this->resolveValue($context->find(\'name\'), $context, $indent);', '$buffer .= $indent . htmlspecialchars($value, ' . ENT_COMPAT . ', \'ISO-8859-1\');', 'return $buffer;', - ) + ), ), array( @@ -87,7 +87,7 @@ class Mustache_Test_CompilerTest extends PHPUnit_Framework_TestCase array( Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_ESCAPED, Mustache_Tokenizer::NAME => 'name', - ) + ), ), 'Monkey', false, @@ -98,7 +98,7 @@ class Mustache_Test_CompilerTest extends PHPUnit_Framework_TestCase '$value = $this->resolveValue($context->find(\'name\'), $context, $indent);', '$buffer .= $indent . htmlspecialchars($value, ' . ENT_QUOTES . ', \'ISO-8859-1\');', 'return $buffer;', - ) + ), ), array( @@ -127,7 +127,7 @@ class Mustache_Test_CompilerTest extends PHPUnit_Framework_TestCase '$value = $this->resolveValue($context->last(), $context, $indent);', '$buffer .= \'\\\'bar\\\'\';', 'return $buffer;', - ) + ), ), ); } diff --git a/test/Mustache/Test/ContextTest.php b/test/Mustache/Test/ContextTest.php index 70fecc7..864b448 100644 --- a/test/Mustache/Test/ContextTest.php +++ b/test/Mustache/Test/ContextTest.php @@ -22,7 +22,7 @@ class Mustache_Test_ContextTest extends PHPUnit_Framework_TestCase $two = new Mustache_Context(array( 'foo' => 'FOO', - 'bar' => '' + 'bar' => '', )); $this->assertEquals('FOO', $two->find('foo')); $this->assertEquals('', $two->find('bar')); diff --git a/test/Mustache/Test/EngineTest.php b/test/Mustache/Test/EngineTest.php index eb5c0ff..ff8b8af 100644 --- a/test/Mustache/Test/EngineTest.php +++ b/test/Mustache/Test/EngineTest.php @@ -151,7 +151,7 @@ class Mustache_Test_EngineTest extends Mustache_Test_FunctionalTestCase public function testWithoutLambdaCache() { $mustache = new MustacheStub(array( - 'cache' => self::$tempDir + 'cache' => self::$tempDir, )); $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( 'foo' => 'FOO', 'baz' => 'BAZ', - )) + )), )); $this->assertEquals('FOOBAZ', $mustache->render('{{>foo}}{{>bar}}{{>baz}}', array())); @@ -327,7 +327,7 @@ class Mustache_Test_EngineTest extends Mustache_Test_FunctionalTestCase public function testUnknownPragmaThrowsException() { 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'); $mustache = new Mustache_Engine(array( - 'logger' => new Mustache_Logger_StreamLogger($name, $level) + 'logger' => new Mustache_Logger_StreamLogger($name, $level), )); return array($name, $mustache); diff --git a/test/Mustache/Test/FiveThree/Functional/EngineTest.php b/test/Mustache/Test/FiveThree/Functional/EngineTest.php index 3c80b2b..7efdcd2 100644 --- a/test/Mustache/Test/FiveThree/Functional/EngineTest.php +++ b/test/Mustache/Test/FiveThree/Functional/EngineTest.php @@ -33,7 +33,7 @@ class Mustache_Test_FiveThree_Functional_EngineTest extends PHPUnit_Framework_Te $helpers = array( 'longdate' => function (\DateTime $value) { return $value->format('Y-m-d h:m:s'); - } + }, ); $data = array( diff --git a/test/Mustache/Test/FiveThree/Functional/FiltersTest.php b/test/Mustache/Test/FiveThree/Functional/FiltersTest.php index 4cbe049..bb03e4d 100644 --- a/test/Mustache/Test/FiveThree/Functional/FiltersTest.php +++ b/test/Mustache/Test/FiveThree/Functional/FiltersTest.php @@ -47,14 +47,14 @@ class Mustache_Test_FiveThree_Functional_FiltersTest extends PHPUnit_Framework_T '{{% FILTERS }}{{ date | longdate }}', $helpers, (object) array('date' => new DateTime('1/1/2000', new DateTimeZone("UTC"))), - '2000-01-01 12:01:00' + '2000-01-01 12:01:00', ), array( '{{% FILTERS }}{{# word | echo }}{{ . }}!{{/ word | echo }}', $helpers, array('word' => 'bacon'), - 'bacon!bacon!bacon!' + 'bacon!bacon!bacon!', ), ); } diff --git a/test/Mustache/Test/FiveThree/Functional/HigherOrderSectionsTest.php b/test/Mustache/Test/FiveThree/Functional/HigherOrderSectionsTest.php index b19b2a7..d24e4be 100644 --- a/test/Mustache/Test/FiveThree/Functional/HigherOrderSectionsTest.php +++ b/test/Mustache/Test/FiveThree/Functional/HigherOrderSectionsTest.php @@ -55,7 +55,7 @@ class Mustache_Test_FiveThree_Functional_HigherOrderSectionsTest extends PHPUnit 'name' => 'Bob', 'wrap' => function ($text) { return sprintf('[[%s]]', $text); - } + }, ); $this->assertEquals(sprintf('[[%s]]', $data['name']), $tpl->render($data)); diff --git a/test/Mustache/Test/FiveThree/Functional/PartialLambdaIndentTest.php b/test/Mustache/Test/FiveThree/Functional/PartialLambdaIndentTest.php index 1ab6e4c..98fc8c0 100644 --- a/test/Mustache/Test/FiveThree/Functional/PartialLambdaIndentTest.php +++ b/test/Mustache/Test/FiveThree/Functional/PartialLambdaIndentTest.php @@ -36,7 +36,7 @@ EOS; EOS; $m = new Mustache_Engine(array( - 'partials' => array('input' => $partial) + 'partials' => array('input' => $partial), )); $tpl = $m->loadTemplate($src); diff --git a/test/Mustache/Test/Functional/ExamplesTest.php b/test/Mustache/Test/Functional/ExamplesTest.php index 68754a6..dcf1fe4 100644 --- a/test/Mustache/Test/Functional/ExamplesTest.php +++ b/test/Mustache/Test/Functional/ExamplesTest.php @@ -28,7 +28,7 @@ class Mustache_Test_Functional_ExamplesTest extends PHPUnit_Framework_TestCase public function testExamples($context, $source, $partials, $expected) { $mustache = new Mustache_Engine(array( - 'partials' => $partials + 'partials' => $partials, )); $this->assertEquals($expected, $mustache->loadTemplate($source)->render($context)); } diff --git a/test/Mustache/Test/Functional/InheritanceTest.php b/test/Mustache/Test/Functional/InheritanceTest.php index 1568d8d..f0d3235 100644 --- a/test/Mustache/Test/Functional/InheritanceTest.php +++ b/test/Mustache/Test/Functional/InheritanceTest.php @@ -24,13 +24,13 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas 'foo' => '{{$baz}}default content{{/baz}}', ), array( - 'bar' => 'set by user' + 'bar' => 'set by user', ), '{{< foo }}{{# bar }}{{$ baz }}{{/ baz }}{{/ bar }}{{/ foo }}', ), array( array( - 'foo' => '{{$baz}}default content{{/baz}}' + 'foo' => '{{$baz}}default content{{/baz}}', ), array( ), @@ -39,19 +39,19 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas array( array( 'foo' => '{{$baz}}default content{{/baz}}', - 'qux' => 'I am a partial' + 'qux' => 'I am a partial', ), array( ), - '{{qux}}{{$baz}}set by template{{/baz}}{{/foo}}' + '{{qux}}{{$baz}}set by template{{/baz}}{{/foo}}', ), array( array( - 'foo' => '{{$baz}}default content{{/baz}}' + 'foo' => '{{$baz}}default content{{/baz}}', ), array(), - '{{=}}<%={{ }}=%>{{/foo}}' - ) + '{{=}}<%={{ }}=%>{{/foo}}', + ), ); } @@ -63,28 +63,28 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas 'foo' => '{{$baz}}default content{{/baz}}', ), array( - 'bar' => 'set by user' + 'bar' => 'set by user', ), '{{ '{{$baz}}default content{{/baz}}' + 'foo' => '{{$baz}}default content{{/baz}}', ), array( ), '{{ '{{$baz}}defualt content{{/baz}}' + 'foo' => '{{$baz}}defualt content{{/baz}}', ), array(), '{{mustache->loadTemplate('{{$foo}}default {{bar}} content{{/foo}}'); $data = array( - 'bar' => 'baz' + 'bar' => 'baz', ); $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}}'); $data = array( - 'bar' => '' + 'bar' => '', ); $this->assertEquals('default content', $tpl->render($data)); @@ -126,7 +126,7 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas ); $data = array( - 'bar' => array('baz' => 'qux') + 'bar' => array('baz' => 'qux'), ); $this->assertEquals('default qux content', $tpl->render($data)); @@ -140,7 +140,7 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas $data = array( 'foo' => array('bar' => 'qux'), - 'baz' => 'three' + 'baz' => 'three', ); $this->assertEquals('default three content', $tpl->render($data)); @@ -153,7 +153,7 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas ); $data = array( - 'bar' => array('baz' => '{{qux}}') + 'bar' => array('baz' => '{{qux}}'), ); $this->assertEquals('default {{qux}} content', $tpl->render($data)); @@ -162,7 +162,7 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas public function testDefaultContentRenderedInsideIncludedTemplates() { $partials = array( - 'include' => '{{$foo}}default content{{/foo}}' + 'include' => '{{$foo}}default content{{/foo}}', ); $this->mustache->setPartials($partials); @@ -179,7 +179,7 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas public function testOverriddenContent() { $partials = array( - 'super' => '...{{$title}}Default title{{/title}}...' + 'super' => '...{{$title}}Default title{{/title}}...', ); $this->mustache->setPartials($partials); @@ -196,7 +196,7 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas public function testOverriddenPartial() { $partials = array( - 'partial' => '|{{$stuff}}...{{/stuff}}{{$default}} default{{/default}}|' + 'partial' => '|{{$stuff}}...{{/stuff}}{{$default}} default{{/default}}|', ); $this->mustache->setPartials($partials); @@ -213,7 +213,7 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas public function testDataDoesNotOverrideBlock() { $partials = array( - 'include' => '{{$var}}var in include{{/var}}' + 'include' => '{{$var}}var in include{{/var}}', ); $this->mustache->setPartials($partials); @@ -223,7 +223,7 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas ); $data = array( - 'var' => 'var in data' + 'var' => 'var in 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() { $partials = array( - 'include' => '{{$var}}var in include{{/var}}' + 'include' => '{{$var}}var in include{{/var}}', ); $this->mustache->setPartials($partials); @@ -242,7 +242,7 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas ); $data = array( - 'var' => 'var in data' + 'var' => 'var in 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() { $partials = array( - 'partial' => '{{$ballmer}}peaking{{/ballmer}}' + 'partial' => '{{$ballmer}}peaking{{/ballmer}}', ); $this->mustache->setPartials($partials); @@ -270,7 +270,7 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas $partials = array( 'partial' => 'stop: - {{$nineties}}collaborate and listen{{/nineties}}' + {{$nineties}}collaborate and listen{{/nineties}}', ); $this->mustache->setPartials($partials); @@ -291,7 +291,7 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas public function testOverrideOneSubstitutionButNotTheOther() { $partials = array( - 'partial' => '{{$stuff}}default one{{/stuff}}, {{$stuff2}}default two{{/stuff2}}' + 'partial' => '{{$stuff}}default one{{/stuff}}, {{$stuff2}}default two{{/stuff2}}', ); $this->mustache->setPartials($partials); @@ -308,7 +308,7 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas public function testSuperTemplatesWithNoParameters() { $partials = array( - 'include' => '{{$foo}}default content{{/foo}}' + 'include' => '{{$foo}}default content{{/foo}}', ); $this->mustache->setPartials($partials); @@ -326,7 +326,7 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas { $partials = array( 'include' => '{{$foo}}default content{{/foo}} {{$bar}}{{ '{{$foo}}include2 default content{{/foo}} {{ '{{$foo}}include2 default content{{/foo}} {{mustache->setPartials($partials); @@ -345,7 +345,7 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas $partials = array( 'parent' => '{{ '{{ '{{$a}}g{{/a}}' + 'grandParent' => '{{$a}}g{{/a}}', ); $this->mustache->setPartials($partials); @@ -364,7 +364,7 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas $partials = array( 'parent' => '{{ '{{ '{{$a}}g{{/a}}' + 'grandParent' => '{{$a}}g{{/a}}', ); $this->mustache->setPartials($partials); @@ -381,7 +381,7 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas public function testIgnoreTextInsideSuperTemplatesButParseArgs() { $partials = array( - 'include' => '{{$foo}}default content{{/foo}}' + 'include' => '{{$foo}}default content{{/foo}}', ); $this->mustache->setPartials($partials); @@ -398,7 +398,7 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas public function testIgnoreTextInsideSuperTemplates() { $partials = array( - 'include' => '{{$foo}}default content{{/foo}}' + 'include' => '{{$foo}}default content{{/foo}}', ); $this->mustache->setPartials($partials); diff --git a/test/Mustache/Test/Functional/MustacheInjectionTest.php b/test/Mustache/Test/Functional/MustacheInjectionTest.php index c2ff3da..d97335e 100644 --- a/test/Mustache/Test/Functional/MustacheInjectionTest.php +++ b/test/Mustache/Test/Functional/MustacheInjectionTest.php @@ -35,25 +35,25 @@ class Mustache_Test_Functional_MustacheInjectionTest extends PHPUnit_Framework_T { $interpolationData = array( 'a' => '{{ b }}', - 'b' => 'FAIL' + 'b' => 'FAIL', ); $sectionData = array( 'a' => true, 'b' => '{{ c }}', - 'c' => 'FAIL' + 'c' => 'FAIL', ); $lambdaInterpolationData = array( 'a' => array($this, 'lambdaInterpolationCallback'), 'b' => '{{ c }}', - 'c' => 'FAIL' + 'c' => 'FAIL', ); $lambdaSectionData = array( 'a' => array($this, 'lambdaSectionCallback'), 'b' => '{{ c }}', - 'c' => 'FAIL' + 'c' => 'FAIL', ); return array( diff --git a/test/Mustache/Test/Functional/NestedPartialIndentTest.php b/test/Mustache/Test/Functional/NestedPartialIndentTest.php index a484cf5..fcc5355 100644 --- a/test/Mustache/Test/Functional/NestedPartialIndentTest.php +++ b/test/Mustache/Test/Functional/NestedPartialIndentTest.php @@ -21,7 +21,7 @@ class Mustache_Test_Functional_NestedPartialIndentTest extends PHPUnit_Framework public function testNestedPartialsAreIndentedProperly($src, array $partials, $expected) { $m = new Mustache_Engine(array( - 'partials' => $partials + 'partials' => $partials, )); $tpl = $m->loadTemplate($src); $this->assertEquals($expected, $tpl->render()); diff --git a/test/Mustache/Test/Loader/ArrayLoaderTest.php b/test/Mustache/Test/Loader/ArrayLoaderTest.php index db164c3..723535c 100644 --- a/test/Mustache/Test/Loader/ArrayLoaderTest.php +++ b/test/Mustache/Test/Loader/ArrayLoaderTest.php @@ -17,7 +17,7 @@ class Mustache_Test_Loader_ArrayLoaderTest extends PHPUnit_Framework_TestCase public function testConstructor() { $loader = new Mustache_Loader_ArrayLoader(array( - 'foo' => 'bar' + 'foo' => 'bar', )); $this->assertEquals('bar', $loader->load('foo')); @@ -26,7 +26,7 @@ class Mustache_Test_Loader_ArrayLoaderTest extends PHPUnit_Framework_TestCase public function testSetAndLoadTemplates() { $loader = new Mustache_Loader_ArrayLoader(array( - 'foo' => 'bar' + 'foo' => 'bar', )); $this->assertEquals('bar', $loader->load('foo')); diff --git a/test/Mustache/Test/Logger/StreamLoggerTest.php b/test/Mustache/Test/Logger/StreamLoggerTest.php index e64c481..2ce0968 100644 --- a/test/Mustache/Test/Logger/StreamLoggerTest.php +++ b/test/Mustache/Test/Logger/StreamLoggerTest.php @@ -134,7 +134,7 @@ class Mustache_Test_Logger_StreamLoggerTest extends PHPUnit_Framework_TestCase Mustache_Logger::ERROR, 'error message', array('name' => 'foo', 'number' => 42), - "ERROR: error message\n" + "ERROR: error message\n", ), // with interpolation @@ -142,7 +142,7 @@ class Mustache_Test_Logger_StreamLoggerTest extends PHPUnit_Framework_TestCase Mustache_Logger::ERROR, 'error {name}-{number}', array('name' => 'foo', 'number' => 42), - "ERROR: error foo-42\n" + "ERROR: error foo-42\n", ), // with iterpolation false positive @@ -150,7 +150,7 @@ class Mustache_Test_Logger_StreamLoggerTest extends PHPUnit_Framework_TestCase Mustache_Logger::ERROR, 'error {nothing}', array('name' => 'foo', 'number' => 42), - "ERROR: error {nothing}\n" + "ERROR: error {nothing}\n", ), // with interpolation injection @@ -158,7 +158,7 @@ class Mustache_Test_Logger_StreamLoggerTest extends PHPUnit_Framework_TestCase Mustache_Logger::ERROR, '{foo}', array('foo' => '{bar}', 'bar' => 'FAIL'), - "ERROR: {bar}\n" + "ERROR: {bar}\n", ), ); } diff --git a/test/Mustache/Test/ParserTest.php b/test/Mustache/Test/ParserTest.php index b5ba261..ddbbf0c 100644 --- a/test/Mustache/Test/ParserTest.php +++ b/test/Mustache/Test/ParserTest.php @@ -28,7 +28,7 @@ class Mustache_Test_ParserTest extends PHPUnit_Framework_TestCase return array( array( array(), - array() + array(), ), array( @@ -48,12 +48,12 @@ class Mustache_Test_ParserTest extends PHPUnit_Framework_TestCase array(array( Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_ESCAPED, Mustache_Tokenizer::LINE => 0, - Mustache_Tokenizer::NAME => 'name' + Mustache_Tokenizer::NAME => 'name', )), array(array( Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_ESCAPED, 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( Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT, Mustache_Tokenizer::LINE => 0, - Mustache_Tokenizer::VALUE => 'foo' + Mustache_Tokenizer::VALUE => 'foo', ), array( Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_INVERTED, Mustache_Tokenizer::LINE => 0, Mustache_Tokenizer::INDEX => 123, - Mustache_Tokenizer::NAME => 'parent' + Mustache_Tokenizer::NAME => 'parent', ), array( Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_ESCAPED, Mustache_Tokenizer::LINE => 0, - Mustache_Tokenizer::NAME => 'name' + Mustache_Tokenizer::NAME => 'name', ), array( Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_END_SECTION, Mustache_Tokenizer::LINE => 0, Mustache_Tokenizer::INDEX => 456, - Mustache_Tokenizer::NAME => 'parent' + Mustache_Tokenizer::NAME => 'parent', ), array( Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT, 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( Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT, Mustache_Tokenizer::LINE => 0, - Mustache_Tokenizer::VALUE => 'foo' + Mustache_Tokenizer::VALUE => 'foo', ), array( Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_INVERTED, @@ -104,14 +104,14 @@ class Mustache_Test_ParserTest extends PHPUnit_Framework_TestCase array( Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_ESCAPED, Mustache_Tokenizer::LINE => 0, - Mustache_Tokenizer::NAME => 'name' + Mustache_Tokenizer::NAME => 'name', ), ), ), array( Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT, 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( Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT, Mustache_Tokenizer::LINE => 0, - Mustache_Tokenizer::VALUE => 'bar' + Mustache_Tokenizer::VALUE => 'bar', ), ), array( @@ -144,7 +144,7 @@ class Mustache_Test_ParserTest extends PHPUnit_Framework_TestCase array( Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT, 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::CTAG => '}}', Mustache_Tokenizer::LINE => 0, - Mustache_Tokenizer::INDEX => 8 + Mustache_Tokenizer::INDEX => 8, ), array( 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::CTAG => '}}', Mustache_Tokenizer::LINE => 0, - Mustache_Tokenizer::INDEX => 16 + Mustache_Tokenizer::INDEX => 16, ), array( Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT, Mustache_Tokenizer::LINE => 0, - Mustache_Tokenizer::VALUE => 'baz' + Mustache_Tokenizer::VALUE => 'baz', ), array( 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::CTAG => '}}', Mustache_Tokenizer::LINE => 0, - Mustache_Tokenizer::INDEX => 19 + Mustache_Tokenizer::INDEX => 19, ), array( 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::CTAG => '}}', Mustache_Tokenizer::LINE => 0, - Mustache_Tokenizer::INDEX => 27 - ) + Mustache_Tokenizer::INDEX => 27, + ), ), array( array( @@ -262,13 +262,13 @@ class Mustache_Test_ParserTest extends PHPUnit_Framework_TestCase array( Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT, Mustache_Tokenizer::LINE => 0, - Mustache_Tokenizer::VALUE => 'baz' - ) - ) - ) - ) - ) - ) + Mustache_Tokenizer::VALUE => 'baz', + ), + ), + ), + ), + ), + ), ), array( @@ -283,7 +283,7 @@ class Mustache_Test_ParserTest extends PHPUnit_Framework_TestCase array( Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT, Mustache_Tokenizer::LINE => 0, - Mustache_Tokenizer::VALUE => 'bar' + Mustache_Tokenizer::VALUE => 'bar', ), array( Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_END_SECTION, @@ -306,11 +306,11 @@ class Mustache_Test_ParserTest extends PHPUnit_Framework_TestCase array( Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT, 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( Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT, Mustache_Tokenizer::LINE => 0, - Mustache_Tokenizer::VALUE => 'bar' + Mustache_Tokenizer::VALUE => 'bar', ), array( Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_END_SECTION, diff --git a/test/Mustache/Test/TokenizerTest.php b/test/Mustache/Test/TokenizerTest.php index 5432240..ad6495f 100644 --- a/test/Mustache/Test/TokenizerTest.php +++ b/test/Mustache/Test/TokenizerTest.php @@ -83,8 +83,8 @@ class Mustache_Test_TokenizerTest extends PHPUnit_Framework_TestCase Mustache_Tokenizer::CTAG => '}}', Mustache_Tokenizer::LINE => 0, Mustache_Tokenizer::INDEX => 10, - ) - ) + ), + ), ), array( @@ -110,8 +110,8 @@ class Mustache_Test_TokenizerTest extends PHPUnit_Framework_TestCase Mustache_Tokenizer::CTAG => '>>>', Mustache_Tokenizer::LINE => 0, Mustache_Tokenizer::INDEX => 12, - ) - ) + ), + ), ), array( @@ -178,7 +178,7 @@ class Mustache_Test_TokenizerTest extends PHPUnit_Framework_TestCase Mustache_Tokenizer::INDEX => 51, ), - ) + ), ), // 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::INDEX => 9, ), - ) + ), ), // 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::VALUE => "}}}", ), - ) + ), ), // unescaped custom delimiters are properly parsed @@ -269,8 +269,8 @@ class Mustache_Test_TokenizerTest extends PHPUnit_Framework_TestCase Mustache_Tokenizer::CTAG => '%>', Mustache_Tokenizer::LINE => 0, Mustache_Tokenizer::INDEX => 9, - ) - ) + ), + ), ), // 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::CTAG => '}}', Mustache_Tokenizer::LINE => 0, - Mustache_Tokenizer::INDEX => 8 + Mustache_Tokenizer::INDEX => 8, ), array( Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT, @@ -298,8 +298,8 @@ class Mustache_Test_TokenizerTest extends PHPUnit_Framework_TestCase Mustache_Tokenizer::CTAG => '}}', Mustache_Tokenizer::LINE => 0, Mustache_Tokenizer::INDEX => 15, - ) - ) + ), + ), ), ); } diff --git a/test/fixtures/examples/dot_notation/DotNotation.php b/test/fixtures/examples/dot_notation/DotNotation.php index d2939f1..5487503 100644 --- a/test/fixtures/examples/dot_notation/DotNotation.php +++ b/test/fixtures/examples/dot_notation/DotNotation.php @@ -8,7 +8,7 @@ class DotNotation 'hometown' => array( 'city' => 'Cincinnati', 'state' => 'OH', - ) + ), ); public $normal = 'Normal'; diff --git a/test/fixtures/examples/grand_parent_context/GrandParentContext.php b/test/fixtures/examples/grand_parent_context/GrandParentContext.php index ce218fb..af8173f 100644 --- a/test/fixtures/examples/grand_parent_context/GrandParentContext.php +++ b/test/fixtures/examples/grand_parent_context/GrandParentContext.php @@ -9,14 +9,14 @@ class GrandParentContext { $this->parent_contexts[] = array('parent_id' => 'parent1', 'child_contexts' => array( array('child_id' => 'parent1-child1'), - array('child_id' => 'parent1-child2') + array('child_id' => 'parent1-child2'), )); $parent2 = new stdClass(); $parent2->parent_id = 'parent2'; $parent2->child_contexts = array( array('child_id' => 'parent2-child1'), - array('child_id' => 'parent2-child2') + array('child_id' => 'parent2-child2'), ); $this->parent_contexts[] = $parent2; diff --git a/test/fixtures/examples/recursive_partials/RecursivePartials.php b/test/fixtures/examples/recursive_partials/RecursivePartials.php index 092a53d..b9a8947 100644 --- a/test/fixtures/examples/recursive_partials/RecursivePartials.php +++ b/test/fixtures/examples/recursive_partials/RecursivePartials.php @@ -8,6 +8,6 @@ class RecursivePartials 'child' => array( 'name' => 'Justin', 'child' => false, - ) + ), ); } diff --git a/test/fixtures/examples/section_magic_objects/SectionMagicObjects.php b/test/fixtures/examples/section_magic_objects/SectionMagicObjects.php index 2d9b464..b67ed9e 100644 --- a/test/fixtures/examples/section_magic_objects/SectionMagicObjects.php +++ b/test/fixtures/examples/section_magic_objects/SectionMagicObjects.php @@ -16,7 +16,7 @@ class MagicObject { protected $_data = array( 'foo' => 'And it worked the second time.', - 'bar' => 'As well as the third.' + 'bar' => 'As well as the third.', ); public function __get($key) diff --git a/test/fixtures/examples/sections_nested/SectionsNested.php b/test/fixtures/examples/sections_nested/SectionsNested.php index 9360505..7073a2c 100644 --- a/test/fixtures/examples/sections_nested/SectionsNested.php +++ b/test/fixtures/examples/sections_nested/SectionsNested.php @@ -13,7 +13,7 @@ class SectionsNested array('name' => 'Super Macho Man'), array('name' => 'Piston Honda'), array('name' => 'Mr. Sandman'), - ) + ), ), array( 'name' => 'Mike Tyson', @@ -22,13 +22,13 @@ class SectionsNested array('name' => 'King Hippo'), array('name' => 'Great Tiger'), array('name' => 'Glass Joe'), - ) + ), ), array( 'name' => 'Don Flamenco', 'enemies' => array( array('name' => 'Bald Bull'), - ) + ), ), ); } From 74d5dc677cc9ebfdb3a3af6b19d9c2b6ab14d5d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dariusz=20Rumi=C5=84ski?= Date: Tue, 23 Sep 2014 23:40:54 +0200 Subject: [PATCH 11/31] update PHP-CS-Fixer to 1.0 --- .gitignore | 3 +- .php_cs | 34 +++++-------------- .travis.yml | 2 +- .../Test/Functional/InheritanceTest.php | 3 +- 4 files changed, 12 insertions(+), 30 deletions(-) diff --git a/.gitignore b/.gitignore index 15977fb..3861f00 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.php_cs.cache composer.lock -vendor mustache.php +vendor diff --git a/.php_cs b/.php_cs index 1265160..45bfb77 100644 --- a/.php_cs +++ b/.php_cs @@ -1,34 +1,16 @@ registerBuiltInFixers(); +$config = Config::create() + // use default level and extra fixers: + ->fixers(array('-concat_without_spaces', 'concat_with_spaces', 'strict', 'strict_param')) + ->setUsingCache(true) + ->setUsingLinter(false); -$fixers = array(); - -foreach ($fixer->getFixers() as $fixer) { - $level = $fixer->getLevel(); - - if (!isset($fixers[$level])) { - $fixers[$level] = array(); - } - - $fixers[$level][] = $fixer->getName(); -} - -$fixers = array_merge( - $fixers[FixerInterface::PSR0_LEVEL], - $fixers[FixerInterface::PSR1_LEVEL], - $fixers[FixerInterface::PSR2_LEVEL], - $fixers[FixerInterface::ALL_LEVEL], - array('concat_with_spaces', 'strict') -); - -$config = new Config(); -$config->fixers($fixers); -$config->getFinder()->in(__DIR__)->exclude('bin'); +$config->getFinder() + ->in(__DIR__) + ->exclude('bin'); return $config; diff --git a/.travis.yml b/.travis.yml index 59c9d31..3652c44 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ install: script: - phpunit - - if [[ `php -r "echo version_compare(PHP_VERSION, '5.3.6', '>=');"` ]]; then php php-cs-fixer.phar --dry-run -v fix .; fi + - if [[ `php -r "echo version_compare(PHP_VERSION, '5.3.6', '>=');"` ]]; then php php-cs-fixer.phar --diff --dry-run -vv fix; fi php: - 5.2 diff --git a/test/Mustache/Test/Functional/InheritanceTest.php b/test/Mustache/Test/Functional/InheritanceTest.php index f0d3235..5b3ba0c 100644 --- a/test/Mustache/Test/Functional/InheritanceTest.php +++ b/test/Mustache/Test/Functional/InheritanceTest.php @@ -268,8 +268,7 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas public function testInheritIndentationWhenOverridingAPartial() { $partials = array( - 'partial' => - 'stop: + 'partial' => 'stop: {{$nineties}}collaborate and listen{{/nineties}}', ); From e78436c9831ec0720d34f720f5c03e1f476e1a25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dariusz=20Rumi=C5=84ski?= Date: Sat, 15 Nov 2014 14:37:41 +0100 Subject: [PATCH 12/31] .travis.yml - update php-cs-fixer download center --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3652c44..154f656 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: php install: - - curl http://cs.sensiolabs.org/get/php-cs-fixer.phar -o php-cs-fixer.phar + - curl http://get.sensiolabs.org/php-cs-fixer.phar -o php-cs-fixer.phar script: - phpunit From 07c8faa73bf401cc9685fea01fb8b1d0a98b7119 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dariusz=20Rumi=C5=84ski?= Date: Sat, 15 Nov 2014 21:21:19 +0100 Subject: [PATCH 13/31] .php_cs - exclude file --- .php_cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.php_cs b/.php_cs index 45bfb77..6fb0311 100644 --- a/.php_cs +++ b/.php_cs @@ -9,8 +9,13 @@ $config = Config::create() ->setUsingCache(true) ->setUsingLinter(false); -$config->getFinder() +$finder = $config->getFinder() ->in(__DIR__) ->exclude('bin'); +// exclude file due to error on PHP 5.3 that ignore content after __halt_compiler when using token_get_all +if (version_compare(PHP_VERSION, '5.4', '<')) { + $finder->notPath('test/Mustache/Test/Loader/InlineLoaderTest.php'); +} + return $config; From e1458c7ede2deceb9a5613769e51fc99b7199b1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dariusz=20Rumi=C5=84ski?= Date: Sat, 15 Nov 2014 22:28:37 +0100 Subject: [PATCH 14/31] .travis.yml - do not run PHP CS Fixer on HHVM --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 154f656..fbbbc72 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ install: script: - phpunit - - if [[ `php -r "echo version_compare(PHP_VERSION, '5.3.6', '>=');"` ]]; then php php-cs-fixer.phar --diff --dry-run -vv fix; fi + - if [[ `php -r "echo version_compare(PHP_VERSION, '5.3.6', '>=') && !defined('HHVM_VERSION');"` ]]; then php php-cs-fixer.phar --diff --dry-run -vv fix; fi php: - 5.2 From 792b3b4599b49805ca535728ea21fe59dbbe2601 Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Mon, 15 Dec 2014 18:34:29 -0800 Subject: [PATCH 15/31] Shinier, newer badges. --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b33b355..6d4a29f 100644 --- a/README.md +++ b/README.md @@ -3,9 +3,9 @@ Mustache.php A [Mustache](http://mustache.github.com/) implementation in PHP. -[![Package version](http://img.shields.io/packagist/v/mustache/mustache.svg)](https://packagist.org/packages/mustache/mustache) -[![Build status](http://img.shields.io/travis/bobthecow/mustache.php/dev.svg)](http://travis-ci.org/bobthecow/mustache.php) -[![Monthly downloads](http://img.shields.io/packagist/dm/mustache/mustache.svg)](https://packagist.org/packages/mustache/mustache) +[![Package version](http://img.shields.io/packagist/v/mustache/mustache.svg?style=flat-square)](https://packagist.org/packages/mustache/mustache) +[![Build status](http://img.shields.io/travis/bobthecow/mustache.php/dev.svg?style=flat-square)](http://travis-ci.org/bobthecow/mustache.php) +[![Monthly downloads](http://img.shields.io/packagist/dm/mustache/mustache.svg?style=flat-square)](https://packagist.org/packages/mustache/mustache) Usage From 87dd6602668d5afdf0495e6a1bd9e56fa75294d4 Mon Sep 17 00:00:00 2001 From: Benjamin Milde Date: Fri, 19 Dec 2014 18:41:05 +0100 Subject: [PATCH 16/31] Changed dollar sign to a full word Related to: https://github.com/bobthecow/mustache.php/issues/241 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b33b355..7c8294e 100644 --- a/README.md +++ b/README.md @@ -24,9 +24,9 @@ And a more in-depth example -- this is the canonical Mustache template: ```html+jinja Hello {{name}} -You have just won ${{value}}! +You have just won {{value}} dollar! {{#in_ca}} -Well, ${{taxed_value}}, after taxes. +Well, {{taxed_value}} dollar, after taxes. {{/in_ca}} ``` From 7cbc0d07966638046d7d476efdce812c15c9b8dc Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Sat, 27 Dec 2014 07:26:15 -0800 Subject: [PATCH 17/31] Plural, too :) --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0ea38e5..6a309ae 100644 --- a/README.md +++ b/README.md @@ -24,9 +24,9 @@ And a more in-depth example -- this is the canonical Mustache template: ```html+jinja Hello {{name}} -You have just won {{value}} dollar! +You have just won {{value}} dollars! {{#in_ca}} -Well, {{taxed_value}} dollar, after taxes. +Well, {{taxed_value}} dollars, after taxes. {{/in_ca}} ``` From 633d1f2913fb3ee0a1c8e5f5cd8d4c4719822967 Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Sat, 27 Dec 2014 07:29:04 -0800 Subject: [PATCH 18/31] Add hhvm-nightly to Travis config. --- .travis.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.travis.yml b/.travis.yml index fbbbc72..2ac373e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,3 +14,9 @@ php: - 5.5 - 5.6 - hhvm + - hhvm-nightly + +matrix: + allow_failures: + - php: hhvm-nightly + fast_finish: true From 953a1e6bc5e606801de17c5c05e90e2236ae273b Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Sat, 27 Dec 2014 07:33:18 -0800 Subject: [PATCH 19/31] Update php-cs-fixer config. --- .php_cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.php_cs b/.php_cs index 6fb0311..14f84b2 100644 --- a/.php_cs +++ b/.php_cs @@ -4,14 +4,15 @@ use Symfony\CS\Config\Config; use Symfony\CS\FixerInterface; $config = Config::create() - // use default level and extra fixers: - ->fixers(array('-concat_without_spaces', 'concat_with_spaces', 'strict', 'strict_param')) - ->setUsingCache(true) + // use symfony level and extra fixers: + ->level(Symfony\CS\FixerInterface::SYMFONY_LEVEL) + ->fixers(array('-concat_without_spaces', 'concat_with_spaces', 'strict')) ->setUsingLinter(false); $finder = $config->getFinder() - ->in(__DIR__) - ->exclude('bin'); + ->in('bin') + ->in('src') + ->in('test'); // exclude file due to error on PHP 5.3 that ignore content after __halt_compiler when using token_get_all if (version_compare(PHP_VERSION, '5.4', '<')) { From cdb8f8d340964241151ea2f319bcc852c126ed58 Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Sat, 27 Dec 2014 07:33:27 -0800 Subject: [PATCH 20/31] Fix bin/create_example CS --- bin/create_example.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/bin/create_example.php b/bin/create_example.php index 19edfde..d0763ad 100755 --- a/bin/create_example.php +++ b/bin/create_example.php @@ -38,7 +38,7 @@ define('EXAMPLE_PATH', realpath(dirname(__FILE__) . '/../test/fixtures/examples' */ function getLowerCaseName($name) { - return preg_replace_callback("/([A-Z])/", create_function ( + return preg_replace_callback("/([A-Z])/", create_function( '$match', 'return "_" . strtolower($match[1]);' ), lcfirst($name)); @@ -58,7 +58,7 @@ function getLowerCaseName($name) */ function getUpperCaseName($name) { - return preg_replace_callback("/_([a-z])/", create_function ( + return preg_replace_callback("/_([a-z])/", create_function( '$match', 'return strtoupper($match{1});' ), ucfirst($name)); @@ -92,8 +92,8 @@ function out($value) */ function buildPath($directory, $filename = null, $extension = null) { - return out(EXAMPLE_PATH . '/' . $directory. - ($extension !== null && $filename !== null ? '/' . $filename. "." . $extension : "")); + return out(EXAMPLE_PATH . '/' . $directory . + ($extension !== null && $filename !== null ? '/' . $filename . "." . $extension : "")); } /** @@ -170,7 +170,6 @@ if (count($argv) > 1) { $example_name = $argv[1]; main($example_name); - } else { echo USAGE; } From f4f77a7882f8118affa9f9dd564d1462803a71e3 Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Sat, 27 Dec 2014 07:34:16 -0800 Subject: [PATCH 21/31] Better dev dependencies. * Add dependency on php-cs-fixer, since we use it. * Add a useful PHPUnit dependency version. --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 2969d03..137f4ad 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,8 @@ "php": ">=5.2.4" }, "require-dev": { - "phpunit/phpunit": "*" + "phpunit/phpunit": "~3.7|~4.0", + "fabpot/php-cs-fixer": "~1.3" }, "autoload": { "psr-0": { "Mustache": "src/" } From c81138f6acaeafc601a1b60b47f55ab728be4c55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dariusz=20Rumi=C5=84ski?= Date: Sat, 27 Dec 2014 22:12:11 +0100 Subject: [PATCH 22/31] update .php_cs file - set dir to check --- .php_cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.php_cs b/.php_cs index 14f84b2..c4d7dec 100644 --- a/.php_cs +++ b/.php_cs @@ -10,9 +10,7 @@ $config = Config::create() ->setUsingLinter(false); $finder = $config->getFinder() - ->in('bin') - ->in('src') - ->in('test'); + ->in(__DIR__); // exclude file due to error on PHP 5.3 that ignore content after __halt_compiler when using token_get_all if (version_compare(PHP_VERSION, '5.4', '<')) { From fd470db0805ec37ad366ce6bcb8d56e15ec3ae61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dariusz=20Rumi=C5=84ski?= Date: Sat, 27 Dec 2014 22:19:07 +0100 Subject: [PATCH 23/31] .travis.yml - no need for sudo --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 2ac373e..4c894ed 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,6 +16,8 @@ php: - hhvm - hhvm-nightly +sudo: false + matrix: allow_failures: - php: hhvm-nightly From ea0869225313db69c3d5cb9331bd294e8c738d2b Mon Sep 17 00:00:00 2001 From: Dariusz Ruminski Date: Thu, 26 Feb 2015 21:35:27 +0100 Subject: [PATCH 24/31] apply no_empty_lines_after_phpdocs fixer --- test/Mustache/Test/Functional/InheritanceTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/test/Mustache/Test/Functional/InheritanceTest.php b/test/Mustache/Test/Functional/InheritanceTest.php index 5b3ba0c..0c1db99 100644 --- a/test/Mustache/Test/Functional/InheritanceTest.php +++ b/test/Mustache/Test/Functional/InheritanceTest.php @@ -4,7 +4,6 @@ * @group inheritance * @group functional */ - class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCase { private $mustache; From c415dc318df3d07e69a160ebc3bf3d7f789fa90c Mon Sep 17 00:00:00 2001 From: Dariusz Ruminski Date: Thu, 26 Feb 2015 21:36:12 +0100 Subject: [PATCH 25/31] apply phpdoc_trim fixer --- src/Mustache/Loader/InlineLoader.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Mustache/Loader/InlineLoader.php b/src/Mustache/Loader/InlineLoader.php index 9e4ab42..dec5b99 100644 --- a/src/Mustache/Loader/InlineLoader.php +++ b/src/Mustache/Loader/InlineLoader.php @@ -46,7 +46,6 @@ * * @@ hello * Hello, {{ name }}! - * */ class Mustache_Loader_InlineLoader implements Mustache_Loader { From 42c34b6e340de1a680094e0b60091b2b89c4f676 Mon Sep 17 00:00:00 2001 From: Dariusz Ruminski Date: Thu, 26 Feb 2015 21:40:19 +0100 Subject: [PATCH 26/31] apply phpdoc_no_empty_return fixer --- bin/create_example.php | 3 --- src/Mustache/Cache.php | 2 -- src/Mustache/Cache/FilesystemCache.php | 4 ---- src/Mustache/Cache/NoopCache.php | 2 -- src/Mustache/Loader/InlineLoader.php | 1 - src/Mustache/Loader/MutableLoader.php | 4 ---- src/Mustache/Logger.php | 18 ------------------ 7 files changed, 34 deletions(-) diff --git a/bin/create_example.php b/bin/create_example.php index d0763ad..9c12168 100755 --- a/bin/create_example.php +++ b/bin/create_example.php @@ -102,7 +102,6 @@ function buildPath($directory, $filename = null, $extension = null) * * @param string $directory * @access public - * @return void */ function createDirectory($directory) { @@ -120,7 +119,6 @@ function createDirectory($directory) * @param string $extension extension of the file without "." * @param string $content the content of the file * @access public - * @return void */ function createFile($directory, $filename, $extension, $content = "") { @@ -144,7 +142,6 @@ function createFile($directory, $filename, $extension, $content = "") * * @param mixed $example_name * @access public - * @return void */ function main($example_name) { diff --git a/src/Mustache/Cache.php b/src/Mustache/Cache.php index c8fc5d5..e0c15db 100644 --- a/src/Mustache/Cache.php +++ b/src/Mustache/Cache.php @@ -31,8 +31,6 @@ interface Mustache_Cache * * @param string $key * @param string $value - * - * @return void */ public function cache($key, $value); } diff --git a/src/Mustache/Cache/FilesystemCache.php b/src/Mustache/Cache/FilesystemCache.php index 120ad2d..046cd4e 100644 --- a/src/Mustache/Cache/FilesystemCache.php +++ b/src/Mustache/Cache/FilesystemCache.php @@ -60,8 +60,6 @@ class Mustache_Cache_FilesystemCache extends Mustache_Cache_AbstractCache * * @param string $key * @param string $value - * - * @return void */ public function cache($key, $value) { @@ -125,8 +123,6 @@ class Mustache_Cache_FilesystemCache extends Mustache_Cache_AbstractCache * * @param string $fileName * @param string $value - * - * @return void */ private function writeFile($fileName, $value) { diff --git a/src/Mustache/Cache/NoopCache.php b/src/Mustache/Cache/NoopCache.php index d3a7e1f..b6e1dbc 100644 --- a/src/Mustache/Cache/NoopCache.php +++ b/src/Mustache/Cache/NoopCache.php @@ -34,8 +34,6 @@ class Mustache_Cache_NoopCache extends Mustache_Cache_AbstractCache * * @param string $key * @param string $value - * - * @return void */ public function cache($key, $value) { diff --git a/src/Mustache/Loader/InlineLoader.php b/src/Mustache/Loader/InlineLoader.php index 9e4ab42..dec5b99 100644 --- a/src/Mustache/Loader/InlineLoader.php +++ b/src/Mustache/Loader/InlineLoader.php @@ -46,7 +46,6 @@ * * @@ hello * Hello, {{ name }}! - * */ class Mustache_Loader_InlineLoader implements Mustache_Loader { diff --git a/src/Mustache/Loader/MutableLoader.php b/src/Mustache/Loader/MutableLoader.php index 78901be..1c4adc6 100644 --- a/src/Mustache/Loader/MutableLoader.php +++ b/src/Mustache/Loader/MutableLoader.php @@ -18,8 +18,6 @@ interface Mustache_Loader_MutableLoader * Set an associative array of Template sources for this loader. * * @param array $templates - * - * @return void */ public function setTemplates(array $templates); @@ -28,8 +26,6 @@ interface Mustache_Loader_MutableLoader * * @param string $name * @param string $template Mustache Template source - * - * @return void */ public function setTemplate($name, $template); } diff --git a/src/Mustache/Logger.php b/src/Mustache/Logger.php index 2e5d674..116241f 100644 --- a/src/Mustache/Logger.php +++ b/src/Mustache/Logger.php @@ -45,8 +45,6 @@ interface Mustache_Logger * * @param string $message * @param array $context - * - * @return null */ public function emergency($message, array $context = array()); @@ -58,8 +56,6 @@ interface Mustache_Logger * * @param string $message * @param array $context - * - * @return null */ public function alert($message, array $context = array()); @@ -70,8 +66,6 @@ interface Mustache_Logger * * @param string $message * @param array $context - * - * @return null */ public function critical($message, array $context = array()); @@ -81,8 +75,6 @@ interface Mustache_Logger * * @param string $message * @param array $context - * - * @return null */ public function error($message, array $context = array()); @@ -94,8 +86,6 @@ interface Mustache_Logger * * @param string $message * @param array $context - * - * @return null */ public function warning($message, array $context = array()); @@ -104,8 +94,6 @@ interface Mustache_Logger * * @param string $message * @param array $context - * - * @return null */ public function notice($message, array $context = array()); @@ -116,8 +104,6 @@ interface Mustache_Logger * * @param string $message * @param array $context - * - * @return null */ public function info($message, array $context = array()); @@ -126,8 +112,6 @@ interface Mustache_Logger * * @param string $message * @param array $context - * - * @return null */ public function debug($message, array $context = array()); @@ -137,8 +121,6 @@ interface Mustache_Logger * @param mixed $level * @param string $message * @param array $context - * - * @return null */ public function log($level, $message, array $context = array()); } From 22611a957cc1f583013a471b2c5aa51d38b45e3c Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Mon, 2 Mar 2015 21:52:24 -0800 Subject: [PATCH 27/31] CS fixes. Plus add config for StyleCI. --- .php_cs | 2 +- .styleci.yml | 10 ++ bin/build_bootstrap.php | 3 +- bin/create_example.php | 29 ++-- src/Mustache/Cache/FilesystemCache.php | 6 +- src/Mustache/Loader/CascadingLoader.php | 2 +- src/Mustache/Loader/InlineLoader.php | 1 + src/Mustache/Logger.php | 4 +- src/Mustache/Template.php | 2 +- test/Mustache/Test/EngineTest.php | 22 +-- .../FiveThree/Functional/MustacheSpecTest.php | 2 +- .../Test/Functional/InheritanceTest.php | 10 +- .../Test/Functional/MustacheSpecTest.php | 2 +- test/Mustache/Test/ParserTest.php | 132 +++++++++--------- test/Mustache/Test/TokenizerTest.php | 10 +- .../examples/dot_notation/DotNotation.php | 4 +- test/fixtures/examples/i18n/I18n.php | 2 +- .../sections_nested/SectionsNested.php | 6 +- 18 files changed, 134 insertions(+), 115 deletions(-) create mode 100644 .styleci.yml diff --git a/.php_cs b/.php_cs index c4d7dec..6784416 100644 --- a/.php_cs +++ b/.php_cs @@ -6,7 +6,7 @@ use Symfony\CS\FixerInterface; $config = Config::create() // use symfony level and extra fixers: ->level(Symfony\CS\FixerInterface::SYMFONY_LEVEL) - ->fixers(array('-concat_without_spaces', 'concat_with_spaces', 'strict')) + ->fixers(array('align_double_arrow', '-concat_without_spaces', 'concat_with_spaces', 'ordered_use', 'strict')) ->setUsingLinter(false); $finder = $config->getFinder() diff --git a/.styleci.yml b/.styleci.yml new file mode 100644 index 0000000..a871cfe --- /dev/null +++ b/.styleci.yml @@ -0,0 +1,10 @@ +preset: symfony + +enabled: + - align_double_arrow + - concat_with_spaces + - ordered_use + - strict + +disabled: + - concat_without_spaces \ No newline at end of file diff --git a/bin/build_bootstrap.php b/bin/build_bootstrap.php index b40b501..923ed23 100755 --- a/bin/build_bootstrap.php +++ b/bin/build_bootstrap.php @@ -12,7 +12,7 @@ /** * A shell script to create a single-file class cache of the entire Mustache - * library: + * library. * * $ bin/build_bootstrap.php * @@ -72,7 +72,6 @@ SymfonyClassCollectionLoader::load(array( * the unnecessary bits removed. * * @license http://www.opensource.org/licenses/MIT - * * @author Fabien Potencier */ class SymfonyClassCollectionLoader diff --git a/bin/create_example.php b/bin/create_example.php index 9c12168..e8b172f 100755 --- a/bin/create_example.php +++ b/bin/create_example.php @@ -2,7 +2,7 @@ string * AString -> a_string @@ -34,6 +35,7 @@ define('EXAMPLE_PATH', realpath(dirname(__FILE__) . '/../test/fixtures/examples' * * @param string $name * @access public + * * @return string */ function getLowerCaseName($name) @@ -45,7 +47,8 @@ function getLowerCaseName($name) } /** - * transform a string to Uppercase (camelcase) + * transform a string to Uppercase (camelcase). + * * Examples * string -> String * a_string -> AString @@ -54,6 +57,7 @@ function getLowerCaseName($name) * * @param string $name * @access public + * * @return string */ function getUpperCaseName($name) @@ -65,10 +69,11 @@ function getUpperCaseName($name) } /** - * return the given value and echo it out appending "\n" + * return the given value and echo it out appending "\n". * * @param mixed $value * @access public + * * @return mixed */ function out($value) @@ -79,15 +84,17 @@ function out($value) } /** - * create Path for certain files in an example + * create Path for certain files in an example. + * * returns the directory name if only $directory is given. * if an extension is given a complete filename is returned. - * the returned filename will be echoed out + * the returned filename will be echoed out. * * @param string $directory directory without / at the end * @param string $filename filename without path and extension * @param string $extension extension of the file without "." * @access public + * * @return string */ function buildPath($directory, $filename = null, $extension = null) @@ -97,8 +104,9 @@ function buildPath($directory, $filename = null, $extension = null) } /** - * creates the directory for the example - * the script die()'s if mkdir() fails + * creates the directory for the example. + * + * the script die()'s if mkdir() fails. * * @param string $directory * @access public @@ -111,8 +119,9 @@ function createDirectory($directory) } /** - * create a file for the example with the given $content - * the script die()'s if fopen() fails + * create a file for the example with the given $content. + * + * the script die()'s if fopen() fails. * * @param string $directory directory without / at the end * @param string $filename filename without path and extension @@ -132,7 +141,7 @@ function createFile($directory, $filename, $extension, $content = "") } /** - * routine to create the example directory and 3 files + * routine to create the example directory and 3 files. * * if the $example_name is "SomeThing" the following files will be created * examples/some_thing diff --git a/src/Mustache/Cache/FilesystemCache.php b/src/Mustache/Cache/FilesystemCache.php index 046cd4e..bae568b 100644 --- a/src/Mustache/Cache/FilesystemCache.php +++ b/src/Mustache/Cache/FilesystemCache.php @@ -56,7 +56,7 @@ class Mustache_Cache_FilesystemCache extends Mustache_Cache_AbstractCache } /** - * Cache and load the compiled class + * Cache and load the compiled class. * * @param string $key * @param string $value @@ -89,7 +89,7 @@ class Mustache_Cache_FilesystemCache extends Mustache_Cache_AbstractCache } /** - * Create cache directory + * Create cache directory. * * @throws Mustache_Exception_RuntimeException If unable to create directory * @@ -117,7 +117,7 @@ class Mustache_Cache_FilesystemCache extends Mustache_Cache_AbstractCache } /** - * Write cache file + * Write cache file. * * @throws Mustache_Exception_RuntimeException If unable to write file * diff --git a/src/Mustache/Loader/CascadingLoader.php b/src/Mustache/Loader/CascadingLoader.php index d02a273..1650512 100644 --- a/src/Mustache/Loader/CascadingLoader.php +++ b/src/Mustache/Loader/CascadingLoader.php @@ -18,7 +18,7 @@ class Mustache_Loader_CascadingLoader implements Mustache_Loader private $loaders; /** - * Construct a CascadingLoader with an array of loaders: + * Construct a CascadingLoader with an array of loaders. * * $loader = new Mustache_Loader_CascadingLoader(array( * new Mustache_Loader_InlineLoader(__FILE__, __COMPILER_HALT_OFFSET__), diff --git a/src/Mustache/Loader/InlineLoader.php b/src/Mustache/Loader/InlineLoader.php index dec5b99..b1ed9ec 100644 --- a/src/Mustache/Loader/InlineLoader.php +++ b/src/Mustache/Loader/InlineLoader.php @@ -55,6 +55,7 @@ class Mustache_Loader_InlineLoader implements Mustache_Loader /** * The InlineLoader requires a filename and offset to process templates. + * * The magic constants `__FILE__` and `__COMPILER_HALT_OFFSET__` are usually * perfectly suited to the job: * diff --git a/src/Mustache/Logger.php b/src/Mustache/Logger.php index 116241f..3af5049 100644 --- a/src/Mustache/Logger.php +++ b/src/Mustache/Logger.php @@ -10,7 +10,7 @@ */ /** - * Describes a Mustache logger instance + * Describes a Mustache logger instance. * * This is identical to the Psr\Log\LoggerInterface. * @@ -29,7 +29,7 @@ interface Mustache_Logger { /** - * Psr\Log compatible log levels + * Psr\Log compatible log levels. */ const EMERGENCY = 'emergency'; const ALERT = 'alert'; diff --git a/src/Mustache/Template.php b/src/Mustache/Template.php index e7156cf..9404742 100644 --- a/src/Mustache/Template.php +++ b/src/Mustache/Template.php @@ -37,7 +37,7 @@ abstract class Mustache_Template } /** - * Mustache Template instances can be treated as a function and rendered by simply calling them: + * Mustache Template instances can be treated as a function and rendered by simply calling them. * * $m = new Mustache_Engine; * $tpl = $m->loadTemplate('Hello, {{ name }}!'); diff --git a/test/Mustache/Test/EngineTest.php b/test/Mustache/Test/EngineTest.php index ff8b8af..d2ef321 100644 --- a/test/Mustache/Test/EngineTest.php +++ b/test/Mustache/Test/EngineTest.php @@ -21,22 +21,22 @@ class Mustache_Test_EngineTest extends Mustache_Test_FunctionalTestCase $partialsLoader = new Mustache_Loader_ArrayLoader(); $mustache = new Mustache_Engine(array( 'template_class_prefix' => '__whot__', - 'cache' => self::$tempDir, - 'cache_file_mode' => 777, - 'logger' => $logger, - 'loader' => $loader, - 'partials_loader' => $partialsLoader, - 'partials' => array( + 'cache' => self::$tempDir, + 'cache_file_mode' => 777, + 'logger' => $logger, + 'loader' => $loader, + 'partials_loader' => $partialsLoader, + 'partials' => array( 'foo' => '{{ foo }}', ), 'helpers' => array( 'foo' => array($this, 'getFoo'), 'bar' => 'BAR', ), - 'escape' => 'strtoupper', + 'escape' => 'strtoupper', 'entity_flags' => ENT_QUOTES, - 'charset' => 'ISO-8859-1', - 'pragmas' => array(Mustache_Engine::PRAGMA_FILTERS), + 'charset' => 'ISO-8859-1', + 'pragmas' => array(Mustache_Engine::PRAGMA_FILTERS), )); $this->assertSame($logger, $mustache->getLogger()); @@ -127,7 +127,7 @@ class Mustache_Test_EngineTest extends Mustache_Test_FunctionalTestCase { $mustache = new Mustache_Engine(array( 'template_class_prefix' => '__whot__', - 'cache' => self::$tempDir, + 'cache' => self::$tempDir, )); $source = '{{ foo }}'; @@ -140,7 +140,7 @@ class Mustache_Test_EngineTest extends Mustache_Test_FunctionalTestCase public function testLambdaCache() { $mustache = new MustacheStub(array( - 'cache' => self::$tempDir, + 'cache' => self::$tempDir, 'cache_lambda_templates' => true, )); diff --git a/test/Mustache/Test/FiveThree/Functional/MustacheSpecTest.php b/test/Mustache/Test/FiveThree/Functional/MustacheSpecTest.php index 9a32ba0..16ef8f6 100644 --- a/test/Mustache/Test/FiveThree/Functional/MustacheSpecTest.php +++ b/test/Mustache/Test/FiveThree/Functional/MustacheSpecTest.php @@ -10,7 +10,7 @@ */ /** - * A PHPUnit test case wrapping the Mustache Spec + * A PHPUnit test case wrapping the Mustache Spec. * * @group mustache-spec * @group functional diff --git a/test/Mustache/Test/Functional/InheritanceTest.php b/test/Mustache/Test/Functional/InheritanceTest.php index 0c1db99..730dd96 100644 --- a/test/Mustache/Test/Functional/InheritanceTest.php +++ b/test/Mustache/Test/Functional/InheritanceTest.php @@ -323,7 +323,7 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas public function testRecursionInInheritedTemplates() { $partials = array( - 'include' => '{{$foo}}default content{{/foo}} {{$bar}}{{ '{{$foo}}default content{{/foo}} {{$bar}}{{ '{{$foo}}include2 default content{{/foo}} {{ '{{ '{{ '{{ '{{ '{{$a}}g{{/a}}', ); @@ -360,8 +360,8 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas public function testMultiLevelInheritanceNoSubChild() { $partials = array( - 'parent' => '{{ '{{ '{{ '{{ '{{$a}}g{{/a}}', ); diff --git a/test/Mustache/Test/Functional/MustacheSpecTest.php b/test/Mustache/Test/Functional/MustacheSpecTest.php index 25c73f2..b79dcb2 100644 --- a/test/Mustache/Test/Functional/MustacheSpecTest.php +++ b/test/Mustache/Test/Functional/MustacheSpecTest.php @@ -10,7 +10,7 @@ */ /** - * A PHPUnit test case wrapping the Mustache Spec + * A PHPUnit test case wrapping the Mustache Spec. * * @group mustache-spec * @group functional diff --git a/test/Mustache/Test/ParserTest.php b/test/Mustache/Test/ParserTest.php index ddbbf0c..c11410a 100644 --- a/test/Mustache/Test/ParserTest.php +++ b/test/Mustache/Test/ParserTest.php @@ -128,8 +128,8 @@ class Mustache_Test_ParserTest extends PHPUnit_Framework_TestCase Mustache_Tokenizer::LINE => 0, ), array( - Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT, - Mustache_Tokenizer::LINE => 0, + Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT, + Mustache_Tokenizer::LINE => 0, Mustache_Tokenizer::VALUE => 'bar', ), ), @@ -142,8 +142,8 @@ class Mustache_Test_ParserTest extends PHPUnit_Framework_TestCase Mustache_Tokenizer::LINE => 0, ), array( - Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT, - Mustache_Tokenizer::LINE => 0, + Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT, + Mustache_Tokenizer::LINE => 0, Mustache_Tokenizer::VALUE => 'bar', ), ), @@ -152,8 +152,8 @@ class Mustache_Test_ParserTest extends PHPUnit_Framework_TestCase array( array( array( - Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT, - Mustache_Tokenizer::LINE => 0, + Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT, + Mustache_Tokenizer::LINE => 0, Mustache_Tokenizer::VALUE => " ", ), array( @@ -161,8 +161,8 @@ class Mustache_Test_ParserTest extends PHPUnit_Framework_TestCase Mustache_Tokenizer::LINE => 0, ), array( - Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT, - Mustache_Tokenizer::LINE => 0, + Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT, + Mustache_Tokenizer::LINE => 0, Mustache_Tokenizer::VALUE => " \n", ), array( @@ -203,65 +203,65 @@ class Mustache_Test_ParserTest extends PHPUnit_Framework_TestCase array( array( array( - Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_PARENT, - Mustache_Tokenizer::NAME => 'foo', - Mustache_Tokenizer::OTAG => '{{', - Mustache_Tokenizer::CTAG => '}}', - Mustache_Tokenizer::LINE => 0, + Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_PARENT, + Mustache_Tokenizer::NAME => 'foo', + Mustache_Tokenizer::OTAG => '{{', + Mustache_Tokenizer::CTAG => '}}', + Mustache_Tokenizer::LINE => 0, Mustache_Tokenizer::INDEX => 8, ), array( - Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_BLOCK_VAR, - Mustache_Tokenizer::NAME => 'bar', - Mustache_Tokenizer::OTAG => '{{', - Mustache_Tokenizer::CTAG => '}}', - Mustache_Tokenizer::LINE => 0, + Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_BLOCK_VAR, + Mustache_Tokenizer::NAME => 'bar', + Mustache_Tokenizer::OTAG => '{{', + Mustache_Tokenizer::CTAG => '}}', + Mustache_Tokenizer::LINE => 0, Mustache_Tokenizer::INDEX => 16, ), array( - Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT, - Mustache_Tokenizer::LINE => 0, + Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT, + Mustache_Tokenizer::LINE => 0, Mustache_Tokenizer::VALUE => 'baz', ), array( - Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_END_SECTION, - Mustache_Tokenizer::NAME => 'bar', - Mustache_Tokenizer::OTAG => '{{', - Mustache_Tokenizer::CTAG => '}}', - Mustache_Tokenizer::LINE => 0, + Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_END_SECTION, + Mustache_Tokenizer::NAME => 'bar', + Mustache_Tokenizer::OTAG => '{{', + Mustache_Tokenizer::CTAG => '}}', + Mustache_Tokenizer::LINE => 0, Mustache_Tokenizer::INDEX => 19, ), array( - Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_END_SECTION, - Mustache_Tokenizer::NAME => 'foo', - Mustache_Tokenizer::OTAG => '{{', - Mustache_Tokenizer::CTAG => '}}', - Mustache_Tokenizer::LINE => 0, + Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_END_SECTION, + Mustache_Tokenizer::NAME => 'foo', + Mustache_Tokenizer::OTAG => '{{', + Mustache_Tokenizer::CTAG => '}}', + Mustache_Tokenizer::LINE => 0, Mustache_Tokenizer::INDEX => 27, ), ), array( array( - Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_PARENT, - Mustache_Tokenizer::NAME => 'foo', - Mustache_Tokenizer::OTAG => '{{', - Mustache_Tokenizer::CTAG => '}}', - Mustache_Tokenizer::LINE => 0, + Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_PARENT, + Mustache_Tokenizer::NAME => 'foo', + Mustache_Tokenizer::OTAG => '{{', + Mustache_Tokenizer::CTAG => '}}', + Mustache_Tokenizer::LINE => 0, Mustache_Tokenizer::INDEX => 8, - Mustache_Tokenizer::END => 27, + Mustache_Tokenizer::END => 27, Mustache_Tokenizer::NODES => array( array( - Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_BLOCK_ARG, - Mustache_Tokenizer::NAME => 'bar', - Mustache_Tokenizer::OTAG => '{{', - Mustache_Tokenizer::CTAG => '}}', - Mustache_Tokenizer::LINE => 0, + Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_BLOCK_ARG, + Mustache_Tokenizer::NAME => 'bar', + Mustache_Tokenizer::OTAG => '{{', + Mustache_Tokenizer::CTAG => '}}', + Mustache_Tokenizer::LINE => 0, Mustache_Tokenizer::INDEX => 16, - Mustache_Tokenizer::END => 19, + Mustache_Tokenizer::END => 19, Mustache_Tokenizer::NODES => array( array( - Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT, - Mustache_Tokenizer::LINE => 0, + Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT, + Mustache_Tokenizer::LINE => 0, Mustache_Tokenizer::VALUE => 'baz', ), ), @@ -281,31 +281,31 @@ class Mustache_Test_ParserTest extends PHPUnit_Framework_TestCase Mustache_Tokenizer::LINE => 0, ), array( - Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT, - Mustache_Tokenizer::LINE => 0, + Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT, + Mustache_Tokenizer::LINE => 0, Mustache_Tokenizer::VALUE => 'bar', ), array( - Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_END_SECTION, - Mustache_Tokenizer::NAME => 'foo', - Mustache_Tokenizer::OTAG => '{{', - Mustache_Tokenizer::CTAG => '}}', - Mustache_Tokenizer::LINE => 0, + Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_END_SECTION, + Mustache_Tokenizer::NAME => 'foo', + Mustache_Tokenizer::OTAG => '{{', + Mustache_Tokenizer::CTAG => '}}', + Mustache_Tokenizer::LINE => 0, Mustache_Tokenizer::INDEX => 11, ), ), array( array( - Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_BLOCK_VAR, - Mustache_Tokenizer::NAME => 'foo', - Mustache_Tokenizer::OTAG => '{{', - Mustache_Tokenizer::CTAG => '}}', - Mustache_Tokenizer::LINE => 0, - Mustache_Tokenizer::END => 11, + Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_BLOCK_VAR, + Mustache_Tokenizer::NAME => 'foo', + Mustache_Tokenizer::OTAG => '{{', + Mustache_Tokenizer::CTAG => '}}', + Mustache_Tokenizer::LINE => 0, + Mustache_Tokenizer::END => 11, Mustache_Tokenizer::NODES => array( array( - Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT, - Mustache_Tokenizer::LINE => 0, + Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT, + Mustache_Tokenizer::LINE => 0, Mustache_Tokenizer::VALUE => 'bar', ), ), @@ -406,16 +406,16 @@ class Mustache_Test_ParserTest extends PHPUnit_Framework_TestCase Mustache_Tokenizer::LINE => 0, ), array( - Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT, - Mustache_Tokenizer::LINE => 0, + Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT, + Mustache_Tokenizer::LINE => 0, Mustache_Tokenizer::VALUE => 'bar', ), array( - Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_END_SECTION, - Mustache_Tokenizer::NAME => 'foo', - Mustache_Tokenizer::OTAG => '{{', - Mustache_Tokenizer::CTAG => '}}', - Mustache_Tokenizer::LINE => 0, + Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_END_SECTION, + Mustache_Tokenizer::NAME => 'foo', + Mustache_Tokenizer::OTAG => '{{', + Mustache_Tokenizer::CTAG => '}}', + Mustache_Tokenizer::LINE => 0, Mustache_Tokenizer::INDEX => 11, ), ), diff --git a/test/Mustache/Test/TokenizerTest.php b/test/Mustache/Test/TokenizerTest.php index ad6495f..9ed65e2 100644 --- a/test/Mustache/Test/TokenizerTest.php +++ b/test/Mustache/Test/TokenizerTest.php @@ -279,11 +279,11 @@ class Mustache_Test_TokenizerTest extends PHPUnit_Framework_TestCase null, array( array( - Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_BLOCK_VAR, - Mustache_Tokenizer::NAME => 'arg', - Mustache_Tokenizer::OTAG => '{{', - Mustache_Tokenizer::CTAG => '}}', - Mustache_Tokenizer::LINE => 0, + Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_BLOCK_VAR, + Mustache_Tokenizer::NAME => 'arg', + Mustache_Tokenizer::OTAG => '{{', + Mustache_Tokenizer::CTAG => '}}', + Mustache_Tokenizer::LINE => 0, Mustache_Tokenizer::INDEX => 8, ), array( diff --git a/test/fixtures/examples/dot_notation/DotNotation.php b/test/fixtures/examples/dot_notation/DotNotation.php index 5487503..7edbc00 100644 --- a/test/fixtures/examples/dot_notation/DotNotation.php +++ b/test/fixtures/examples/dot_notation/DotNotation.php @@ -3,8 +3,8 @@ class DotNotation { public $person = array( - 'name' => array('first' => 'Chris', 'last' => 'Firescythe'), - 'age' => 24, + 'name' => array('first' => 'Chris', 'last' => 'Firescythe'), + 'age' => 24, 'hometown' => array( 'city' => 'Cincinnati', 'state' => 'OH', diff --git a/test/fixtures/examples/i18n/I18n.php b/test/fixtures/examples/i18n/I18n.php index 5fc26d9..8508a59 100644 --- a/test/fixtures/examples/i18n/I18n.php +++ b/test/fixtures/examples/i18n/I18n.php @@ -10,7 +10,7 @@ class I18n // A *very* small i18n dictionary :) private static $dictionary = array( - 'Hello.' => 'Hola.', + 'Hello.' => 'Hola.', 'My name is {{ name }}.' => 'Me llamo {{ name }}.', ); diff --git a/test/fixtures/examples/sections_nested/SectionsNested.php b/test/fixtures/examples/sections_nested/SectionsNested.php index 7073a2c..23dac63 100644 --- a/test/fixtures/examples/sections_nested/SectionsNested.php +++ b/test/fixtures/examples/sections_nested/SectionsNested.php @@ -8,7 +8,7 @@ class SectionsNested { return array( array( - 'name' => 'Von Kaiser', + 'name' => 'Von Kaiser', 'enemies' => array( array('name' => 'Super Macho Man'), array('name' => 'Piston Honda'), @@ -16,7 +16,7 @@ class SectionsNested ), ), array( - 'name' => 'Mike Tyson', + 'name' => 'Mike Tyson', 'enemies' => array( array('name' => 'Soda Popinski'), array('name' => 'King Hippo'), @@ -25,7 +25,7 @@ class SectionsNested ), ), array( - 'name' => 'Don Flamenco', + 'name' => 'Don Flamenco', 'enemies' => array( array('name' => 'Bald Bull'), ), From 067fd6c33e2031f52168cc5f03914e941d7f9830 Mon Sep 17 00:00:00 2001 From: Mike Sherov Date: Tue, 3 Mar 2015 11:47:22 -0500 Subject: [PATCH 28/31] Failing Test For Inheritance Indentation inside a replacement variable. --- .../Test/Functional/InheritanceTest.php | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/Mustache/Test/Functional/InheritanceTest.php b/test/Mustache/Test/Functional/InheritanceTest.php index 730dd96..122ed31 100644 --- a/test/Mustache/Test/Functional/InheritanceTest.php +++ b/test/Mustache/Test/Functional/InheritanceTest.php @@ -286,6 +286,29 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas ); } + public function testInheritSpacingWhenOverridingAPartial() + { + $partials = array( + 'parent' => 'collaborate_and{{$id}}{{/id}}', + 'child' => '{{mustache->setPartials($partials); + + $tpl = $this->mustache->loadTemplate( + 'stop: + {{>child}}' + ); + + $data = array(); + + $this->assertEquals( + 'stop: + collaborate_and_listen', + $tpl->render($data) + ); + } + public function testOverrideOneSubstitutionButNotTheOther() { $partials = array( From 7cb9fdff6a6a86fa37403444705c508ec3de8f13 Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Tue, 3 Mar 2015 10:05:27 -0800 Subject: [PATCH 29/31] Never indent block arg sections. Fixes #253 --- src/Mustache/Compiler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mustache/Compiler.php b/src/Mustache/Compiler.php index c872df4..860316f 100644 --- a/src/Mustache/Compiler.php +++ b/src/Mustache/Compiler.php @@ -263,7 +263,7 @@ class Mustache_Compiler const BLOCK_ARG = ' // %s block_arg - $value = $this->section%s($context, $indent, true); + $value = $this->section%s($context, \'\', true); $newContext[%s] = %s$value; '; From 47eb13cb2656780cb7084d543d323cc6f54048e0 Mon Sep 17 00:00:00 2001 From: Dariusz Ruminski Date: Sat, 28 Mar 2015 17:54:07 +0100 Subject: [PATCH 30/31] CS update --- .php_cs | 5 ---- bin/create_example.php | 16 ++++++------ composer.json | 2 +- src/Mustache/Cache.php | 2 +- src/Mustache/Cache/AbstractCache.php | 6 ++--- src/Mustache/Cache/FilesystemCache.php | 2 +- src/Mustache/Cache/NoopCache.php | 2 +- src/Mustache/Compiler.php | 14 +++++----- src/Mustache/Engine.php | 8 +++--- src/Mustache/HelperCollection.php | 6 ++--- src/Mustache/Logger/StreamLogger.php | 20 +++++++------- src/Mustache/Parser.php | 2 +- src/Mustache/Template.php | 4 +-- src/Mustache/Tokenizer.php | 2 +- test/Mustache/Test/EngineTest.php | 2 +- .../Test/FiveThree/Functional/EngineTest.php | 2 +- .../Test/FiveThree/Functional/FiltersTest.php | 4 +-- .../Mustache/Test/Logger/StreamLoggerTest.php | 4 +-- test/Mustache/Test/ParserTest.php | 2 +- test/Mustache/Test/TokenizerTest.php | 26 +++++++++---------- .../examples/delimiters/Delimiters.php | 8 +++--- .../examples/double_section/DoubleSection.php | 2 +- .../SectionIteratorObjects.php | 4 +-- .../SectionMagicObjects.php | 4 +-- .../section_objects/SectionObjects.php | 4 +-- test/fixtures/examples/sections/Sections.php | 8 +++--- test/fixtures/examples/simple/Simple.php | 2 +- .../fixtures/examples/unescaped/Unescaped.php | 2 +- 28 files changed, 80 insertions(+), 85 deletions(-) diff --git a/.php_cs b/.php_cs index 6784416..8ea84c3 100644 --- a/.php_cs +++ b/.php_cs @@ -12,9 +12,4 @@ $config = Config::create() $finder = $config->getFinder() ->in(__DIR__); -// exclude file due to error on PHP 5.3 that ignore content after __halt_compiler when using token_get_all -if (version_compare(PHP_VERSION, '5.4', '<')) { - $finder->notPath('test/Mustache/Test/Loader/InlineLoaderTest.php'); -} - return $config; diff --git a/bin/create_example.php b/bin/create_example.php index e8b172f..cca36f3 100755 --- a/bin/create_example.php +++ b/bin/create_example.php @@ -40,7 +40,7 @@ define('EXAMPLE_PATH', realpath(dirname(__FILE__) . '/../test/fixtures/examples' */ function getLowerCaseName($name) { - return preg_replace_callback("/([A-Z])/", create_function( + return preg_replace_callback('/([A-Z])/', create_function( '$match', 'return "_" . strtolower($match[1]);' ), lcfirst($name)); @@ -62,7 +62,7 @@ function getLowerCaseName($name) */ function getUpperCaseName($name) { - return preg_replace_callback("/_([a-z])/", create_function( + return preg_replace_callback('/_([a-z])/', create_function( '$match', 'return strtoupper($match{1});' ), ucfirst($name)); @@ -100,7 +100,7 @@ function out($value) function buildPath($directory, $filename = null, $extension = null) { return out(EXAMPLE_PATH . '/' . $directory . - ($extension !== null && $filename !== null ? '/' . $filename . "." . $extension : "")); + ($extension !== null && $filename !== null ? '/' . $filename . '.' . $extension : '')); } /** @@ -129,9 +129,9 @@ function createDirectory($directory) * @param string $content the content of the file * @access public */ -function createFile($directory, $filename, $extension, $content = "") +function createFile($directory, $filename, $extension, $content = '') { - $handle = @fopen(buildPath($directory, $filename, $extension), "w"); + $handle = @fopen(buildPath($directory, $filename, $extension), 'w'); if ($handle) { fwrite($handle, $content); fclose($handle); @@ -157,9 +157,9 @@ function main($example_name) $lowercase = getLowerCaseName($example_name); $uppercase = getUpperCaseName($example_name); createDirectory($lowercase); - createFile($lowercase, $lowercase, "mustache"); - createFile($lowercase, $lowercase, "txt"); - createFile($lowercase, $uppercase, "php", <<getLoggedMustache(Mustache_Logger::DEBUG); $mustache->render('{{ foo }}{{> bar }}', array('foo' => 'FOO')); $log = file_get_contents($name); - $this->assertContains("DEBUG: Instantiating template: ", $log); + $this->assertContains('DEBUG: Instantiating template: ', $log); $this->assertContains("WARNING: Partial not found: \"bar\"", $log); } diff --git a/test/Mustache/Test/FiveThree/Functional/EngineTest.php b/test/Mustache/Test/FiveThree/Functional/EngineTest.php index 7efdcd2..3bc43ca 100644 --- a/test/Mustache/Test/FiveThree/Functional/EngineTest.php +++ b/test/Mustache/Test/FiveThree/Functional/EngineTest.php @@ -44,7 +44,7 @@ class Mustache_Test_FiveThree_Functional_EngineTest extends PHPUnit_Framework_Te return array( array(array(Mustache_Engine::PRAGMA_FILTERS), $helpers, $data, $tpl, '2000-01-01 12:01:00'), - array(array(), $helpers, $data, $tpl, '' ), + array(array(), $helpers, $data, $tpl, ''), ); } } diff --git a/test/Mustache/Test/FiveThree/Functional/FiltersTest.php b/test/Mustache/Test/FiveThree/Functional/FiltersTest.php index bb03e4d..9fee396 100644 --- a/test/Mustache/Test/FiveThree/Functional/FiltersTest.php +++ b/test/Mustache/Test/FiveThree/Functional/FiltersTest.php @@ -46,7 +46,7 @@ class Mustache_Test_FiveThree_Functional_FiltersTest extends PHPUnit_Framework_T array( '{{% FILTERS }}{{ date | longdate }}', $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', ), @@ -72,7 +72,7 @@ class Mustache_Test_FiveThree_Functional_FiltersTest extends PHPUnit_Framework_T }); $foo = new \StdClass(); - $foo->date = new DateTime('1/1/2000', new DateTimeZone("UTC")); + $foo->date = new DateTime('1/1/2000', new DateTimeZone('UTC')); $this->assertEquals('[[2000-01-01 12:01:00]]', $tpl->render($foo)); } diff --git a/test/Mustache/Test/Logger/StreamLoggerTest.php b/test/Mustache/Test/Logger/StreamLoggerTest.php index 2ce0968..c0dc7cb 100644 --- a/test/Mustache/Test/Logger/StreamLoggerTest.php +++ b/test/Mustache/Test/Logger/StreamLoggerTest.php @@ -55,13 +55,13 @@ class Mustache_Test_Logger_StreamLoggerTest extends PHPUnit_Framework_TestCase { $stream = tmpfile(); $logger = new Mustache_Logger_StreamLogger($stream, $logLevel); - $logger->log($level, "logged"); + $logger->log($level, 'logged'); rewind($stream); $result = fread($stream, 1024); if ($shouldLog) { - $this->assertContains("logged", $result); + $this->assertContains('logged', $result); } else { $this->assertEmpty($result); } diff --git a/test/Mustache/Test/ParserTest.php b/test/Mustache/Test/ParserTest.php index c11410a..77c6fae 100644 --- a/test/Mustache/Test/ParserTest.php +++ b/test/Mustache/Test/ParserTest.php @@ -154,7 +154,7 @@ class Mustache_Test_ParserTest extends PHPUnit_Framework_TestCase array( Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT, Mustache_Tokenizer::LINE => 0, - Mustache_Tokenizer::VALUE => " ", + Mustache_Tokenizer::VALUE => ' ', ), array( Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_DELIM_CHANGE, diff --git a/test/Mustache/Test/TokenizerTest.php b/test/Mustache/Test/TokenizerTest.php index 9ed65e2..c9fb5b9 100644 --- a/test/Mustache/Test/TokenizerTest.php +++ b/test/Mustache/Test/TokenizerTest.php @@ -30,7 +30,7 @@ class Mustache_Test_TokenizerTest extends PHPUnit_Framework_TestCase { $tokenizer = new Mustache_Tokenizer(); - $text = "{{{ name }}"; + $text = '{{{ name }}'; $tokenizer->scan($text, null); } @@ -41,8 +41,8 @@ class Mustache_Test_TokenizerTest extends PHPUnit_Framework_TestCase { $tokenizer = new Mustache_Tokenizer(); - $text = "<%{ name %>"; - $tokenizer->scan($text, "<% %>"); + $text = '<%{ name %>'; + $tokenizer->scan($text, '<% %>'); } public function getTokens() @@ -183,7 +183,7 @@ class Mustache_Test_TokenizerTest extends PHPUnit_Framework_TestCase // See https://github.com/bobthecow/mustache.php/issues/183 array( - "{{# a }}0{{/ a }}", + '{{# a }}0{{/ a }}', null, array( array( @@ -197,7 +197,7 @@ class Mustache_Test_TokenizerTest extends PHPUnit_Framework_TestCase array( Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT, Mustache_Tokenizer::LINE => 0, - Mustache_Tokenizer::VALUE => "0", + Mustache_Tokenizer::VALUE => '0', ), array( Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_END_SECTION, @@ -212,8 +212,8 @@ class Mustache_Test_TokenizerTest extends PHPUnit_Framework_TestCase // custom delimiters don't swallow the next character, even if it is a }, }}}, or the same delimiter array( - "<% a %>} <% b %>%> <% c %>}}}", - "<% %>", + '<% a %>} <% b %>%> <% c %>}}}', + '<% %>', array( array( Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_ESCAPED, @@ -226,7 +226,7 @@ class Mustache_Test_TokenizerTest extends PHPUnit_Framework_TestCase array( Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT, Mustache_Tokenizer::LINE => 0, - Mustache_Tokenizer::VALUE => "} ", + Mustache_Tokenizer::VALUE => '} ', ), array( Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_ESCAPED, @@ -239,7 +239,7 @@ class Mustache_Test_TokenizerTest extends PHPUnit_Framework_TestCase array( Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT, Mustache_Tokenizer::LINE => 0, - Mustache_Tokenizer::VALUE => "%> ", + Mustache_Tokenizer::VALUE => '%> ', ), array( Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_ESCAPED, @@ -252,15 +252,15 @@ class Mustache_Test_TokenizerTest extends PHPUnit_Framework_TestCase array( Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT, Mustache_Tokenizer::LINE => 0, - Mustache_Tokenizer::VALUE => "}}}", + Mustache_Tokenizer::VALUE => '}}}', ), ), ), // unescaped custom delimiters are properly parsed array( - "<%{ a }%>", - "<% %>", + '<%{ a }%>', + '<% %>', array( array( Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_UNESCAPED, @@ -289,7 +289,7 @@ class Mustache_Test_TokenizerTest extends PHPUnit_Framework_TestCase array( Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT, Mustache_Tokenizer::LINE => 0, - Mustache_Tokenizer::VALUE => "default", + Mustache_Tokenizer::VALUE => 'default', ), array( Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_END_SECTION, diff --git a/test/fixtures/examples/delimiters/Delimiters.php b/test/fixtures/examples/delimiters/Delimiters.php index 6f03557..6db842a 100644 --- a/test/fixtures/examples/delimiters/Delimiters.php +++ b/test/fixtures/examples/delimiters/Delimiters.php @@ -2,15 +2,15 @@ class Delimiters { - public $start = "It worked the first time."; + public $start = 'It worked the first time.'; public function middle() { return array( - array('item' => "And it worked the second time."), - array('item' => "As well as the third."), + array('item' => 'And it worked the second time.'), + array('item' => 'As well as the third.'), ); } - public $final = "Then, surprisingly, it worked the final time."; + public $final = 'Then, surprisingly, it worked the final time.'; } diff --git a/test/fixtures/examples/double_section/DoubleSection.php b/test/fixtures/examples/double_section/DoubleSection.php index 8860181..f4e87a8 100644 --- a/test/fixtures/examples/double_section/DoubleSection.php +++ b/test/fixtures/examples/double_section/DoubleSection.php @@ -7,5 +7,5 @@ class DoubleSection return true; } - public $two = "second"; + public $two = 'second'; } diff --git a/test/fixtures/examples/section_iterator_objects/SectionIteratorObjects.php b/test/fixtures/examples/section_iterator_objects/SectionIteratorObjects.php index 3415ed5..9a50342 100644 --- a/test/fixtures/examples/section_iterator_objects/SectionIteratorObjects.php +++ b/test/fixtures/examples/section_iterator_objects/SectionIteratorObjects.php @@ -2,7 +2,7 @@ class SectionIteratorObjects { - public $start = "It worked the first time."; + public $start = 'It worked the first time.'; protected $_data = array( array('item' => 'And it worked the second time.'), @@ -14,5 +14,5 @@ class SectionIteratorObjects return new ArrayIterator($this->_data); } - public $final = "Then, surprisingly, it worked the final time."; + public $final = 'Then, surprisingly, it worked the final time.'; } diff --git a/test/fixtures/examples/section_magic_objects/SectionMagicObjects.php b/test/fixtures/examples/section_magic_objects/SectionMagicObjects.php index b67ed9e..e9f6645 100644 --- a/test/fixtures/examples/section_magic_objects/SectionMagicObjects.php +++ b/test/fixtures/examples/section_magic_objects/SectionMagicObjects.php @@ -2,14 +2,14 @@ class SectionMagicObjects { - public $start = "It worked the first time."; + public $start = 'It worked the first time.'; public function middle() { return new MagicObject(); } - public $final = "Then, surprisingly, it worked the final time."; + public $final = 'Then, surprisingly, it worked the final time.'; } class MagicObject diff --git a/test/fixtures/examples/section_objects/SectionObjects.php b/test/fixtures/examples/section_objects/SectionObjects.php index 4860834..0b6cc56 100644 --- a/test/fixtures/examples/section_objects/SectionObjects.php +++ b/test/fixtures/examples/section_objects/SectionObjects.php @@ -2,14 +2,14 @@ class SectionObjects { - public $start = "It worked the first time."; + public $start = 'It worked the first time.'; public function middle() { return new SectionObject(); } - public $final = "Then, surprisingly, it worked the final time."; + public $final = 'Then, surprisingly, it worked the final time.'; } class SectionObject diff --git a/test/fixtures/examples/sections/Sections.php b/test/fixtures/examples/sections/Sections.php index 37110ff..5e52485 100644 --- a/test/fixtures/examples/sections/Sections.php +++ b/test/fixtures/examples/sections/Sections.php @@ -2,15 +2,15 @@ class Sections { - public $start = "It worked the first time."; + public $start = 'It worked the first time.'; public function middle() { return array( - array('item' => "And it worked the second time."), - array('item' => "As well as the third."), + array('item' => 'And it worked the second time.'), + array('item' => 'As well as the third.'), ); } - public $final = "Then, surprisingly, it worked the final time."; + public $final = 'Then, surprisingly, it worked the final time.'; } diff --git a/test/fixtures/examples/simple/Simple.php b/test/fixtures/examples/simple/Simple.php index f097ff2..cfc746b 100644 --- a/test/fixtures/examples/simple/Simple.php +++ b/test/fixtures/examples/simple/Simple.php @@ -2,7 +2,7 @@ class Simple { - public $name = "Chris"; + public $name = 'Chris'; public $value = 10000; public function taxed_value() diff --git a/test/fixtures/examples/unescaped/Unescaped.php b/test/fixtures/examples/unescaped/Unescaped.php index 282ba21..f271aa0 100644 --- a/test/fixtures/examples/unescaped/Unescaped.php +++ b/test/fixtures/examples/unescaped/Unescaped.php @@ -2,5 +2,5 @@ class Unescaped { - public $title = "Bear > Shark"; + public $title = 'Bear > Shark'; } From 46facc76b5c4d928e0932c1d59d5c95f42f05adc Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Tue, 31 Mar 2015 23:37:28 -0700 Subject: [PATCH 31/31] Bump to v2.8.0 --- src/Mustache/Engine.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mustache/Engine.php b/src/Mustache/Engine.php index 339f8f5..d13f1cb 100644 --- a/src/Mustache/Engine.php +++ b/src/Mustache/Engine.php @@ -23,7 +23,7 @@ */ class Mustache_Engine { - const VERSION = '2.7.0'; + const VERSION = '2.8.0'; const SPEC_VERSION = '1.1.2'; const PRAGMA_FILTERS = 'FILTERS';