From 4353e7e2a41cbb5e853450ac57d47216b3dceab4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dariusz=20Rumi=C5=84ski?= Date: Wed, 14 May 2014 21:48:16 +0200 Subject: [PATCH 1/5] Correct indentation in Engine --- src/Mustache/Engine.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mustache/Engine.php b/src/Mustache/Engine.php index b395336..95aa5d6 100644 --- a/src/Mustache/Engine.php +++ b/src/Mustache/Engine.php @@ -213,7 +213,7 @@ class Mustache_Engine */ public function getEntityFlags() { - return $this->entityFlags; + return $this->entityFlags; } /** From 5ea8dc21e9412a5ee48c1f1b536d4b17a0d234ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dariusz=20Rumi=C5=84ski?= Date: Wed, 14 May 2014 21:49:53 +0200 Subject: [PATCH 2/5] Decrease indentation in HelperCollection constructor --- src/Mustache/HelperCollection.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Mustache/HelperCollection.php b/src/Mustache/HelperCollection.php index bbeb277..c7c7950 100644 --- a/src/Mustache/HelperCollection.php +++ b/src/Mustache/HelperCollection.php @@ -27,14 +27,16 @@ class Mustache_HelperCollection */ public function __construct($helpers = null) { - if ($helpers !== null) { - if (!is_array($helpers) && !$helpers instanceof Traversable) { - throw new Mustache_Exception_InvalidArgumentException('HelperCollection constructor expects an array of helpers'); - } + if ($helpers === null) { + return; + } - foreach ($helpers as $name => $helper) { - $this->add($name, $helper); - } + if (!is_array($helpers) && !$helpers instanceof Traversable) { + throw new Mustache_Exception_InvalidArgumentException('HelperCollection constructor expects an array of helpers'); + } + + foreach ($helpers as $name => $helper) { + $this->add($name, $helper); } } From 01d03d91df569abeb940fab0bfeac3f4d69f9f74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dariusz=20Rumi=C5=84ski?= Date: Wed, 14 May 2014 21:52:33 +0200 Subject: [PATCH 3/5] Strict comparison in Tokenizer --- src/Mustache/Tokenizer.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Mustache/Tokenizer.php b/src/Mustache/Tokenizer.php index 68ec5c1..bf1e5d1 100644 --- a/src/Mustache/Tokenizer.php +++ b/src/Mustache/Tokenizer.php @@ -116,7 +116,7 @@ class Mustache_Tokenizer } else { $char = $text[$i]; $this->buffer .= $char; - if ($char == "\n") { + if ($char === "\n") { $this->flushBuffer(); $this->line++; } @@ -157,14 +157,14 @@ 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 ); $this->buffer = ''; $i += $this->ctagLen - 1; $this->state = self::IN_TEXT; - if ($this->tagType == self::T_UNESCAPED) { - if ($this->ctag == '}}') { + if ($this->tagType === self::T_UNESCAPED) { + if ($this->ctag === '}}') { $i++; } else { // Clean up `{{{ tripleStache }}}` style tokens. From d2f89447982f2595a9534fb9192f44efeb7280ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dariusz=20Rumi=C5=84ski?= Date: Wed, 14 May 2014 21:58:28 +0200 Subject: [PATCH 4/5] Add few spaces around concatenations --- bin/build_bootstrap.php | 10 +++++----- test/bootstrap.php | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/bin/build_bootstrap.php b/bin/build_bootstrap.php index f9fa2af..258fd4d 100755 --- a/bin/build_bootstrap.php +++ b/bin/build_bootstrap.php @@ -20,13 +20,13 @@ * containing all Mustache library classes. This file can then be included in * your project, rather than requiring the Mustache Autoloader. */ -$baseDir = realpath(dirname(__FILE__).'/..'); +$baseDir = realpath(dirname(__FILE__) . '/..'); -require $baseDir.'/src/Mustache/Autoloader.php'; +require $baseDir . '/src/Mustache/Autoloader.php'; Mustache_Autoloader::register(); // delete the old file -$file = $baseDir.'/mustache.php'; +$file = $baseDir . '/mustache.php'; if (file_exists($file)) { unlink($file); } @@ -121,9 +121,9 @@ EOS; $content .= preg_replace(array('/^\s*<\?php/', '/\?>\s*$/'), '', file_get_contents($r->getFileName())); } - $cache = $cacheDir.'/'.$name.$extension; + $cache = $cacheDir . '/' . $name . $extension; $header = sprintf(self::HEADER, strftime('%Y')); - self::writeCacheFile($cache, $header . substr(self::stripComments(' Date: Wed, 14 May 2014 21:59:30 +0200 Subject: [PATCH 5/5] Apply PSR rules on bin directory --- bin/build_bootstrap.php | 8 ++++---- bin/create_example.php | 31 ++++++++++++++++++------------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/bin/build_bootstrap.php b/bin/build_bootstrap.php index 258fd4d..7863efc 100755 --- a/bin/build_bootstrap.php +++ b/bin/build_bootstrap.php @@ -77,7 +77,7 @@ SymfonyClassCollectionLoader::load(array( */ class SymfonyClassCollectionLoader { - static private $loaded; + private static $loaded; const HEADER = << 1) { +if (count($argv) > 1) { // get the name of the example $example_name = $argv[1];