Skip to content

Commit

Permalink
Merge branch 'release/2.8.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
bobthecow committed Apr 1, 2015
2 parents fdf41dd + 46facc7 commit 64c28cc
Show file tree
Hide file tree
Showing 59 changed files with 424 additions and 419 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.php_cs.cache
composer.lock
vendor
mustache.php
vendor
13 changes: 11 additions & 2 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
<?php

$config = new Symfony\CS\Config\Config();
$config->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;
10 changes: 10 additions & 0 deletions .styleci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
preset: symfony

enabled:
- align_double_arrow
- concat_with_spaces
- ordered_use
- strict

disabled:
- concat_without_spaces
14 changes: 11 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -14,3 +14,11 @@ php:
- 5.5
- 5.6
- hhvm
- hhvm-nightly

sudo: false

matrix:
allow_failures:
- php: hhvm-nightly
fast_finish: true
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}}
```

Expand Down
3 changes: 1 addition & 2 deletions bin/build_bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

/**
* A shell script to create a single-file class cache of the entire Mustache
* library:
* library.
*
* $ bin/build_bootstrap.php
*
Expand Down Expand Up @@ -72,7 +72,6 @@
* the unnecessary bits removed.
*
* @license http://www.opensource.org/licenses/MIT
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class SymfonyClassCollectionLoader
Expand Down
51 changes: 28 additions & 23 deletions bin/create_example.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<?php

/**
* A commandline script to create an example and the needed files:
* A commandline script to create an example and the needed files.
*
* $ bin/create_example.php my_new_example
*
Expand All @@ -26,6 +26,7 @@

/**
* transform a string to lowercase using underlines.
*
* Examples:
* String -> string
* AString -> a_string
Expand All @@ -34,18 +35,20 @@
*
* @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
Expand All @@ -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)
Expand All @@ -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)
{
Expand All @@ -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);
Expand All @@ -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
Expand All @@ -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", <<<CONTENT
createFile($lowercase, $lowercase, 'mustache');
createFile($lowercase, $lowercase, 'txt');
createFile($lowercase, $uppercase, 'php', <<<CONTENT
<?php
class {$uppercase} {
Expand All @@ -170,7 +176,6 @@ class {$uppercase} {
$example_name = $argv[1];

main($example_name);

} else {
echo USAGE;
}
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/" }
Expand Down
2 changes: 1 addition & 1 deletion src/Mustache/Autoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions 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 All @@ -31,8 +31,6 @@ public function load($key);
*
* @param string $key
* @param string $value
*
* @return void
*/
public function cache($key, $value);
}
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
12 changes: 4 additions & 8 deletions 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 All @@ -56,12 +56,10 @@ public function load($key)
}

/**
* 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)
{
Expand Down Expand Up @@ -91,7 +89,7 @@ protected function getCacheFilename($name)
}

/**
* Create cache directory
* Create cache directory.
*
* @throws Mustache_Exception_RuntimeException If unable to create directory
*
Expand Down Expand Up @@ -119,14 +117,12 @@ private function buildDirectoryForFilename($fileName)
}

/**
* 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)
{
Expand Down
4 changes: 1 addition & 3 deletions 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 All @@ -34,8 +34,6 @@ public function load($key)
*
* @param string $key
* @param string $value
*
* @return void
*/
public function cache($key, $value)
{
Expand Down
Loading

0 comments on commit 64c28cc

Please sign in to comment.