Skip to content

Commit

Permalink
CS update
Browse files Browse the repository at this point in the history
  • Loading branch information
keradus committed Mar 28, 2015
1 parent 22611a9 commit 47eb13c
Show file tree
Hide file tree
Showing 28 changed files with 80 additions and 85 deletions.
5 changes: 0 additions & 5 deletions .php_cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
16 changes: 8 additions & 8 deletions bin/create_example.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
*/
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));
Expand All @@ -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));
Expand Down Expand Up @@ -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 : ''));
}

/**
Expand Down Expand Up @@ -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);
Expand All @@ -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} {
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/" }
Expand Down
2 changes: 1 addition & 1 deletion src/Mustache/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
6 changes: 3 additions & 3 deletions src/Mustache/Cache/AbstractCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ public function setLogger($logger = null)
/**
* 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())
{
Expand Down
2 changes: 1 addition & 1 deletion src/Mustache/Cache/FilesystemCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function __construct($baseDir, $fileMode = null)
*
* @param string $key
*
* @return boolean
* @return bool
*/
public function load($key)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Mustache/Cache/NoopCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Mustache_Cache_NoopCache extends Mustache_Cache_AbstractCache
*
* @param string $key
*
* @return boolean
* @return bool
*/
public function load($key)
{
Expand Down
14 changes: 7 additions & 7 deletions src/Mustache/Compiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ private function parent($id, $indent, array $children, $level)
*
* @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)
{
Expand All @@ -474,7 +474,7 @@ private static function onlyBlockArgs(array $node)
*
* @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
Expand Down Expand Up @@ -543,10 +543,10 @@ private function text($text, $level)
/**
* 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
*/
Expand All @@ -560,7 +560,7 @@ private function prepare($text, $bonus = 0, $prependNewline = true, $appendNewli
$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)';
Expand Down
8 changes: 4 additions & 4 deletions src/Mustache/Engine.php
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ public function getHelper($name)
*
* @param string $name
*
* @return boolean True if the helper is present
* @return bool True if the helper is present
*/
public function hasHelper($name)
{
Expand Down Expand Up @@ -772,9 +772,9 @@ private function compile($source)
/**
* 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())
{
Expand Down
6 changes: 3 additions & 3 deletions src/Mustache/HelperCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function get($name)
*
* @param string $name
*
* @return boolean True if helper is present
* @return bool True if helper is present
*/
public function __isset($name)
{
Expand All @@ -115,7 +115,7 @@ public function __isset($name)
*
* @param string $name
*
* @return boolean True if helper is present
* @return bool True if helper is present
*/
public function has($name)
{
Expand Down Expand Up @@ -163,7 +163,7 @@ public function clear()
/**
* 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()
{
Expand Down
20 changes: 10 additions & 10 deletions src/Mustache/Logger/StreamLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -67,7 +67,7 @@ public function __destruct()
*
* @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)
{
Expand All @@ -81,7 +81,7 @@ public function setLevel($level)
/**
* Get the current minimum logging level.
*
* @return integer
* @return int
*/
public function getLevel()
{
Expand Down Expand Up @@ -114,9 +114,9 @@ public function log($level, $message, array $context = array())
* @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())
{
Expand All @@ -141,7 +141,7 @@ protected function writeLog($level, $message, array $context = array())
*
* @throws InvalidArgumentException if the logging level is unknown.
*
* @param integer $level
* @param int $level
*
* @return string
*/
Expand All @@ -153,9 +153,9 @@ protected static function getLevelName($level)
/**
* 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
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Mustache/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ private function clearStandaloneLines(array &$nodes, array &$tokens)
*
* @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)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Mustache/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ abstract class Mustache_Template
protected $mustache;

/**
* @var boolean
* @var bool
*/
protected $strictCallables = false;

Expand Down Expand Up @@ -109,7 +109,7 @@ abstract public function renderInternal(Mustache_Context $context, $indent = '')
*
* @param mixed $value
*
* @return boolean True if the value is 'iterable'
* @return bool True if the value is 'iterable'
*/
protected function isIterable($value)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Mustache/Tokenizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ private function addPragma($text, $index)
* @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)
{
Expand Down
2 changes: 1 addition & 1 deletion test/Mustache/Test/EngineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ public function testVerboseLoggingIsVerbose()
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);
}

Expand Down
2 changes: 1 addition & 1 deletion test/Mustache/Test/FiveThree/Functional/EngineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function pragmaData()

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, ''),
);
}
}
4 changes: 2 additions & 2 deletions test/Mustache/Test/FiveThree/Functional/FiltersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function singleFilterData()
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',
),

Expand All @@ -72,7 +72,7 @@ public function testChainedFilters()
});

$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));
}
Expand Down
4 changes: 2 additions & 2 deletions test/Mustache/Test/Logger/StreamLoggerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ public function testLoggingThresholds($logLevel, $level, $shouldLog)
{
$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);
}
Expand Down
2 changes: 1 addition & 1 deletion test/Mustache/Test/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public function getTokenSets()
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,
Expand Down
Loading

0 comments on commit 47eb13c

Please sign in to comment.