Browse Source

DevKit updates (#3910)

Sonata CI 9 years ago
parent
commit
70386709be
1 changed files with 14 additions and 3 deletions
  1. 14 3
      .php_cs

+ 14 - 3
.php_cs

@@ -11,7 +11,6 @@
 require_once __DIR__.'/vendor/sllh/php-cs-fixer-styleci-bridge/autoload.php';
 
 use SLLH\StyleCIBridge\ConfigBridge;
-use Symfony\CS\Fixer\Contrib\HeaderCommentFixer;
 
 $header = <<<EOF
 This file is part of the Sonata Project package.
@@ -22,8 +21,20 @@ For the full copyright and license information, please view the LICENSE
 file that was distributed with this source code.
 EOF;
 
-HeaderCommentFixer::setHeader($header);
+// PHP-CS-Fixer 1.x
+if (class_exists('Symfony\CS\Fixer\Contrib\HeaderCommentFixer')) {
+    \Symfony\CS\Fixer\Contrib\HeaderCommentFixer::setHeader($header);
+}
 
-return ConfigBridge::create()
+$config = ConfigBridge::create()
     ->setUsingCache(true)
 ;
+
+// PHP-CS-Fixer 2.x
+if (method_exists($config, 'setRules')) {
+    $config->setRules(array_merge($config->getRules(), array(
+        'header_comment' => array('header' => $header)
+    )));
+}
+
+return $config;