Commit 38c9f80e authored by Guillaume Perréal's avatar Guillaume Perréal
Browse files

Permet de surcharger ponctuellement des règles avec ->setRule et ->setRules.

Showing with 23 additions and 2 deletions
+23 -2
...@@ -41,6 +41,9 @@ final class Config extends PhpCsFixerConfig ...@@ -41,6 +41,9 @@ final class Config extends PhpCsFixerConfig
*/ */
private $docHeaderfile = '.docheader'; private $docHeaderfile = '.docheader';
/** @var array<string, mixed> */
private $ruleOverrides = [];
/** /**
* Set cacheFile. * Set cacheFile.
* *
...@@ -66,7 +69,7 @@ final class Config extends PhpCsFixerConfig ...@@ -66,7 +69,7 @@ final class Config extends PhpCsFixerConfig
*/ */
public function getRules() public function getRules()
{ {
return array_merge( return array_replace(
$this->ruleSets(), $this->ruleSets(),
[ [
// Configuration && overrides // Configuration && overrides
...@@ -100,10 +103,28 @@ final class Config extends PhpCsFixerConfig ...@@ -100,10 +103,28 @@ final class Config extends PhpCsFixerConfig
// Risky // Risky
'is_null' => ['use_yoda_style' => false], 'is_null' => ['use_yoda_style' => false],
'non_printable_character' => ['use_escape_sequences_in_strings' => true], 'non_printable_character' => ['use_escape_sequences_in_strings' => true],
] : [] ] : [],
$this->ruleOverrides
); );
} }
/**
* @param string $rule
* @param mixed $setting
*/
public function setRule(string $rule, $setting)
{
$this->ruleOverrides[$rule] = $setting;
}
/**
* {@inheritDoc}
*/
public function setRules(array $rules)
{
$this->ruleOverrides = array_replace($this->ruleOverrides, $rules);
}
/** /**
* @return string * @return string
*/ */
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment