From 47eb13cb2656780cb7084d543d323cc6f54048e0 Mon Sep 17 00:00:00 2001 From: Dariusz Ruminski Date: Sat, 28 Mar 2015 17:54:07 +0100 Subject: [PATCH] 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'; }