From 4caabb58adb05722bc2c289db06e834085eafd78 Mon Sep 17 00:00:00 2001
From: Demian Katz <demian.katz@villanova.edu>
Date: Wed, 25 Oct 2017 08:31:48 -0400
Subject: [PATCH] Smarter caching of php-cs-fixer results.

---
 .gitignore                    | 5 ++---
 .travis.yml                   | 1 +
 tests/vufind.php_cs           | 6 ++++++
 tests/vufind_templates.php_cs | 7 ++++++-
 4 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/.gitignore b/.gitignore
index 0d34b4b5dac..706d03393e2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,8 +3,7 @@
 ChangeLog
 \#*
 .\#*
-.php_cs.cache
-.php_cs_template.cache
+.php_cs_cache
 TAGS
 *~
 /downloads
@@ -14,4 +13,4 @@ composer.phar
 import/solrmarc.log
 node_modules
 public/swagger-ui
-.vagrant
\ No newline at end of file
+.vagrant
diff --git a/.travis.yml b/.travis.yml
index 857f8d33a7c..1006959fc58 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -17,6 +17,7 @@ before_script:
 cache:
   directories:
     - downloads
+    - .php_cs_cache
     - $HOME/.composer/cache/files
 
 script:
diff --git a/tests/vufind.php_cs b/tests/vufind.php_cs
index d154d57a69b..9784b030262 100644
--- a/tests/vufind.php_cs
+++ b/tests/vufind.php_cs
@@ -65,6 +65,12 @@ $rules = [
     'visibility_required' => true,
 ];
 
+$cacheDir = __DIR__ . '/../.php_cs_cache';
+if (!is_dir($cacheDir)) {
+    mkdir($cacheDir);
+}
+
 return PhpCsFixer\Config::create()
+    ->setCacheFile($cacheDir . '/.code.cache')
     ->setRules($rules)
     ->setFinder($finder);
diff --git a/tests/vufind_templates.php_cs b/tests/vufind_templates.php_cs
index 8cb5bd0b3e9..a4db59e5051 100644
--- a/tests/vufind_templates.php_cs
+++ b/tests/vufind_templates.php_cs
@@ -62,7 +62,12 @@ $rules = [
     'visibility_required' => true,
 ];
 
+$cacheDir = __DIR__ . '/../.php_cs_cache';
+if (!is_dir($cacheDir)) {
+    mkdir($cacheDir);
+}
+
 return PhpCsFixer\Config::create()
-    ->setCacheFile(__DIR__ . '/../.php_cs_template.cache')
+    ->setCacheFile($cacheDir . '/.template.cache')
     ->setRules($rules)
     ->setFinder($finder);
-- 
GitLab