11<?php
22/**
3- * Yii2 PHP CS Fixer Config - Config.
3+ * Yii2 PHP CS Fixer Config
44 *
55 * @author Kacper Pruszynski (plumthedev)
6- * @version 1.0.0
6+ * @link https://github.com/plumthedev/yii2-php-cs-fixer-config
7+ * @copyright Copyright (c) 2019 plumthedev
8+ * @license https://github.com/plumthedev/yii2-php-cs-fixer-config/blob/master/LICENSE
9+ * @version 1.0.1
710 */
811
912namespace plumthedev \PhpCsFixer ;
1013
1114use PhpCsFixer \Config as PhpCsFixerConfig ;
15+ use yii \helpers \ArrayHelper ;
1216
1317class Config extends PhpCsFixerConfig
1418{
@@ -17,11 +21,7 @@ public function __construct($name = 'yii2-php-cs-fixer-config')
1721 parent ::__construct ($ name );
1822 $ this ->setRiskyAllowed (true );
1923 $ this ->setFinder (Finder::create ());
20- }
21- 22- public function getRules ()
23- {
24- return [
24+ $ this ->setRules ([
2525 '@PSR2 ' => true ,
2626 'array_syntax ' => [
2727 'syntax ' => 'short ' ,
@@ -124,6 +124,13 @@ public function getRules()
124124 'trim_array_spaces ' => true ,
125125 'unary_operator_spaces ' => true ,
126126 'whitespace_after_comma_in_array ' => true ,
127- ];
127+ ]);
128+ }
129+ 130+ public function mergeRules ($ rules )
131+ {
132+ $ mergedRules = ArrayHelper::merge ($ this ->getRules (), $ rules );
133+ $ this ->setRules ($ mergedRules );
134+ return $ this ;
128135 }
129136}
0 commit comments