Prechádzať zdrojové kódy

Merge pull request #256 from keradus/cs

CS update
Justin Hileman 10 rokov pred
rodič
commit
7b57d9b1d2

+ 0 - 5
.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;

+ 8 - 8
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", <<<CONTENT
+    createFile($lowercase, $lowercase, 'mustache');
+    createFile($lowercase, $lowercase, 'txt');
+    createFile($lowercase, $uppercase, 'php', <<<CONTENT
 <?php
 
 class {$uppercase} {

+ 1 - 1
composer.json

@@ -17,7 +17,7 @@
     },
     "require-dev": {
         "phpunit/phpunit": "~3.7|~4.0",
-        "fabpot/php-cs-fixer": "~1.3"
+        "fabpot/php-cs-fixer": "~1.6"
     },
     "autoload": {
         "psr-0": { "Mustache": "src/" }

+ 1 - 1
src/Mustache/Cache.php

@@ -22,7 +22,7 @@ interface Mustache_Cache
      *
      * @param string $key
      *
-     * @return boolean indicates successfully class load
+     * @return bool indicates successfully class load
      */
     public function load($key);
 

+ 3 - 3
src/Mustache/Cache/AbstractCache.php

@@ -47,9 +47,9 @@ abstract class Mustache_Cache_AbstractCache implements Mustache_Cache
     /**
      * Add a log record if logging is enabled.
      *
-     * @param integer $level   The logging level
-     * @param string  $message The log message
-     * @param array   $context The log context
+     * @param int    $level   The logging level
+     * @param string $message The log message
+     * @param array  $context The log context
      */
     protected function log($level, $message, array $context = array())
     {

+ 1 - 1
src/Mustache/Cache/FilesystemCache.php

@@ -41,7 +41,7 @@ class Mustache_Cache_FilesystemCache extends Mustache_Cache_AbstractCache
      *
      * @param string $key
      *
-     * @return boolean
+     * @return bool
      */
     public function load($key)
     {

+ 1 - 1
src/Mustache/Cache/NoopCache.php

@@ -22,7 +22,7 @@ class Mustache_Cache_NoopCache extends Mustache_Cache_AbstractCache
      *
      * @param string $key
      *
-     * @return boolean
+     * @return bool
      */
     public function load($key)
     {

+ 7 - 7
src/Mustache/Compiler.php

@@ -457,7 +457,7 @@ class Mustache_Compiler
      *
      * @param array $node
      *
-     * @return boolean True if $node is a block arg token.
+     * @return bool True if $node is a block arg token.
      */
     private static function onlyBlockArgs(array $node)
     {
@@ -474,7 +474,7 @@ class Mustache_Compiler
      *
      * @param string   $id      Variable name
      * @param string[] $filters Array of filters
-     * @param boolean  $escape  Escape the variable value for output?
+     * @param bool     $escape  Escape the variable value for output?
      * @param int      $level
      *
      * @return string Generated variable interpolation PHP source
@@ -543,10 +543,10 @@ class Mustache_Compiler
     /**
      * Prepare PHP source code snippet for output.
      *
-     * @param string  $text
-     * @param int     $bonus          Additional indent level (default: 0)
-     * @param boolean $prependNewline Prepend a newline to the snippet? (default: true)
-     * @param boolean $appendNewline  Append a newline to the snippet? (default: false)
+     * @param string $text
+     * @param int    $bonus          Additional indent level (default: 0)
+     * @param bool   $prependNewline Prepend a newline to the snippet? (default: true)
+     * @param bool   $appendNewline  Append a newline to the snippet? (default: false)
      *
      * @return string PHP source code snippet
      */
@@ -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)';

+ 4 - 4
src/Mustache/Engine.php

@@ -405,7 +405,7 @@ class Mustache_Engine
      *
      * @param string $name
      *
-     * @return boolean True if the helper is present
+     * @return bool True if the helper is present
      */
     public function hasHelper($name)
     {
@@ -772,9 +772,9 @@ class Mustache_Engine
     /**
      * Add a log record if logging is enabled.
      *
-     * @param integer $level   The logging level
-     * @param string  $message The log message
-     * @param array   $context The log context
+     * @param int    $level   The logging level
+     * @param string $message The log message
+     * @param array  $context The log context
      */
     private function log($level, $message, array $context = array())
     {

+ 3 - 3
src/Mustache/HelperCollection.php

@@ -103,7 +103,7 @@ class Mustache_HelperCollection
      *
      * @param string $name
      *
-     * @return boolean True if helper is present
+     * @return bool True if helper is present
      */
     public function __isset($name)
     {
@@ -115,7 +115,7 @@ class Mustache_HelperCollection
      *
      * @param string $name
      *
-     * @return boolean True if helper is present
+     * @return bool True if helper is present
      */
     public function has($name)
     {
@@ -163,7 +163,7 @@ class Mustache_HelperCollection
     /**
      * Check whether the helper collection is empty.
      *
-     * @return boolean True if the collection is empty
+     * @return bool True if the collection is empty
      */
     public function isEmpty()
     {

+ 10 - 10
src/Mustache/Logger/StreamLogger.php

@@ -39,7 +39,7 @@ class Mustache_Logger_StreamLogger extends Mustache_Logger_AbstractLogger
      * @throws InvalidArgumentException if the logging level is unknown.
      *
      * @param resource|string $stream Resource instance or URL
-     * @param integer         $level  The minimum logging level at which this handler will be triggered
+     * @param int             $level  The minimum logging level at which this handler will be triggered
      */
     public function __construct($stream, $level = Mustache_Logger::ERROR)
     {
@@ -67,7 +67,7 @@ class Mustache_Logger_StreamLogger extends Mustache_Logger_AbstractLogger
      *
      * @throws Mustache_Exception_InvalidArgumentException if the logging level is unknown.
      *
-     * @param integer $level The minimum logging level which will be written
+     * @param int $level The minimum logging level which will be written
      */
     public function setLevel($level)
     {
@@ -81,7 +81,7 @@ class Mustache_Logger_StreamLogger extends Mustache_Logger_AbstractLogger
     /**
      * Get the current minimum logging level.
      *
-     * @return integer
+     * @return int
      */
     public function getLevel()
     {
@@ -114,9 +114,9 @@ class Mustache_Logger_StreamLogger extends Mustache_Logger_AbstractLogger
      * @throws Mustache_Exception_LogicException   If neither a stream resource nor url is present.
      * @throws Mustache_Exception_RuntimeException If the stream url cannot be opened.
      *
-     * @param integer $level   The logging level
-     * @param string  $message The log message
-     * @param array   $context The log context
+     * @param int    $level   The logging level
+     * @param string $message The log message
+     * @param array  $context The log context
      */
     protected function writeLog($level, $message, array $context = array())
     {
@@ -141,7 +141,7 @@ class Mustache_Logger_StreamLogger extends Mustache_Logger_AbstractLogger
      *
      * @throws InvalidArgumentException if the logging level is unknown.
      *
-     * @param integer $level
+     * @param int $level
      *
      * @return string
      */
@@ -153,9 +153,9 @@ class Mustache_Logger_StreamLogger extends Mustache_Logger_AbstractLogger
     /**
      * Format a log line for output.
      *
-     * @param integer $level   The logging level
-     * @param string  $message The log message
-     * @param array   $context The log context
+     * @param int    $level   The logging level
+     * @param string $message The log message
+     * @param array  $context The log context
      *
      * @return string
      */

+ 1 - 1
src/Mustache/Parser.php

@@ -254,7 +254,7 @@ class Mustache_Parser
      *
      * @param array $token
      *
-     * @return boolean True if token is a whitespace token
+     * @return bool True if token is a whitespace token
      */
     private function tokenIsWhitespace(array $token)
     {

+ 2 - 2
src/Mustache/Template.php

@@ -22,7 +22,7 @@ abstract class Mustache_Template
     protected $mustache;
 
     /**
-     * @var boolean
+     * @var bool
      */
     protected $strictCallables = false;
 
@@ -109,7 +109,7 @@ abstract class Mustache_Template
      *
      * @param mixed $value
      *
-     * @return boolean True if the value is 'iterable'
+     * @return bool True if the value is 'iterable'
      */
     protected function isIterable($value)
     {

+ 1 - 1
src/Mustache/Tokenizer.php

@@ -313,7 +313,7 @@ class Mustache_Tokenizer
      * @param string $text   Mustache template source
      * @param int    $index  Current tokenizer index
      *
-     * @return boolean True if this is a closing section tag
+     * @return bool True if this is a closing section tag
      */
     private function tagChange($tag, $tagLen, $text, $index)
     {

+ 1 - 1
test/Mustache/Test/EngineTest.php

@@ -317,7 +317,7 @@ class Mustache_Test_EngineTest extends Mustache_Test_FunctionalTestCase
         list($name, $mustache) = $this->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);
     }
 

+ 1 - 1
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, ''),
         );
     }
 }

+ 2 - 2
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));
     }

+ 2 - 2
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);
         }

+ 1 - 1
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,

+ 13 - 13
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,

+ 4 - 4
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.';
 }

+ 1 - 1
test/fixtures/examples/double_section/DoubleSection.php

@@ -7,5 +7,5 @@ class DoubleSection
         return true;
     }
 
-    public $two = "second";
+    public $two = 'second';
 }

+ 2 - 2
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.';
 }

+ 2 - 2
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

+ 2 - 2
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

+ 4 - 4
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.';
 }

+ 1 - 1
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()

+ 1 - 1
test/fixtures/examples/unescaped/Unescaped.php

@@ -2,5 +2,5 @@
 
 class Unescaped
 {
-    public $title = "Bear > Shark";
+    public $title = 'Bear > Shark';
 }