From dce9aa03238c69757039b70c064db4264814fd59 Mon Sep 17 00:00:00 2001 From: lotyp Date: Thu, 23 May 2024 14:43:38 +0300 Subject: [PATCH] fix: PSR-12 space_before_parenthesis --- src/ConfigBuilder.php | 26 ++++++++++++++++++-------- src/RuleSets/DefaultSet.php | 3 +++ src/RuleSets/ExtendedPERSet.php | 7 +++++++ 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/src/ConfigBuilder.php b/src/ConfigBuilder.php index debfa05a..54ab11ec 100644 --- a/src/ConfigBuilder.php +++ b/src/ConfigBuilder.php @@ -22,6 +22,15 @@ final class ConfigBuilder { private Config $config; + private function __construct(private readonly RuleSet $ruleSet) + { + $this->config = new Config($ruleSet->name()); + $this->config + ->setRiskyAllowed($ruleSet->allowRisky()) + ->setUsingCache($ruleSet->useCache()) + ; + } + public static function createFromRuleSet(RuleSet $ruleSet): self { return new self($ruleSet); @@ -62,18 +71,19 @@ public function addFiles(array $files): self return $this; } - public function getConfig(): ConfigInterface + /** + * @param list $files + */ + public function exclude(array $files): self { - return $this->config->setRules($this->ruleSet->rules()); + $this->getFinder()->exclude($files); + + return $this; } - private function __construct(private readonly RuleSet $ruleSet) + public function getConfig(): ConfigInterface { - $this->config = new Config($ruleSet->name()); - $this->config - ->setRiskyAllowed($ruleSet->allowRisky()) - ->setUsingCache($ruleSet->useCache()) - ; + return $this->config->setRules($this->ruleSet->rules()); } private function getFinder(): Finder diff --git a/src/RuleSets/DefaultSet.php b/src/RuleSets/DefaultSet.php index 475c2142..1c2ff468 100644 --- a/src/RuleSets/DefaultSet.php +++ b/src/RuleSets/DefaultSet.php @@ -148,6 +148,9 @@ public function rules(): array 'self_static_accessor' => true, 'no_useless_else' => true, 'no_useless_return' => true, + 'class_definition' => [ + 'space_before_parenthesis' => false, + ], /* * @PhpCsFixer:risky diff --git a/src/RuleSets/ExtendedPERSet.php b/src/RuleSets/ExtendedPERSet.php index 6475808a..75aac8ad 100644 --- a/src/RuleSets/ExtendedPERSet.php +++ b/src/RuleSets/ExtendedPERSet.php @@ -43,6 +43,13 @@ public function rules(): array */ '@PER-CS2.0' => true, + /* + * @PER-CS2.0 Overrides + */ + 'class_definition' => [ + 'space_before_parenthesis' => false, + ], + /* * @Symfony */