diff --git a/src/Config.php b/src/Config.php index 269df9e1b9dab7db582873711b4f70f35b20c96a..f027e1a7609937eeb55ddbe1cb0d0c646220e731 100644 --- a/src/Config.php +++ b/src/Config.php @@ -1,11 +1,18 @@ <?php +/* + * This file is part of "irstea/php-cs-fixer-config". + * (c) 2018 Irstea <dsi.poleis@irstea.fr> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ namespace Irstea\CS; use PhpCsFixer\Config as PhpCsFixerConfig; /** - * Class Config + * Class Config. */ final class Config extends PhpCsFixerConfig { @@ -144,13 +151,14 @@ final class Config extends PhpCsFixerConfig function () { $last = date('Y'); $first = exec('git log --format=%cd --date=format:%Y --date-order | tail -n1') ?? $last; + return ($last !== null && $last !== $first) ? "$first-$last" : $first; } ); } /** - * @return boolean[] + * @return bool[] */ private function ruleSets() { @@ -216,7 +224,7 @@ final class Config extends PhpCsFixerConfig $commit = $this->getHeadCommit(); $cache = $this->loadCache(); if (!isset($cache[$commit][$key])) { - if (!isset($cache[$commit])) { + if (!isset($cache[$commit])) { // TODO: load a template from a local file. $cache[$commit] = []; } $cache[$commit][$key] = $generator(); @@ -234,6 +242,7 @@ final class Config extends PhpCsFixerConfig if ($this->commit === null) { $this->commit = trim(shell_exec('git rev-parse HEAD')); } + return $this->commit; } @@ -248,6 +257,7 @@ final class Config extends PhpCsFixerConfig $this->cache = json_decode(file_get_contents($this->cacheFile), true); } } + return $this->cache; } @@ -258,5 +268,4 @@ final class Config extends PhpCsFixerConfig { file_put_contents($this->cacheFile, json_encode($cache)); } - }