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 0965a1b..8ea84c3 100644 --- a/.php_cs +++ b/.php_cs @@ -1,6 +1,15 @@ getFinder()->in(__DIR__)->exclude('bin'); +use Symfony\CS\Config\Config; +use Symfony\CS\FixerInterface; + +$config = Config::create() + // use symfony level and extra fixers: + ->level(Symfony\CS\FixerInterface::SYMFONY_LEVEL) + ->fixers(array('align_double_arrow', '-concat_without_spaces', 'concat_with_spaces', 'ordered_use', 'strict')) + ->setUsingLinter(false); + +$finder = $config->getFinder() + ->in(__DIR__); return $config; 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/.travis.yml b/.travis.yml index fa13c65..4c894ed 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,11 @@ language: php -before_script: - - curl http://cs.sensiolabs.org/get/php-cs-fixer.phar -o php-cs-fixer.phar +install: + - curl http://get.sensiolabs.org/php-cs-fixer.phar -o php-cs-fixer.phar 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', '>=') && !defined('HHVM_VERSION');"` ]]; then php php-cs-fixer.phar --diff --dry-run -vv fix; fi php: - 5.2 @@ -14,3 +14,11 @@ php: - 5.5 - 5.6 - hhvm + - hhvm-nightly + +sudo: false + +matrix: + allow_failures: + - php: hhvm-nightly + fast_finish: true diff --git a/README.md b/README.md index b33b355..6a309ae 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 @@ -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}} dollars! {{#in_ca}} -Well, ${{taxed_value}}, after taxes. +Well, {{taxed_value}} dollars, after taxes. {{/in_ca}} ``` 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 19edfde..cca36f3 100755 --- a/bin/create_example.php +++ b/bin/create_example.php @@ -2,7 +2,7 @@ string * AString -> a_string @@ -34,18 +35,20 @@ define('EXAMPLE_PATH', realpath(dirname(__FILE__) . '/../test/fixtures/examples' * * @param string $name * @access public + * * @return string */ 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)); } /** - * transform a string to Uppercase (camelcase) + * transform a string to Uppercase (camelcase). + * * Examples * string -> String * a_string -> AString @@ -54,21 +57,23 @@ function getLowerCaseName($name) * * @param string $name * @access public + * * @return string */ 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)); } /** - * 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,30 +84,32 @@ 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) { - return out(EXAMPLE_PATH . '/' . $directory. - ($extension !== null && $filename !== null ? '/' . $filename. "." . $extension : "")); + return out(EXAMPLE_PATH . '/' . $directory . + ($extension !== null && $filename !== null ? '/' . $filename . '.' . $extension : '')); } /** - * 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 - * @return void */ function createDirectory($directory) { @@ -112,19 +119,19 @@ 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 * @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 = "") +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); @@ -134,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 @@ -144,16 +151,15 @@ function createFile($directory, $filename, $extension, $content = "") * * @param mixed $example_name * @access public - * @return void */ 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", << 1) { $example_name = $argv[1]; main($example_name); - } else { echo USAGE; } diff --git a/composer.json b/composer.json index 2969d03..388a940 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.6" }, "autoload": { "psr-0": { "Mustache": "src/" } 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/Cache.php b/src/Mustache/Cache.php index c8fc5d5..45c4e7e 100644 --- a/src/Mustache/Cache.php +++ b/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); @@ -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/AbstractCache.php b/src/Mustache/Cache/AbstractCache.php index 98b6451..eb157c7 100644 --- a/src/Mustache/Cache/AbstractCache.php +++ b/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()) { diff --git a/src/Mustache/Cache/FilesystemCache.php b/src/Mustache/Cache/FilesystemCache.php index 120ad2d..15bcb87 100644 --- a/src/Mustache/Cache/FilesystemCache.php +++ b/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) { @@ -56,12 +56,10 @@ 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 - * - * @return void */ public function cache($key, $value) { @@ -91,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 * @@ -119,14 +117,12 @@ class Mustache_Cache_FilesystemCache extends Mustache_Cache_AbstractCache } /** - * Write cache file + * Write cache file. * * @throws Mustache_Exception_RuntimeException If unable to write file * * @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..66787c7 100644 --- a/src/Mustache/Cache/NoopCache.php +++ b/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) { @@ -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/Compiler.php b/src/Mustache/Compiler.php index 72d3414..e25bd8c 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; @@ -264,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; '; @@ -342,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)); @@ -458,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) { @@ -475,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 @@ -544,16 +543,16 @@ 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 */ private function prepare($text, $bonus = 0, $prependNewline = true, $appendNewline = false) { - $text = ($prependNewline ? "\n" : '').trim($text); + $text = ($prependNewline ? "\n" : '') . trim($text); if ($prependNewline) { $bonus++; } @@ -561,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/Engine.php b/src/Mustache/Engine.php index 4cac394..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'; @@ -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'])) { @@ -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()) { diff --git a/src/Mustache/HelperCollection.php b/src/Mustache/HelperCollection.php index c7c7950..00a9b01 100644 --- a/src/Mustache/HelperCollection.php +++ b/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() { 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 9e4ab42..b1ed9ec 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 { @@ -56,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/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..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'; @@ -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()); } diff --git a/src/Mustache/Logger/StreamLogger.php b/src/Mustache/Logger/StreamLogger.php index d422340..7db52d6 100644 --- a/src/Mustache/Logger/StreamLogger.php +++ b/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 */ diff --git a/src/Mustache/Parser.php b/src/Mustache/Parser.php index 0c134ec..c60f5db 100644 --- a/src/Mustache/Parser.php +++ b/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) { diff --git a/src/Mustache/Template.php b/src/Mustache/Template.php index e7156cf..0648e2c 100644 --- a/src/Mustache/Template.php +++ b/src/Mustache/Template.php @@ -22,7 +22,7 @@ abstract class Mustache_Template protected $mustache; /** - * @var boolean + * @var bool */ protected $strictCallables = false; @@ -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 }}!'); @@ -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) { diff --git a/src/Mustache/Tokenizer.php b/src/Mustache/Tokenizer.php index 3175a03..dfbaa8a 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'; @@ -75,7 +68,6 @@ class Mustache_Tokenizer private $state; private $tagType; - private $tag; private $buffer; private $tokens; private $seenTag; @@ -163,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) { @@ -224,7 +216,6 @@ class Mustache_Tokenizer { $this->state = self::IN_TEXT; $this->tagType = null; - $this->tag = null; $this->buffer = ''; $this->tokens = array(); $this->seenTag = false; @@ -244,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 = ''; } @@ -261,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))); @@ -322,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) { 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/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..ce0eee6 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 */ @@ -48,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, @@ -59,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( @@ -68,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, @@ -77,9 +76,9 @@ 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;', - ) + ), ), array( @@ -88,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, @@ -97,9 +96,9 @@ 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;', - ) + ), ), array( @@ -124,11 +123,11 @@ 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/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 f61f876..c4c8890 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, )); @@ -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())); @@ -237,7 +237,7 @@ class Mustache_Test_EngineTest extends Mustache_Test_FunctionalTestCase public static function wrapWithUnderscores($text) { - return '__'.$text.'__'; + return '__' . $text . '__'; } /** @@ -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); } @@ -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..3bc43ca 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( @@ -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 4cbe049..9fee396 100644 --- a/test/Mustache/Test/FiveThree/Functional/FiltersTest.php +++ b/test/Mustache/Test/FiveThree/Functional/FiltersTest.php @@ -46,15 +46,15 @@ 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"))), - '2000-01-01 12:01:00' + (object) array('date' => new DateTime('1/1/2000', new DateTimeZone('UTC'))), + '2000-01-01 12:01:00', ), array( '{{% FILTERS }}{{# word | echo }}{{ . }}!{{/ word | echo }}', $helpers, array('word' => 'bacon'), - 'bacon!bacon!bacon!' + 'bacon!bacon!bacon!', ), ); } @@ -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/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/MustacheSpecTest.php b/test/Mustache/Test/FiveThree/Functional/MustacheSpecTest.php index 88094fb..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 @@ -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/FiveThree/Functional/PartialLambdaIndentTest.php b/test/Mustache/Test/FiveThree/Functional/PartialLambdaIndentTest.php index 04fd56d..98fc8c0 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 = << array('input' => $partial) + 'partials' => array('input' => $partial), )); $tpl = $m->loadTemplate($src); diff --git a/test/Mustache/Test/Functional/CallTest.php b/test/Mustache/Test/Functional/CallTest.php index e66cc52..34798cd 100644 --- a/test/Mustache/Test/Functional/CallTest.php +++ b/test/Mustache/Test/Functional/CallTest.php @@ -15,7 +15,6 @@ */ class Mustache_Test_Functional_CallTest extends PHPUnit_Framework_TestCase { - public function testCallEatsContext() { $m = new Mustache_Engine(); diff --git a/test/Mustache/Test/Functional/ExamplesTest.php b/test/Mustache/Test/Functional/ExamplesTest.php index ffb8361..dcf1fe4 100644 --- a/test/Mustache/Test/Functional/ExamplesTest.php +++ b/test/Mustache/Test/Functional/ExamplesTest.php @@ -15,7 +15,6 @@ */ class Mustache_Test_Functional_ExamplesTest extends PHPUnit_Framework_TestCase { - /** * Test everything in the `examples` directory. * @@ -29,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)); } @@ -47,16 +46,16 @@ 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); while (($file = readdir($handle)) !== false) { - if ($file == '.' || $file == '..') { + if ($file === '.' || $file === '..') { continue; } - $fullpath = $path.'/'.$file; + $fullpath = $path . '/' . $file; if (is_dir($fullpath)) { $examples[$file] = $this->loadExample($fullpath); } @@ -82,10 +81,10 @@ 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') { + if (is_dir($fullpath) && $info['basename'] === 'partials') { // load partials $partials = $this->loadPartials($fullpath); } elseif (is_file($fullpath)) { @@ -125,11 +124,11 @@ class Mustache_Test_Functional_ExamplesTest extends PHPUnit_Framework_TestCase $handle = opendir($path); while (($file = readdir($handle)) !== false) { - if ($file == '.' || $file == '..') { + if ($file === '.' || $file === '..') { continue; } - $fullpath = $path.'/'.$file; + $fullpath = $path . '/' . $file; $info = pathinfo($fullpath); if ($info['extension'] === 'mustache') { diff --git a/test/Mustache/Test/Functional/InheritanceTest.php b/test/Mustache/Test/Functional/InheritanceTest.php index dd524a5..122ed31 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; @@ -24,13 +23,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 +38,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 +62,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 +112,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 +125,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,11 +139,10 @@ 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)); - } public function testMustacheInjectionInDefaultContent() @@ -154,7 +152,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)); @@ -163,7 +161,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); @@ -180,7 +178,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); @@ -197,7 +195,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); @@ -214,7 +212,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); @@ -224,7 +222,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)); @@ -233,7 +231,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); @@ -243,7 +241,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,8 +249,8 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas public function testOverridePartialWithNewlines() { - $partials = array( - 'partial' => '{{$ballmer}}peaking{{/ballmer}}' + $partials = array( + 'partial' => '{{$ballmer}}peaking{{/ballmer}}', ); $this->mustache->setPartials($partials); @@ -269,9 +267,8 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas public function testInheritIndentationWhenOverridingAPartial() { $partials = array( - 'partial' => - 'stop: - {{$nineties}}collaborate and listen{{/nineties}}' + 'partial' => 'stop: + {{$nineties}}collaborate and listen{{/nineties}}', ); $this->mustache->setPartials($partials); @@ -289,10 +286,33 @@ 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( - 'partial' => '{{$stuff}}default one{{/stuff}}, {{$stuff2}}default two{{/stuff2}}' + 'partial' => '{{$stuff}}default one{{/stuff}}, {{$stuff2}}default two{{/stuff2}}', ); $this->mustache->setPartials($partials); @@ -309,7 +329,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,8 +346,8 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas public function testRecursionInInheritedTemplates() { $partials = array( - 'include' => '{{$foo}}default content{{/foo}} {{$bar}}{{ '{{$foo}}include2 default content{{/foo}} {{ '{{$foo}}default content{{/foo}} {{$bar}}{{ '{{$foo}}include2 default content{{/foo}} {{mustache->setPartials($partials); @@ -344,9 +364,9 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas public function testTopLevelSubstitutionsTakePrecedenceInMultilevelInheritance() { $partials = array( - 'parent' => '{{ '{{ '{{$a}}g{{/a}}' + 'parent' => '{{ '{{ '{{$a}}g{{/a}}', ); $this->mustache->setPartials($partials); @@ -363,9 +383,9 @@ class Mustache_Test_Functional_InheritanceTest extends PHPUnit_Framework_TestCas public function testMultiLevelInheritanceNoSubChild() { $partials = array( - 'parent' => '{{ '{{ '{{$a}}g{{/a}}' + 'parent' => '{{ '{{ '{{$a}}g{{/a}}', ); $this->mustache->setPartials($partials); @@ -382,7 +402,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); @@ -399,7 +419,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 54de502..d97335e 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() @@ -36,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/MustacheSpecTest.php b/test/Mustache/Test/Functional/MustacheSpecTest.php index 96fcf40..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 @@ -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/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/FunctionalTestCase.php b/test/Mustache/Test/FunctionalTestCase.php index 4d243e0..34647fc 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 == '..') { + 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/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/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'); diff --git a/test/Mustache/Test/Logger/StreamLoggerTest.php b/test/Mustache/Test/Logger/StreamLoggerTest.php index e64c481..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); } @@ -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 eccfc3d..77c6fae 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 */ @@ -29,7 +28,7 @@ class Mustache_Test_ParserTest extends PHPUnit_Framework_TestCase return array( array( array(), - array() + array(), ), array( @@ -49,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', )), ), @@ -63,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', ), ), @@ -93,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, @@ -105,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', ), ), ), @@ -129,9 +128,9 @@ 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::VALUE => 'bar' + Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT, + Mustache_Tokenizer::LINE => 0, + Mustache_Tokenizer::VALUE => 'bar', ), ), array( @@ -143,9 +142,9 @@ 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::VALUE => 'bar' + Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT, + Mustache_Tokenizer::LINE => 0, + Mustache_Tokenizer::VALUE => 'bar', ), ), ), @@ -153,17 +152,17 @@ class Mustache_Test_ParserTest extends PHPUnit_Framework_TestCase array( array( array( - Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT, - Mustache_Tokenizer::LINE => 0, - Mustache_Tokenizer::VALUE => " ", + Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT, + Mustache_Tokenizer::LINE => 0, + Mustache_Tokenizer::VALUE => ' ', ), array( Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_DELIM_CHANGE, 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( @@ -204,72 +203,72 @@ 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::INDEX => 8 + 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::INDEX => 16 + 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::VALUE => 'baz' + 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::INDEX => 19 + 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::INDEX => 27 - ) + 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::VALUE => 'baz' - ) - ) - ) - ) - ) - ) + Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT, + Mustache_Tokenizer::LINE => 0, + Mustache_Tokenizer::VALUE => 'baz', + ), + ), + ), + ), + ), + ), ), array( @@ -282,36 +281,36 @@ 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::VALUE => 'bar' + 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::VALUE => 'bar' - ) - ) - ) - ) + Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_TEXT, + Mustache_Tokenizer::LINE => 0, + Mustache_Tokenizer::VALUE => 'bar', + ), + ), + ), + ), ), ); } @@ -407,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::VALUE => 'bar' + 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 e5eeb72..c9fb5b9 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 */ @@ -31,7 +30,7 @@ class Mustache_Test_TokenizerTest extends PHPUnit_Framework_TestCase { $tokenizer = new Mustache_Tokenizer(); - $text = "{{{ name }}"; + $text = '{{{ name }}'; $tokenizer->scan($text, null); } @@ -42,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() @@ -84,8 +83,8 @@ class Mustache_Test_TokenizerTest extends PHPUnit_Framework_TestCase Mustache_Tokenizer::CTAG => '}}', Mustache_Tokenizer::LINE => 0, Mustache_Tokenizer::INDEX => 10, - ) - ) + ), + ), ), array( @@ -111,8 +110,8 @@ class Mustache_Test_TokenizerTest extends PHPUnit_Framework_TestCase Mustache_Tokenizer::CTAG => '>>>', Mustache_Tokenizer::LINE => 0, Mustache_Tokenizer::INDEX => 12, - ) - ) + ), + ), ), array( @@ -179,12 +178,12 @@ class Mustache_Test_TokenizerTest extends PHPUnit_Framework_TestCase Mustache_Tokenizer::INDEX => 51, ), - ) + ), ), // See https://github.com/bobthecow/mustache.php/issues/183 array( - "{{# a }}0{{/ a }}", + '{{# a }}0{{/ a }}', null, array( array( @@ -198,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, @@ -208,13 +207,13 @@ 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 array( - "<% a %>} <% b %>%> <% c %>}}}", - "<% %>", + '<% a %>} <% b %>%> <% c %>}}}', + '<% %>', array( array( Mustache_Tokenizer::TYPE => Mustache_Tokenizer::T_ESCAPED, @@ -227,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, @@ -240,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, @@ -253,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, @@ -270,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 @@ -280,17 +279,17 @@ 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::INDEX => 8 + 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( 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, @@ -299,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/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/dot_notation/DotNotation.php b/test/fixtures/examples/dot_notation/DotNotation.php index d2939f1..7edbc00 100644 --- a/test/fixtures/examples/dot_notation/DotNotation.php +++ b/test/fixtures/examples/dot_notation/DotNotation.php @@ -3,12 +3,12 @@ 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', - ) + ), ); public $normal = 'Normal'; 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/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/i18n/I18n.php b/test/fixtures/examples/i18n/I18n.php index 7b7cd9f..8508a59 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'; @@ -11,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/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_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 2d9b464..e9f6645 100644 --- a/test/fixtures/examples/section_magic_objects/SectionMagicObjects.php +++ b/test/fixtures/examples/section_magic_objects/SectionMagicObjects.php @@ -2,21 +2,21 @@ 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 { 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/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/sections_nested/SectionsNested.php b/test/fixtures/examples/sections_nested/SectionsNested.php index 9360505..23dac63 100644 --- a/test/fixtures/examples/sections_nested/SectionsNested.php +++ b/test/fixtures/examples/sections_nested/SectionsNested.php @@ -8,27 +8,27 @@ class SectionsNested { return array( array( - 'name' => 'Von Kaiser', + 'name' => 'Von Kaiser', 'enemies' => array( array('name' => 'Super Macho Man'), array('name' => 'Piston Honda'), array('name' => 'Mr. Sandman'), - ) + ), ), array( - 'name' => 'Mike Tyson', + 'name' => 'Mike Tyson', 'enemies' => array( array('name' => 'Soda Popinski'), array('name' => 'King Hippo'), array('name' => 'Great Tiger'), array('name' => 'Glass Joe'), - ) + ), ), array( - 'name' => 'Don Flamenco', + 'name' => 'Don Flamenco', 'enemies' => array( array('name' => 'Bald Bull'), - ) + ), ), ); } 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'; }